@@ -0,0 +1,82 @@
|
||||
package minectrl
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/reptmod"
|
||||
"91porn-server/models/v/repttypemod"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// Report doc
|
||||
// @Summary 举报 - 用户举报
|
||||
// @Description 用户操作
|
||||
// @Tags mine
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param uid query integer true "举报者uid"
|
||||
// @Param objType query string true "举报对象类型,video、comment、user"
|
||||
// @Param types query string true "类型:内容违规/账号违规/侵权/其他"
|
||||
// @Param objID query string false "举报对象ID,videoID、commentId"
|
||||
// @Param objUID query integer false "被举报用户UID"
|
||||
// @Success 200 {string} json "{"msg": {"hasReported":true}} 已经举报则hasReported为true,提示用户已经举报"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /mine/report [post]
|
||||
func Report(ctx *gin.Context) {
|
||||
var arg struct {
|
||||
UID uint64 `form:"uid" json:"uid" binding:"required"`
|
||||
ObjType reptmod.ReportObjType `form:"objType" json:"objType" binding:"required"`
|
||||
Types string `form:"types" json:"types" binding:"required"`
|
||||
ObjID *primitive.ObjectID `form:"objID" json:"objID" binding:""`
|
||||
ObjUID *uint64 `form:"objUID" json:"objUID" binding:""`
|
||||
}
|
||||
if err := ctx.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "mine Report arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
if arg.ObjType == reptmod.User && arg.ObjUID == nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "mine Report arg error: no objUID ")
|
||||
return
|
||||
}
|
||||
if arg.ObjType != reptmod.User && arg.ObjID == nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "mine Report arg error: no objID ")
|
||||
return
|
||||
}
|
||||
//举报有效期一个月
|
||||
ok, err := reptmod.Do(arg.UID, arg.ObjType, arg.ObjID, arg.ObjUID, arg.Types, time.Hour*24*30)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrNetWorkBusy, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{
|
||||
"hasReported": ok,
|
||||
})
|
||||
}
|
||||
|
||||
// Report doc
|
||||
// @Summary 举报 - 举报种类
|
||||
// @Description 举报种类
|
||||
// @Tags mine
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": []}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /mine/report/types/list [get]
|
||||
func ReportTypesList(c *gin.Context) {
|
||||
list, err := repttypemod.List()
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrNetWorkBusy, "mine ReportTypesList error: "+err.Error())
|
||||
return
|
||||
}
|
||||
typesList := make([]string, 0, len(list))
|
||||
for _, report := range list {
|
||||
if report.Name != nil {
|
||||
typesList = append(typesList, *report.Name)
|
||||
}
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, typesList)
|
||||
}
|
||||
Reference in New Issue
Block a user