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>
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
package commentapi
|
||||
|
||||
import (
|
||||
"hkdj-web-server/app/api/proto"
|
||||
"hkdj-web-server/app/service/commentser"
|
||||
"hkdj-web-server/pub/common"
|
||||
"hkdj-web-server/pub/common/ipaddr"
|
||||
"hkdj-web-server/pub/common/srvdef"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// SendComment 发布评论
|
||||
// @Tags 评论APP
|
||||
// @Summary 发布评论 --by 王鸣
|
||||
// @Description 发布短剧、短剧剧集或视频评论,parentsId为0发布一级评论,大于0发布二级评论,replyCommentId表示实际回复的评论,objectType 10-短剧 11-短剧剧集 20-视频
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.CommentSendReq true "参数列表"
|
||||
// @Success 200 {object} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/app/comment/send [post]
|
||||
func SendComment(ctx *gin.Context) {
|
||||
var in proto.CommentSendReq
|
||||
if err := ctx.ShouldBindJSON(&in); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
ip := ipaddr.ResolveClientIP(ctx)
|
||||
err := commentser.SendComment(ctx, common.GetUserId(ctx), ip, &in)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, "success")
|
||||
}
|
||||
|
||||
// List 评论列表
|
||||
// @Tags 评论APP
|
||||
// @Summary 评论列表 --by 王鸣
|
||||
// @Description 分页查询短剧、短剧剧集或视频评论树,一级评论分页返回,二级评论挂在children中,objectType 10-短剧 11-短剧剧集 20-视频
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param params query proto.GetCommentListReq true "评论列表请求"
|
||||
// @Success 200 {object} proto.GetCommentListResp{list=[]proto.CommentInfo} "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Router /api/app/comment/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var in proto.GetCommentListReq
|
||||
if err := ctx.ShouldBindQuery(&in); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, err := commentser.GetCommentPage(ctx, common.GetUserId(ctx), &in)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// SetLike 评论点赞/取消点赞
|
||||
// @Tags 评论APP
|
||||
// @Summary 评论点赞/取消点赞 --by 王鸣
|
||||
// @Description 设置当前用户对短剧、短剧剧集或视频评论的点赞状态
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.CommentLikeSetReq true "评论点赞设置请求"
|
||||
// @Success 200 {object} proto.CommentLikeSetResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/app/comment/like/set [post]
|
||||
func SetLike(ctx *gin.Context) {
|
||||
var in proto.CommentLikeSetReq
|
||||
if err := ctx.ShouldBindJSON(&in); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, err := commentser.SetCommentLike(ctx, common.GetUserId(ctx), &in)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
Reference in New Issue
Block a user