feat: 徽章处理

This commit is contained in:
Blizzard
2026-02-14 15:35:12 +08:00
parent 4ffc41ea84
commit 3f50901ac6
10 changed files with 157 additions and 8 deletions
+20
View File
@@ -82,3 +82,23 @@ func (a *UserProfileApi) MyStars(c *gin.Context) {
PageSize: req.PageSize,
}, c)
}
// MyBadges 我的徽章
// @Tags 个人中心
// @Summary 我的徽章
// @Security BearerAuth
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /profile/badge [get]
func (a *UserProfileApi) MyBadges(c *gin.Context) {
userId := auth.GetUserId(c)
list, err := userProfileService.MyBadges(userId)
if err != nil {
global.Logger.Error("获取用户徽章失败", zap.Error(err))
response.FailWithMsg("获取用户徽章失败", c)
return
}
response.OkWithData(response.ListResult{
List: list,
}, c)
}
+51
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"
@@ -113,6 +114,31 @@ func (a *WikiApi) WikiDetail(c *gin.Context) {
response.OkWithData(topic, c)
}
// DeleteWiki 删除百科
// @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 /wiki/delete [post]
func (a *WikiApi) DeleteWiki(c *gin.Context) {
var req common.IdsReq
err := c.ShouldBindJSON(&req)
if err != nil {
response.FailWithMsg("请求参数错误", c)
return
}
err = wikiService.DeleteWiki(req)
if err != nil {
global.Logger.Error("删除失败", zap.Error(err))
response.FailWithMsg("删除失败", c)
return
}
response.OkWithMsg("删除成功", c)
}
// StarWiki 收藏百科
// @Tags 百科
// @Summary 收藏百科
@@ -134,3 +160,28 @@ func (a *WikiApi) StarWiki(c *gin.Context) {
}
response.OkWithMsg("操作成功", c)
}
// UploadImg 上传图片
// @Tags 百科
// @Summary 上传图片
// @Security BearerAuth
// @accept application/json
// @Produce application/json
// @Param data body common.UploadOss true "上传图片"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"上传成功"}"
// @Router /wiki/uploadImg [post]
func (a *WikiApi) UploadImg(c *gin.Context) {
var req common.UploadOss
err := c.ShouldBind(&req)
if err != nil {
response.FailWithMsg("请求参数错误", c)
return
}
err = wikiService.UploadImg(req)
if err != nil {
global.Logger.Error("上传失败", zap.Error(err))
response.FailWithMsg("上传失败", c)
return
}
response.OkWithMsg("上传成功", c)
}