dao

package
v0.0.0-...-5da3697 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

dao 层进行了数据访问对象的封装,并针对业务所需的字段进行了处理。

Index

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 New

func New(engine *gorm.DB) *Dao

func (*Dao) CheckName

func (d *Dao) CheckName(ctx context.Context, name string) bool

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

func (d *Dao) CountTag(ctx context.Context, name string, state uint8) (int, error)

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

func (d *Dao) CreateTag(ctx context.Context, name string, state uint8, crateBy string) error

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

func (d *Dao) DeleteTag(ctx context.Context, id uint32) (bool, error)

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

func (d *Dao) GetAuth(appkey, appSecret string) (model.Auth, error)

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

func (d *Dao) GetTag(ctx context.Context, id uint32, state uint8) (model.BlogTag, error)

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.

func (*Dao) UpdateTag

func (d *Dao) UpdateTag(ctx context.Context, id uint32, name string, state uint8, modifiedBy string) error

UpdateTag tag's function is db.Updates use values store key value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL