feat: 个人中心发布

This commit is contained in:
Blizzard
2026-02-14 11:38:59 +08:00
parent f1d9f63296
commit 4820323381
35 changed files with 691 additions and 148 deletions
+48
View File
@@ -2,6 +2,7 @@ package plant
import (
"sundynix-go/global"
common "sundynix-go/model/commom/request"
"sundynix-go/model/commom/response"
plantReq "sundynix-go/model/plant/request"
"sundynix-go/utils/auth"
@@ -148,3 +149,50 @@ func (a *PostApi) CommentPost(c *gin.Context) {
}
response.OkWithMsg("评论成功", c)
}
// DeletePost 删除帖子
// @Tags 帖子
// @Summary 删除帖子
// @Security BearerAuth
// @accept application/json
// @Produce application/json
// @Param data body common.IdsReq true "删除帖子"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /post/delete [post]
func (a *PostApi) DeletePost(c *gin.Context) {
var req common.IdsReq
err := c.ShouldBindJSON(&req)
if err != nil {
response.FailWithMsg("请求参数错误", c)
return
}
err = postService.DeletePost(req.Ids)
if err != nil {
global.Logger.Error("删除帖子失败", zap.Error(err))
response.FailWithMsg("删除帖子失败", c)
return
}
response.OkWithMsg("删除帖子成功", c)
}
// StarPost 收藏帖子
// @Tags 帖子
// @Summary 收藏帖子
// @Security BearerAuth
// @Produce application/json
// @Param id query string true "帖子id"
// @Param type query string true "收藏类型 1 收藏 2 取消收藏"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"收藏成功"}"
// @Router /post/star [get]
func (a *PostApi) StarPost(c *gin.Context) {
postId := c.Query("id")
class := c.Query("type")
userId := auth.GetUserId(c)
err := postService.StarPost(userId, postId, class)
if err != nil {
global.Logger.Error("操作失败", zap.Error(err))
response.FailWithMsg("操作失败", c)
return
}
response.OkWithMsg("操作成功", c)
}