Documentation ¶
Index ¶
- func CtxWithTransaction(ctx context.Context, tx *gorm.DB) context.Context
- func GetDBWithCtx(ctx context.Context) *gorm.DB
- func NewDBEngine(dbSetting *setting.DatabaseSetting) (*gorm.DB, error)
- func Transaction(ctx context.Context, fn func(txctx context.Context) error) error
- type Article
- func (a *Article) Count(db *gorm.DB) (int, error)
- func (a *Article) Create(db *gorm.DB) error
- func (a *Article) Delete(db *gorm.DB) error
- func (a *Article) Get(db *gorm.DB) (*Article, error)
- func (a *Article) List(db *gorm.DB, pageOffset, pageSize int) ([]*Article, error)
- func (a *Article) Update(db *gorm.DB, updateMap map[string]any) error
- type Model
- type Tag
- func (t *Tag) Count(db *gorm.DB) (int, error)
- func (t *Tag) Create(db *gorm.DB) error
- func (t *Tag) Delete(db *gorm.DB) error
- func (t *Tag) Get(db *gorm.DB) (*Tag, error)
- func (t *Tag) List(db *gorm.DB, pageOffset, pageSize int) ([]*Tag, error)
- func (t *Tag) Update(db *gorm.DB, updateMap map[string]any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDBEngine ¶
func NewDBEngine(dbSetting *setting.DatabaseSetting) (*gorm.DB, error)
Types ¶
type Article ¶
type Article struct { *Model Title string `json:"title"` Desc string `json:"desc"` Content string `json:"content"` CoverImageUrl string `json:"cover_image_url"` TagID uint32 `json:"-"` Tag *Tag `json:"tag" gorm:"-"` }
type Model ¶
type Model struct { ID uint32 `json:"id"` CreatedAt uint32 `json:"create_time"` UpdatedAt uint32 `json:"update_time"` DeletedAt soft_delete.DeletedAt `json:"-"` // gorm查询会自动过滤被软删除的结果,软删除即 deleted_at != 0 CreatedBy string `json:"create_by"` UpdatedBy string `json:"update_by"` Status uint8 `json:"status"` // 1启用,2禁用,99删除 }
Click to show internal directories.
Click to hide internal directories.