dao

package
v0.0.0-...-e972461 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateOpen  = 1
	StateClose = 0
)

Variables

This section is empty.

Functions

func Close

func Close(db *gorm.DB) error

func NewDBEngine

func NewDBEngine(databaseSetting *setting.DatabaseSettingS) (*gorm.DB, error)

Types

type ArticleDao

type ArticleDao interface {
	CreateArticle(title string, desc string, content string, image string,
		state uint8, createdBy string) (*ArticleModel, error)
	UpdateArticle(id uint32, title string, desc string, content string, image string,
		state uint8, modifiedBy string) error
	GetArticle(id uint32, state uint8) (ArticleModel, error)
	DeleteArticle(id uint32) error
	CountArticleListByTagID(id uint32, state uint8) (int64, error)
	GetArticleListByTagID(id uint32, state uint8, page, pageSize int) ([]*ArticleTagRow, error)
}

type ArticleDaoDB

type ArticleDaoDB struct {
	// contains filtered or unexported fields
}

func NewArticleDaoDB

func NewArticleDaoDB(db *gorm.DB) *ArticleDaoDB

func (*ArticleDaoDB) CountArticleListByTagID

func (d *ArticleDaoDB) CountArticleListByTagID(id uint32, state uint8) (int64, error)

func (*ArticleDaoDB) CreateArticle

func (d *ArticleDaoDB) CreateArticle(title string, desc string, content string, image string,
	state uint8, createdBy string) (*ArticleModel, error)

func (*ArticleDaoDB) DeleteArticle

func (d *ArticleDaoDB) DeleteArticle(id uint32) error

func (*ArticleDaoDB) GetArticle

func (d *ArticleDaoDB) GetArticle(id uint32, state uint8) (ArticleModel, error)

func (*ArticleDaoDB) GetArticleListByTagID

func (d *ArticleDaoDB) GetArticleListByTagID(id uint32, state uint8, page, pageSize int) ([]*ArticleTagRow, error)

func (*ArticleDaoDB) UpdateArticle

func (d *ArticleDaoDB) UpdateArticle(id uint32, title string, desc string, content string, image string,
	state uint8, modifiedBy string) error

type ArticleModel

type ArticleModel struct {
	*Model
	Title         string `json:"title"`
	Desc          string `json:"desc"`
	Content       string `json:"content"`
	CoverImageURL string `json:"cover_image_url"`
	State         uint8  `json:"state"`
}

Model to Artile.

func (ArticleModel) TableName

func (ArticleModel) TableName() string

type ArticleTagDao

type ArticleTagDao interface {
	GetArticleTagByAID(articleID uint32) (ArticleTagModel, error)
	GetArticleTagListByTID(tagID uint32) ([]*ArticleTagModel, error)
	GetArticleTagListByAIDs(articleIDs []uint32) ([]*ArticleTagModel, error)
	CreateArticleTag(articleID, tagID uint32, createdBy string) error
	UpdateArticleTag(articleID, tagID uint32, modifiedBy string) error
	DeleteArticleTag(articleID uint32) error
}

type ArticleTagDaoDB

type ArticleTagDaoDB struct {
	// contains filtered or unexported fields
}

func NewArticleTagDao

func NewArticleTagDao(db *gorm.DB) *ArticleTagDaoDB

func (*ArticleTagDaoDB) CreateArticleTag

func (d *ArticleTagDaoDB) CreateArticleTag(articleID, tagID uint32, createdBy string) error

func (*ArticleTagDaoDB) DeleteArticleTag

func (d *ArticleTagDaoDB) DeleteArticleTag(articleID uint32) error

func (*ArticleTagDaoDB) GetArticleTagByAID

func (d *ArticleTagDaoDB) GetArticleTagByAID(articleID uint32) (ArticleTagModel, error)

TODO: combine single query and batch query.

func (*ArticleTagDaoDB) GetArticleTagListByAIDs

func (d *ArticleTagDaoDB) GetArticleTagListByAIDs(articleIDs []uint32) ([]*ArticleTagModel, error)

func (*ArticleTagDaoDB) GetArticleTagListByTID

func (d *ArticleTagDaoDB) GetArticleTagListByTID(tagID uint32) ([]*ArticleTagModel, error)

func (*ArticleTagDaoDB) UpdateArticleTag

func (d *ArticleTagDaoDB) UpdateArticleTag(articleID, tagID uint32, modifiedBy string) error

type ArticleTagModel

type ArticleTagModel struct {
	*Model
	TagID     uint32 `json:"tag_id"`
	ArticleID uint32 `json:"article_id"`
}

Model to Artile-Tag.

func (ArticleTagModel) TableName

func (ArticleTagModel) TableName() string

type ArticleTagRow

type ArticleTagRow struct {
	Article ArticleModel
	Tag     TagModel
}

type Model

type Model struct {
	ID         uint32 `gorm:"primary_key" json:"id"`
	CreatedBy  string `json:"created_by"`
	ModifiedBy string `json:"modified_by"`
	IsDel      uint8  `json:"is_del"`
}

type TagDao

type TagDao interface {
	GetTag(id uint32, state uint8) (TagModel, error)
	GetTagList(name string, state uint8, page, pageSize int) ([]*TagModel, error)
	GetTagListByIDs(ids []uint32, state uint8) ([]*TagModel, error)
	CountTag(name string, state uint8) (int64, error)
	CreateTag(name string, state uint8, createdBy string) error
	UpdateTag(id uint32, name string, state uint8, modifiedBy string) error
	DeleteTag(id uint32) error
}

type TagDaoDB

type TagDaoDB struct {
	// contains filtered or unexported fields
}

func NewTagDao

func NewTagDao(db *gorm.DB) *TagDaoDB

func (*TagDaoDB) CountTag

func (d *TagDaoDB) CountTag(name string, state uint8) (int64, error)

func (*TagDaoDB) CreateTag

func (d *TagDaoDB) CreateTag(name string, state uint8, createdBy string) error

func (*TagDaoDB) DeleteTag

func (d *TagDaoDB) DeleteTag(id uint32) error

func (*TagDaoDB) GetTag

func (d *TagDaoDB) GetTag(id uint32, state uint8) (TagModel, error)

func (*TagDaoDB) GetTagList

func (d *TagDaoDB) GetTagList(name string, state uint8, page, pageSize int) ([]*TagModel, error)

func (*TagDaoDB) GetTagListByIDs

func (d *TagDaoDB) GetTagListByIDs(ids []uint32, state uint8) ([]*TagModel, error)

func (*TagDaoDB) UpdateTag

func (d *TagDaoDB) UpdateTag(id uint32, name string, state uint8, modifiedBy string) error

type TagModel

type TagModel struct {
	*Model
	Name  string `json:"name"`
	State uint8  `json:"state"`
}

Model to tag.

func (TagModel) TableName

func (TagModel) TableName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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