Documentation ¶
Index ¶
- Constants
- Variables
- type ListPubPost
- type Pagination
- type Plate
- type Post
- type PostBiz
- func (pb *PostBiz) CreatePlate(ctx context.Context, plate Plate) error
- func (pb *PostBiz) CreatePost(ctx context.Context, post Post) (int64, error)
- func (pb *PostBiz) DeletePlate(ctx context.Context, plateId int64) error
- func (pb *PostBiz) DeletePost(ctx context.Context, post Post) error
- func (pb *PostBiz) GetPost(ctx context.Context, postId int64, uid int64) (Post, error)
- func (pb *PostBiz) GetPubPost(ctx context.Context, postId int64) (ListPubPost, error)
- func (pb *PostBiz) ListPlates(ctx context.Context, pagination Pagination) ([]Plate, error)
- func (pb *PostBiz) ListPost(ctx context.Context, pagination Pagination) ([]Post, error)
- func (pb *PostBiz) ListPubPost(ctx context.Context, pagination Pagination) ([]ListPubPost, error)
- func (pb *PostBiz) PublishPost(ctx context.Context, post Post) error
- func (pb *PostBiz) UpdatePlate(ctx context.Context, plate Plate) error
- func (pb *PostBiz) UpdatePost(ctx context.Context, post Post) error
- func (pb *PostBiz) UpdatePostStatus(ctx context.Context, post Post) error
- type PostData
Constants ¶
View Source
const ( Draft uint8 = iota // 0: 草稿状态 Published // 1: 发布状态 Withdrawn // 2: 撤回状态 Deleted // 3: 删除状态 )
Variables ¶
View Source
var ProviderSet = wire.NewSet(NewPostBiz)
ProviderSet is biz providers.
Functions ¶
This section is empty.
Types ¶
type ListPubPost ¶
type ListPubPost struct { ID int64 `bson:"id"` // MongoDB的ObjectID CreatedAt time.Time `bson:"createdat"` // 创建时间 UpdatedAt time.Time `bson:"updatedat"` // 更新时间 Title string `bson:"title"` // 文章标题 Content string `bson:"content"` // 文章内容 Status uint8 `bson:"status"` // 文章状态,如草稿、发布等 UserID int64 `bson:"userid"` // 用户uid Slug string `bson:"slug"` // 文章的唯一标识,用于生成友好URL CategoryID int64 `bson:"categoryid"` // 关联分类表的外键 PlateID int64 `bson:"plateid"` // 关联板块表的外键 Plate Plate `bson:"plate"` // 板块关系 Tags string `bson:"tags"` // 文章标签,以逗号分隔 CommentCount int64 `bson:"commentcount"` // 文章的评论数量 }
type Pagination ¶
type Plate ¶
type Plate struct { ID int64 `gorm:"primaryKey;autoIncrement"` // 板块ID Name string `gorm:"size:255;not null;uniqueIndex"` // 板块名称 Description string `gorm:"type:text"` // 板块描述 CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"` // 创建时间 UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime"` // 更新时间 DeletedAt sql.NullTime `gorm:"column:deleted_at;index"` // 删除时间 Deleted bool `gorm:"column:deleted;default:false"` // 是否删除 UserID int64 `gorm:"column:uid;index"` // 板主ID Posts []Post `gorm:"foreignKey:PlateID"` // 帖子关系 }
type Post ¶
type Post struct { ID int64 `gorm:"primarykey"` CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"` UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime"` DeletedAt sql.NullTime `gorm:"index"` Title string `gorm:"size:255;not null"` // 文章标题 Content string `gorm:"type:text;not null"` // 文章内容 Status uint8 `gorm:"default:0"` // 文章状态,如草稿、发布等 UserID int64 `gorm:"column:user_id;index"` // 用户uid Slug string `gorm:"size:100;uniqueIndex"` // 文章的唯一标识,用于生成友好URL CategoryID int64 `gorm:"index"` // 关联分类表的外键 PlateID int64 `gorm:"index"` // 关联板块表的外键 Plate Plate `gorm:"foreignKey:PlateID"` // 板块关系 Tags string `gorm:"type:varchar(255);default:''"` // 文章标签,以逗号分隔 CommentCount int64 `gorm:"default:0"` // 文章的评论数量 }
type PostBiz ¶
type PostBiz struct {
// contains filtered or unexported fields
}
func NewPostBiz ¶
func (*PostBiz) CreatePlate ¶
func (*PostBiz) CreatePost ¶
func (*PostBiz) DeletePlate ¶
func (*PostBiz) GetPubPost ¶
func (*PostBiz) ListPlates ¶
func (*PostBiz) ListPubPost ¶
func (pb *PostBiz) ListPubPost(ctx context.Context, pagination Pagination) ([]ListPubPost, error)
func (*PostBiz) UpdatePlate ¶
type PostData ¶
type PostData interface { Insert(ctx context.Context, post Post) (int64, error) // 创建一个新的帖子记录 UpdateById(ctx context.Context, post Post) error // 根据ID更新一个帖子记录 UpdateStatus(ctx context.Context, post Post) error // 更新帖子的状态 GetById(ctx context.Context, postId int64, uid int64) (Post, error) // 根据ID获取一个帖子记录 GetPubById(ctx context.Context, postId int64) (ListPubPost, error) // 根据ID获取一个已发布的帖子记录 ListPub(ctx context.Context, pagination Pagination) ([]ListPubPost, error) // 获取已发布的帖子记录列表 List(ctx context.Context, pagination Pagination) ([]Post, error) // 获取个人的帖子记录列表 DeleteById(ctx context.Context, post Post) error CreatePlate(ctx context.Context, plate Plate) error ListPlates(ctx context.Context, pagination Pagination) ([]Plate, error) UpdatePlate(ctx context.Context, plate Plate) error DeletePlate(ctx context.Context, plateId int64) error }
Click to show internal directories.
Click to hide internal directories.