@@ -0,0 +1,138 @@
|
||||
package freevidcfgctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/freeVidmod"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 免费观看视频配置 doc
|
||||
// @Summary 免费观看配置新增
|
||||
// @Description 免费观看配置新增
|
||||
// @Tags 免费视频观看-配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param uid formData integer true "免费观看受益人"
|
||||
// @Param publisherID formData array true "可免费观看视频的发布者列表"
|
||||
// @Param startTime formData string false "免费观看开始时间"
|
||||
// @Param endTime formData string false "免费观看开始时间"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /freeVid/cfg/add [post]
|
||||
func Add(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
incr := freeVidmod.Incr{}
|
||||
if err := c.ShouldBind(&incr); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err = freeVidmod.InsertOne(&incr); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbInsertError, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(&incr)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.FreeVidConfig, constant.Add, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// 免费观看视频配置 doc
|
||||
// @Summary 免费观看配置修改
|
||||
// @Description 免费观看配置修改
|
||||
// @Tags 免费视频观看-配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param uid formData integer true "免费观看受益人"
|
||||
// @Param publisherID formData array false "可免费观看视频的发布者列表"
|
||||
// @Param startTime formData string false "免费观看开始时间"
|
||||
// @Param endTime formData string false "免费观看开始时间"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /freeVid/cfg/edit [post]
|
||||
func Edit(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
Uid uint64 `form:"uid" json:"uid" binding:"required"`
|
||||
freeVidmod.EditDoc
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if _, err = freeVidmod.Update(arg.Uid, arg.EditDoc); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(&arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.FreeVidConfig, constant.Modify, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// 免费观看视频配置 doc
|
||||
// @Summary 免费观看配置列表
|
||||
// @Description 免费观看配置列表
|
||||
// @Tags 免费视频观看-配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param uid formData integer false "免费观看受益人"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /freeVid/cfg/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
param := freeVidmod.ListParam{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "web freeVid config list arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
result, err := freeVidmod.List(param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, result)
|
||||
}
|
||||
|
||||
// 免费观看视频配置 doc
|
||||
// @Summary 免费观看配置删除
|
||||
// @Description 免费观看配置删除
|
||||
// @Tags 免费视频观看-配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param uids formData array true "用户ID数组"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /freeVid/cfg/del [delete]
|
||||
func Del(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var param struct {
|
||||
UIDs []uint64 `form:"uids" json:"uids" binding:"required"`
|
||||
}
|
||||
if err = ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if _, err = freeVidmod.Delete(param.UIDs); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(¶m)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.FreeVidConfig, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
Reference in New Issue
Block a user