Documentation
¶
Index ¶
- func CantWriteNew(userId uint64, maxCount int64) bool
- func Create(entity *Entity) int64
- func DecrementLike(entity Entity) int64
- func DecrementReplyFast(articleId uint64, posters []Poster) error
- func Delete(entity *Entity) int64
- func GetCountGroupByDay() ([]map[string]any, error)
- func GetMapByIds(ids []uint64) map[uint64]*SmallEntity
- func GetMaxId() uint64
- func GetUserCount(userId uint64) int64
- func IncrementLike(entity Entity) int64
- func IncrementReply(entity Entity) int64
- func IncrementReplyFast(articleId uint64, posters []Poster) error
- func IncrementView(entity Entity) int64
- func Page[ResType SmallEntity](q PageQuery) struct{ ... }
- func Save(entity *Entity) error
- func SaveNoUpdate(entity *Entity) error
- func UpdatePosters(id uint64, posters []Poster) error
- type Entity
- type PageQuery
- type Poster
- type SmallEntity
- func GetAllSimple(offset, limit int) ([]*SmallEntity, error)
- func GetByIds(ids []uint64) (entities []*SmallEntity)
- func GetLatestArticles(limit int) ([]SmallEntity, error)
- func GetLatestArticlesByUserId(userId uint64, limit int) ([]*SmallEntity, error)
- func GetRecommendedArticles(limit int) ([]SmallEntity, error)
- func GetRecommendedArticlesByAuthorId(authorId uint64, limit int) ([]*SmallEntity, error)
- func GetSimple(id any) (entity SmallEntity)
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CantWriteNew ¶
func DecrementLike ¶ added in v0.0.2
func DecrementReplyFast ¶ added in v0.1.1
func GetCountGroupByDay ¶ added in v0.1.1
GetCountGroupByDay groups article counts by day.
func GetMapByIds ¶
func GetMapByIds(ids []uint64) map[uint64]*SmallEntity
func GetUserCount ¶ added in v0.0.3
func IncrementLike ¶ added in v0.0.2
func IncrementReply ¶
func IncrementReplyFast ¶ added in v0.1.1
func IncrementView ¶
func Page ¶
func Page[ResType SmallEntity](q PageQuery) struct { Page int PageSize int Total int64 Data []ResType }
func SaveNoUpdate ¶ added in v0.0.2
func UpdatePosters ¶ added in v0.1.1
Types ¶
type Entity ¶
type Entity struct {
Id uint64 `gorm:"primaryKey;column:id;autoIncrement;not null;" json:"id"` //
Title string `gorm:"column:title;type:varchar(512);not null;default:'';" json:"title"` //
Content string `gorm:"column:content;type:text;" json:"content"` //
Description string `gorm:"column:description;type:varchar(255);not null;default:'';" json:"description"` // 文章描述,用于SEO
RenderedHTML string `gorm:"column:rendered_html;type:text;" json:"renderedHTML"` //md 渲染后数据
RenderedVersion uint32 `gorm:"column:rendered_version;type:bigint unsigned;not null;default:0;" json:"renderedVersion"` //md 的渲染器版本
Type int8 `gorm:"column:type;type:tinyint;not null;default:0;" json:"type"` // 文章类型:0 博文,1教程,2问答,3分享
CategoryId []uint64 `gorm:"column:category_id;type:varchar(255);not null;default:'[]';serializer:json" json:"categoryId"` // 分类
UserId uint64 `gorm:"column:user_id;type:bigint unsigned;not null;default:0;index:idx_user_status;" json:"userId"` //
Posters []Poster `gorm:"column:posters;type:text;serializer:json" json:"posters"`
ArticleStatus int8 `` // 文章状态:0 草稿 1 发布
/* 131-byte string literal not displayed */
ProcessStatus int8 `` // 管理状态:0 正常 1 封禁
/* 132-byte string literal not displayed */
LikeCount uint64 `gorm:"column:like_count;type:bigint unsigned;not null;default:0;" json:"likeCount"` // 喜欢数量
ViewCount uint64 `gorm:"column:view_count;index;type:bigint unsigned;not null;default:0;" json:"viewCount"` // 访问数量
ReplyCount uint64 `gorm:"column:reply_count;type:bigint unsigned;not null;default:0;index;" json:"replyCount"` // 评论数量
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime;<-:create;" json:"createdAt"` //
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime;index:idx_updated_at_status,priority:1;" json:"updatedAt"`
DeletedAt gorm.DeletedAt //
}
func GetLatestArticlesWithContent ¶ added in v0.1.1
type SmallEntity ¶
type SmallEntity struct {
Id uint64 `gorm:"primaryKey;column:id;autoIncrement;not null;" json:"id"` //
Title string `gorm:"column:title;type:varchar(512);not null;default:'';" json:"title"` //
Description string `gorm:"column:description;type:varchar(255);not null;default:'';" json:"description"` // 文章描述,用于SEO
Type int8 `gorm:"column:type;type:tinyint;not null;default:0;" json:"type"` // 文章类型:0 博文,1教程,2问答,3分享
CategoryId []uint64 `gorm:"column:category_id;type:varchar(255);not null;default:'[]';serializer:json" json:"categoryId"` // 分类
UserId uint64 `gorm:"column:user_id;type:bigint unsigned;not null;default:0;" json:"userId"` //
Posters []Poster `gorm:"column:posters;type:text;serializer:json" json:"posters"`
ArticleStatus int8 `gorm:"column:article_status;type:tinyint;not null;default:0;" json:"articleStatus"` // 文章状态:0 草稿 1 发布
ProcessStatus int8 `gorm:"column:process_status;type:tinyint;not null;default:0;" json:"processStatus"` // 管理状态:0 正常 1 封禁
ViewCount uint64 `gorm:"column:view_count;type:bigint unsigned;not null;default:0;" json:"viewCount"` // 访问数量
ReplyCount uint64 `gorm:"column:reply_count;type:bigint unsigned;not null;default:0;" json:"replyCount"` // 评论
LikeCount uint64 `gorm:"column:like_count;type:bigint unsigned;not null;default:0;" json:"likeCount"` // 被喜欢
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime;<-:create;" json:"createdAt"` //
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime;" json:"updatedAt"`
DeletedAt gorm.DeletedAt //
}
func GetAllSimple ¶ added in v0.1.1
func GetAllSimple(offset, limit int) ([]*SmallEntity, error)
GetAllSimple returns paginated simple entities for export and repair jobs.
func GetByIds ¶
func GetByIds(ids []uint64) (entities []*SmallEntity)
func GetLatestArticles ¶
func GetLatestArticles(limit int) ([]SmallEntity, error)
GetLatestArticles 获取最新的n篇文章
func GetLatestArticlesByUserId ¶
func GetLatestArticlesByUserId(userId uint64, limit int) ([]*SmallEntity, error)
func GetRecommendedArticles ¶
func GetRecommendedArticles(limit int) ([]SmallEntity, error)
func GetRecommendedArticlesByAuthorId ¶
func GetRecommendedArticlesByAuthorId(authorId uint64, limit int) ([]*SmallEntity, error)
func GetSimple ¶ added in v0.1.1
func GetSimple(id any) (entity SmallEntity)
func (*SmallEntity) GetPosters ¶ added in v0.1.1
func (itself *SmallEntity) GetPosters() []Poster
func (*SmallEntity) PubDate ¶ added in v0.0.6
func (itself *SmallEntity) PubDate() string
func (*SmallEntity) TableName ¶
func (itself *SmallEntity) TableName() string
Click to show internal directories.
Click to hide internal directories.