feat: post api
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package plant
|
||||
|
||||
import (
|
||||
"sundynix-go/global"
|
||||
"sundynix-go/model/system"
|
||||
)
|
||||
|
||||
// Post 帖子
|
||||
type Post struct {
|
||||
global.BaseModel
|
||||
UserId string `json:"userId" form:"userId" gorm:"column:user_id;size:50;comment:用户id"`
|
||||
Title string `json:"title" form:"title" gorm:"column:title;size:100;comment:帖子标题"`
|
||||
Content string `json:"content" form:"content" gorm:"column:content;size:500;comment:帖子内容"`
|
||||
ViewCount int `json:"viewCount" form:"viewCount" gorm:"default:0;column:view_count;comment:浏览次数"`
|
||||
CommentCount int `json:"commentCount" form:"commentCount" gorm:"default:0;column:comment_count;comment:评论次数"`
|
||||
LikeCount int `json:"likeCount" form:"likeCount" gorm:"default:0;column:like_count;comment:点赞次数"`
|
||||
Location string `json:"location" form:"location" gorm:"column:location;size:100;comment:位置"`
|
||||
HasReviewed int `json:"hasReviewed" form:"hasReviewed" gorm:"column:has_reviewed;comment:是否审核通过"`
|
||||
HasLiked int `json:"hasLiked" form:"hasLiked" gorm:"-"`
|
||||
//图片
|
||||
ImgList []*system.Oss `json:"imgList" form:"imgList" gorm:"many2many:post_oss;comment:图片列表"`
|
||||
//评论
|
||||
CommentList []*PostComment `json:"commentList" form:"commentList" gorm:"foreignKey:PostId;comment:评论列表"`
|
||||
//点赞
|
||||
LikeList []*PostLike `json:"likeList" form:"likeList" gorm:"foreignKey:PostId;comment:点赞列表"`
|
||||
Publisher *system.User `json:"publisher" form:"publisher" gorm:"foreignKey:UserId;comment:用户"`
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package plant
|
||||
|
||||
import (
|
||||
"sundynix-go/global"
|
||||
"sundynix-go/model/system"
|
||||
)
|
||||
|
||||
type PostComment struct {
|
||||
global.BaseModel
|
||||
RootId string `json:"rootId" form:"rootId" gorm:"column:root_id;size:50;default:'0';comment:根评论id"`
|
||||
ParentId string `json:"parentId" form:"parentId" gorm:"column:parent_id;size:50;comment:父级评论id"`
|
||||
PostId string `json:"postId" form:"postId" gorm:"index;column:post_id;size:50;comment:帖子id"`
|
||||
UserId string `json:"userId" form:"userId" gorm:"index;column:user_id;size:50;comment:用户id"`
|
||||
Content string `json:"content" form:"content" gorm:"column:content;size:500;comment:评论内容"`
|
||||
Commentator *system.User `json:"commentator" form:"commentator" gorm:"foreignKey:UserId;comment:评论者"`
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package plant
|
||||
|
||||
import (
|
||||
"sundynix-go/global"
|
||||
"sundynix-go/model/system"
|
||||
)
|
||||
|
||||
type PostLike struct {
|
||||
global.BaseModel
|
||||
PostId string `json:"postId" form:"postId" gorm:"index;column:post_id;size:50;comment:帖子id"`
|
||||
UserId string `json:"userId" form:"userId" gorm:"index;column:user_id;size:50;comment:用户id"`
|
||||
Liker *system.User `json:"liker" form:"liker" gorm:"foreignKey:UserId;comment:点赞者"`
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package request
|
||||
|
||||
import common "sundynix-go/model/commom/request"
|
||||
|
||||
type CreatePost struct {
|
||||
Title string `json:"title"` // 标题 必须
|
||||
Content string `json:"content"` // 内容
|
||||
Location string `json:"location"` //位置
|
||||
OssIds []string `json:"ossIds"` // 图片id[]
|
||||
}
|
||||
|
||||
// UpdatePost 修改帖子
|
||||
type UpdatePost struct {
|
||||
Id string `json:"id" binding:"required"`
|
||||
Title string `json:"title"` // 标题
|
||||
Content string `json:"content"` // 内容
|
||||
}
|
||||
|
||||
// PostPage 帖子列表
|
||||
type PostPage struct {
|
||||
common.PageInfo
|
||||
Title string `json:"title"` // 标题
|
||||
HasReviewed int `json:"hasReviewed"` //是否审核通过
|
||||
}
|
||||
|
||||
// CreateComment 创建评论
|
||||
type CreateComment struct {
|
||||
PostId string `json:"postId" binding:"required"` // 帖子id
|
||||
Content string `json:"content" binding:"required"` // 评论内容
|
||||
}
|
||||
Reference in New Issue
Block a user