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
+27 -2
View File
@@ -4,6 +4,7 @@ import (
"sundynix-go/global"
"sundynix-go/model/commom/response"
plantReq "sundynix-go/model/plant/request"
"sundynix-go/utils/auth"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
@@ -78,7 +79,8 @@ func (a *WikiApi) WikiPage(c *gin.Context) {
response.FailWithMsg("请求参数错误", c)
return
}
list, total, err := wikiService.WikiPage(req)
userId := auth.GetUserId(c)
list, total, err := wikiService.WikiPage(req, userId)
if err != nil {
global.Logger.Error("分页百科失败", zap.Error(err))
response.FailWithMsg("分页百科失败", c)
@@ -102,10 +104,33 @@ func (a *WikiApi) WikiPage(c *gin.Context) {
// @Router /wiki/detail [get]
func (a *WikiApi) WikiDetail(c *gin.Context) {
id := c.Query("id")
topic, err := wikiService.Detail(id)
userId := auth.GetUserId(c)
topic, err := wikiService.Detail(id, userId)
if err != nil {
response.FailWithMsg("获取失败", c)
return
}
response.OkWithData(topic, c)
}
// StarWiki 收藏百科
// @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 /wiki/star [get]
func (a *WikiApi) StarWiki(c *gin.Context) {
postId := c.Query("id")
class := c.Query("type")
userId := auth.GetUserId(c)
err := wikiService.StarWiki(userId, postId, class)
if err != nil {
global.Logger.Error("操作失败", zap.Error(err))
response.FailWithMsg("操作失败", c)
return
}
response.OkWithMsg("操作成功", c)
}