Documentation
¶
Index ¶
- func CantWriteNew(userId uint64, maxCount int64) bool
- func Create(entity *Entity) int64
- func DecrementLike(entity Entity) int64
- func Delete(entity *Entity) int64
- func GetCount() int64
- func GetMapByIds(ids []uint64) map[uint64]*Entity
- func GetMaxId() uint64
- func GetMonthCount() int64
- func GetUserCount(userId uint64) int64
- func IncrementLike(entity Entity) int64
- func IncrementReply(entity Entity) int64
- func IncrementView(entity Entity) int64
- func Page[ResType SmallEntity](q PageQuery) struct{ ... }
- func Save(entity *Entity) error
- func SaveAll(entities *[]Entity) int64
- func SaveNoUpdate(entity *Entity) error
- type Entity
- type PageQuery
- type SmallEntity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CantWriteNew ¶
func DecrementLike ¶ added in v0.0.2
func GetMapByIds ¶
func GetMonthCount ¶ added in v0.0.3
func GetMonthCount() int64
func GetUserCount ¶ added in v0.0.3
func IncrementLike ¶ added in v0.0.2
func IncrementReply ¶
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
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分享
UserId uint64 `gorm:"column:user_id;type:bigint unsigned;not null;default:0;" json:"userId"` //
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 封禁
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;" json:"replyCount"` // 评论数量
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime;<-:create;" json:"createdAt"` //
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime;index;" json:"updatedAt"`
DeletedAt *time.Time `gorm:"column:deleted_at;type:datetime;" json:"deletedAt"` //
}
func GetByUserAndTitle ¶
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分享
UserId uint64 `gorm:"column:user_id;type:bigint unsigned;not null;default:0;" json:"userId"` //
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 *time.Time `gorm:"column:deleted_at;type:datetime;" json:"deletedAt"` //
}
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 (*SmallEntity) TableName ¶
func (itself *SmallEntity) TableName() string
Click to show internal directories.
Click to hide internal directories.