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
+2 -2
View File
@@ -151,13 +151,13 @@ func (a *MyPlantApi) CompleteTask(c *gin.Context) {
return
}
userId := auth.GetUserId(c)
err = plantService.CompleteTask(req, userId)
res, err := plantService.CompleteTask(req, userId)
if err != nil {
global.Logger.Error("完成任务失败", zap.Error(err))
response.FailWithMsg("完成任务失败", c)
return
}
response.OkWithMsg("完成任务成功", c)
response.OkWithData(res, c)
}
// DeletePlants
+26
View File
@@ -67,3 +67,29 @@ func (o *OcrApi) MyClassifyLog(c *gin.Context) {
PageSize: req.PageSize,
}, c)
}
// DeleteClassifyLog
// @tags 识别相关
// @Summary 删除识别记录
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "删除识别记录"
// @Success 200 {object} response.Response{msg=string} "删除识别记录"
// @router /classify/deleteClassifyLog [post]
func (o *OcrApi) DeleteClassifyLog(c *gin.Context) {
var req request.IdsReq
err := c.ShouldBind(&req)
if err != nil {
response.FailWithMsg("请求参数错误", c)
return
}
userId := auth.GetUserId(c)
err = ocrService.DeleteClassifyLog(req, userId)
if err != nil {
global.Logger.Error("删除识别记录失败!", zap.Error(err))
response.FailWithMsg("删除识别记录失败!", c)
return
}
response.OkWithMsg("删除识别记录成功!", c)
}
+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)
}
+33
View File
@@ -1,11 +1,13 @@
package plant
import (
"sundynix-go/global"
"sundynix-go/model/commom/response"
"sundynix-go/model/plant/request"
"sundynix-go/utils/auth"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
type UserProfileApi struct{}
@@ -49,3 +51,34 @@ func (a *UserProfileApi) ProfileDetail(c *gin.Context) {
}
response.OkWithData(res, c)
}
// MyStars 我的收藏
// @Tags 个人中心
// @Summary 我的收藏
// @Security BearerAuth
// @accept application/json
// @Produce application/json
// @Param data body request.StarsPageReq true "分页获取收藏列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /profile/star [post]
func (a *UserProfileApi) MyStars(c *gin.Context) {
var req request.StarsPageReq
err := c.ShouldBindJSON(&req)
if err != nil {
response.FailWithMsg("请求参数错误", c)
return
}
userId := auth.GetUserId(c)
list, total, err := userProfileService.MyStars(req, userId)
if err != nil {
global.Logger.Error("获取收藏失败", zap.Error(err))
response.FailWithMsg("获取收藏失败", c)
return
}
response.OkWithData(response.PageResult{
List: list,
Total: total,
Page: req.Current,
PageSize: req.PageSize,
}, c)
}
+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)
}