117 lines
3.4 KiB
Go
117 lines
3.4 KiB
Go
package likectrl
|
|
|
|
import (
|
|
"time"
|
|
|
|
"91porn-server/app/service/likeser"
|
|
"91porn-server/common"
|
|
"91porn-server/common/log"
|
|
"91porn-server/common/stderr"
|
|
"91porn-server/models/commod"
|
|
"91porn-server/models/v/likemod"
|
|
"91porn-server/models/v/noticerecdmod"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// ThumbsUp doc
|
|
// @Summary 点赞 - 视频/评论点赞
|
|
// @Description 用户操作
|
|
// @Tags 点赞
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Param q body likemod.ReqInfo true "参数"
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /thumbsUp [post]
|
|
func ThumbsUp(ctx *gin.Context) {
|
|
uid, err := common.GetUID(ctx)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
|
return
|
|
}
|
|
param := likemod.ReqInfo{}
|
|
err = ctx.ShouldBind(¶m)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
|
return
|
|
}
|
|
|
|
code, err := likeser.ThumbsUp(ctx, uid, param.Type, param.ObjID, param.TagID)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, code, err)
|
|
return
|
|
}
|
|
common.ServeJSON(ctx, code, nil)
|
|
}
|
|
|
|
// ThumbsDown doc
|
|
// @Summary 取消点赞 - 视频/评论取消点赞
|
|
// @Description 用户操作
|
|
// @Tags 点赞
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Param q query likemod.DesLikeReq true "请求参数"
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /thumbsDown [post]
|
|
func ThumbsDown(ctx *gin.Context) {
|
|
uid, err := common.GetUID(ctx)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
|
return
|
|
}
|
|
param := likemod.DesLikeReq{}
|
|
err = ctx.ShouldBind(¶m)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
|
return
|
|
}
|
|
|
|
code, err := likeser.ThumbsDown(ctx, uid, param.Type, param.ObjIDs...)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, code, err)
|
|
return
|
|
}
|
|
common.ServeJSON(ctx, code, nil)
|
|
}
|
|
|
|
// Record doc
|
|
// @Summary 被赞列表
|
|
// @Description 被赞列表
|
|
// @Tags 点赞
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Param pageNumber query integer true "当前页" mininum(1)
|
|
// @Param pageSize query integer true "每页条数" mininum(1)
|
|
// @Success 200 {object} likeser.RecordPage "{"hasNext": true,"list":[]}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /api/app/like/record/list [get]
|
|
func RecordList(c *gin.Context) {
|
|
var arg struct {
|
|
commod.Page
|
|
}
|
|
if err := c.ShouldBind(&arg); err != nil {
|
|
common.ServeJSON(c, stderr.ErrParamError, "likectrl RecordList arg error "+err.Error())
|
|
return
|
|
}
|
|
// 检查uid是否存在
|
|
uid, err := common.GetUID(c)
|
|
if err != nil {
|
|
common.ServeJSON(c, stderr.UserIsNotExists, "likectrl RecordList Context USER_ID is not exist ")
|
|
return
|
|
}
|
|
skip := (arg.PageNumber - 1) * arg.PageSize
|
|
limit := arg.PageSize
|
|
recordPage, err := likeser.RecordPages(uid, int64(skip), int64(limit))
|
|
if err != nil {
|
|
common.ServeJSON(c, stderr.Failure, err)
|
|
return
|
|
}
|
|
err = noticerecdmod.UpdateTrendReadTime(noticerecdmod.Like, uid, time.Now())
|
|
if err != nil {
|
|
log.Error("likectrl RecordList UpdateTrendReadTime faild", log.E(err))
|
|
}
|
|
common.ServeJSON(c, stderr.Success, recordPage)
|
|
}
|