Documentation
¶
Overview ¶
dao 层进行了数据访问对象的封装,并针对业务所需的字段进行了处理。
Index ¶
- type Dao
- func (d *Dao) CheckName(ctx context.Context, name string) bool
- func (d *Dao) CountTag(ctx context.Context, name string, state uint8) (int, error)
- func (d *Dao) CreateTag(ctx context.Context, name string, state uint8, crateBy string) error
- func (d *Dao) DeleteTag(ctx context.Context, id uint32) (bool, error)
- func (d *Dao) GetAuth(appkey, appSecret string) (model.Auth, error)
- func (d *Dao) GetTag(ctx context.Context, id uint32, state uint8) (model.BlogTag, error)
- func (d *Dao) GetTagList(ctx context.Context, name string, state uint8, page, pageSize int) ([]*model.BlogTag, error)
- func (d *Dao) UpdateTag(ctx context.Context, id uint32, name string, state uint8, modifiedBy string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dao ¶
type Dao struct {
// contains filtered or unexported fields
}
func (*Dao) CheckName ¶
CheckName checks the name of a BlogTag against the database and returns the corresponding BlogTag and an error if any. It takes a single parameter 'name' of type string and returns a BlogTag and an error.
func (*Dao) CountTag ¶
CountTag returns the count of tags with the given name and state.
It takes the following parameters: - name: a string representing the name of the tag. - state: a uint8 representing the state of the tag.
It returns an integer representing the count of tags and an error if any.
func (*Dao) CreateTag ¶
CreateTag creates a tag in the blog.
name: the name of the tag. state: the state of the tag. crateBy: the user who created the tag. error: an error if the tag creation fails.
func (*Dao) DeleteTag ¶
DeleteTag deletes a tag with the given ID.
It takes an ID of type uint32 as a parameter. It returns an error.
func (*Dao) GetAuth ¶
GetAuth returns the authentication model for the given app key and app secret.
Parameters: - appkey: the application key. - appSecret: the application secret.
Returns: - model.Auth: the authentication model. - error: an error if any occurred.
func (*Dao) GetTag ¶
GetTag retrieves a BlogTag from the Dao using the provided id and state.
Parameters:
- id: an unsigned 32-bit integer representing the id of the BlogTag.
- state: an unsigned 8-bit integer representing the state of the BlogTag.
Returns:
- a BlogTag struct representing the retrieved BlogTag.
- an error, if any occurred.
func (*Dao) GetTagList ¶
func (d *Dao) GetTagList(ctx context.Context, name string, state uint8, page, pageSize int) ([]*model.BlogTag, error)
GetTagList retrieves a list of BlogTag objects based on the given parameters.
Parameters: - name: a string representing the name of the tag. - state: an unsigned 8-bit integer representing the state of the tag. - page: an integer representing the page number. - pageSize: an integer representing the number of items per page.
Returns: - a slice of pointers to BlogTag objects. - an error if there was an issue retrieving the list.