Files
web_huakui_server/web/api/web_commend/commend.go
T
rootandClaude Opus 4.7 85c0071fd8 feat: 从黄果 NET hgdjnet-server 9bfbafe 导入 HKDJ 官网后端
来源:hgdjnet-server 9bfbafe10d417deea959bd53117bc88a10e60a83
项目身份 HKDJ / JHA-216,独立官网仓库,Jenkins 守卫键 hkdjnet
测试目录 /server/hkdj_net,App/Web API 30331/30332

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-10-16 11:20:04 +08:00

169 lines
4.5 KiB
Go

package web_commend
import (
"hkdj-web-server/pub/common"
"hkdj-web-server/pub/common/srvdef"
"hkdj-web-server/web/service/srv_commend"
"github.com/gin-gonic/gin"
)
// @Tags 评论
// @Summary 评论列表
// @Description 评论列表
// @Accept json
// @Produce json
// @Param param body srv_commend.CommendSearch true "参数列表"
// @Success 200 {object} srv_commend.CommendSearchResp "成功"
// @Failure 400 {string} string "失败"
// @Router /api/web/post/comment/list [POST]
func SearchManyCommend(ctx *gin.Context) {
var req = &srv_commend.CommendSearch{}
if err := ctx.ShouldBind(req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
resp, serr := srv_commend.SearchComandList(ctx, req)
if serr != nil {
common.ServerJSON(ctx, serr.Code, serr.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}
type CommendDelReq struct {
Id int64 `json:"id" binding:"required"`
}
type CommendDelIpReq struct {
Ip string `json:"ip"`
}
// @Tags 评论
// @Summary 删除一个评论
// @Description 删除一个评论
// @Accept json
// @Produce json
// @Param param body CommendDelReq true "参数列表"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "获取失败的返回结果"
// @Router /api/web/post/comment/del [POST]
func DelCommend(ctx *gin.Context) {
var req = &CommendDelReq{}
if err := ctx.ShouldBind(req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
serr := srv_commend.DelCommend(ctx, req.Id)
if serr != nil {
common.ServerJSON(ctx, serr.Code, serr.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, nil)
}
// @Tags 评论
// @Summary 删除一个用户所有评论
// @Description 删除一个用户所有评论
// @Accept json
// @Produce json
// @Param param body CommendDelIpReq true "参数列表"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "获取失败的返回结果"
// @Router /api/web/post/comment/user/del [POST]
func DelUserCommend(ctx *gin.Context) {
var req = &CommendDelIpReq{}
if err := ctx.ShouldBind(req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
serr := srv_commend.DelUserCommend(ctx, req.Ip)
if serr != nil {
common.ServerJSON(ctx, serr.Code, serr.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, nil)
}
// @Tags 评论
// @Summary 回复评论
// @Description 回复评论
// @Accept json
// @Produce json
// @Param param body srv_commend.CommendReplay true "参数列表"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "获取失败的返回结果"
// @Router /api/web/post/comment/replay [POST]
func ReplayPostComment(ctx *gin.Context) {
var req = &srv_commend.CommendReplay{}
if err := ctx.ShouldBind(req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
serr := srv_commend.AddPostComment(ctx, req)
if serr != nil {
common.ServerJSON(ctx, serr.Code, serr.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, nil)
}
type CommendReviewBatchReq struct {
Ids *[]int64 `json:"ids"`
ReviewStatus int `json:"reviewStatus"`
}
// @Tags 评论
// @Summary 批量审核评论
// @Description 批量审核评论
// @Accept json
// @Produce json
// @Param param body CommendReviewBatchReq true "参数列表"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "获取失败的返回结果"
// @Security ApiKeyAuth
// @Router /api/web/post/comment/reviewBatch [POST]
func ReviewCommendBatch(ctx *gin.Context) {
var req = &CommendReviewBatchReq{}
if err := ctx.ShouldBind(req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
serr := srv_commend.ReviewCommendBatch(ctx, req.Ids, req.ReviewStatus)
if serr != nil {
common.ServerJSON(ctx, serr.Code, serr.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, nil)
}
// @Tags 评论
// @Summary 审核评论
// @Description 审核评论
// @Accept json
// @Produce json
// @Param param body srv_commend.CommendReviewReq true "参数列表"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "获取失败的返回结果"
// @Security ApiKeyAuth
// @Router /api/web/post/comment/review [POST]
func ReviewComment(ctx *gin.Context) {
var req = &srv_commend.CommendReviewReq{}
if err := ctx.ShouldBind(req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
serr := srv_commend.ReviewComment(ctx, req.Id, req.ReviewStatus)
if serr != nil {
common.ServerJSON(ctx, serr.Code, serr.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, nil)
}