@@ -0,0 +1,52 @@
|
||||
package acth5ctrl
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/models/l/lotterylgmod"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 中奖号列表
|
||||
// @Description 中奖号列表
|
||||
// @Tags web-活动
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param pageNumber formData integer true "当前页"
|
||||
// @Param pageSize formData integer true "每页条数"
|
||||
// @Param title formData string false "过滤项-标题"
|
||||
// @Param actId formData string false "过滤项-活动ID"
|
||||
// @Param enable formData bool false "过滤项-活动开关"
|
||||
// @Param status formData string false "过滤项-活动状态"
|
||||
// @Param startTime formData string false "过滤项-活动开始时间"
|
||||
// @Param endTime formData string false "过滤项-活动结束时间"
|
||||
// @Success 200 {string} user "{"msg": "操作成功", "date": { "total":10, "list":[] }}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/lottnum/list [get]
|
||||
func List(c *gin.Context) {
|
||||
var arg struct {
|
||||
Start *time.Time `form:"start" json:"start"`
|
||||
End *time.Time `form:"end" json:"end"`
|
||||
UID *uint64 `form:"uid" json:"uid"`
|
||||
Code *int `form:"code" json:"code"`
|
||||
commod.Page
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "web lottnum list arg error"+err.Error())
|
||||
return
|
||||
}
|
||||
info, total, err := lotterylgmod.LottnumList(arg.PageNumber, arg.PageSize, arg.Start, arg.End, arg.UID, arg.Code)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, gin.H{
|
||||
"list": info,
|
||||
"total": total,
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package activityctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/activitymod"
|
||||
"91porn-server/web/service/activityser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 新增
|
||||
func Add(c *gin.Context) {
|
||||
var in activitymod.AddCond
|
||||
if err := c.ShouldBind(&in); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "web activity Add arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
code := activityser.Add(in)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, code, "success")
|
||||
}
|
||||
|
||||
// 修改
|
||||
func Modify(c *gin.Context) {
|
||||
var in *activitymod.ModifyCond
|
||||
if err := c.ShouldBind(&in); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "web activity Modify arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
code := activityser.Modify(in)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, code, "success")
|
||||
}
|
||||
|
||||
// 查询
|
||||
func QueryAll(c *gin.Context) {
|
||||
var in *activitymod.QueryAllCond
|
||||
if err := c.ShouldBindQuery(&in); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "web activity QueryAll arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
data, code := activityser.QueryAll(in)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, code, data)
|
||||
}
|
||||
|
||||
func QueryDropDownBox(c *gin.Context) {
|
||||
data, code := activityser.QueryDropDownBox()
|
||||
common.ServeJSON(c, code, data)
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package activityctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/prizemod"
|
||||
"91porn-server/web/service/activityser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 新增
|
||||
func AddPrize(c *gin.Context) {
|
||||
var in prizemod.AddPrizeCond
|
||||
if err := c.ShouldBind(&in); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "web activity Add arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
code := activityser.AddPrize(in)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, code, "success")
|
||||
}
|
||||
|
||||
// 修改
|
||||
func ModifyPrize(c *gin.Context) {
|
||||
var in *prizemod.ModifyPrizeCond
|
||||
if err := c.ShouldBind(&in); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "web activity Modify arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
code := activityser.ModifyPrize(in)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, code, "success")
|
||||
}
|
||||
|
||||
// 查询
|
||||
func QueryAllPrize(c *gin.Context) {
|
||||
var in *prizemod.QueryAllPrizeCond
|
||||
if err := c.ShouldBindQuery(&in); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "web activity QueryAll arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
data, code := activityser.QueryAllPrize(in)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, code, data)
|
||||
}
|
||||
|
||||
func QueryVipDropDownBox(c *gin.Context) {
|
||||
data, code := activityser.QueryVipDropDownBox()
|
||||
common.ServeJSON(c, code, data)
|
||||
}
|
||||
|
||||
func QueryPrizeDropDownBox(c *gin.Context) {
|
||||
data, code := activityser.QueryPrizeDropDownBox()
|
||||
common.ServeJSON(c, code, data)
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package activityctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/activitymod"
|
||||
"91porn-server/web/service/activityser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 新增
|
||||
func AddPrizePool(c *gin.Context) {
|
||||
var in activitymod.AddPrizePoolCond
|
||||
if err := c.ShouldBind(&in); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "web prizePool Add arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
code := activityser.AddPrizePool(in)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, code, "success")
|
||||
}
|
||||
|
||||
// 修改
|
||||
func ModifyPrizePool(c *gin.Context) {
|
||||
var in *activitymod.ModifyPrizePoolCond
|
||||
if err := c.ShouldBind(&in); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "web prizePool Modify arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
code := activityser.ModifyPrizePool(in)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, code, "success")
|
||||
}
|
||||
|
||||
// 查询
|
||||
func QueryAllPrizePool(c *gin.Context) {
|
||||
var in *activitymod.QueryAllPrizePoolCond
|
||||
if err := c.ShouldBindQuery(&in); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "web prizePool QueryAll arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
data, code := activityser.QueryAllPrizePool(in)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, code, data)
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package activityctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/activitymod"
|
||||
"91porn-server/web/service/activityser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func QueryAllRecord(c *gin.Context) {
|
||||
var in *activitymod.QueryAllRecordCond
|
||||
if err := c.ShouldBindQuery(&in); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "web activity QueryAllRecord arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
data, code := activityser.QueryAllRecord(in)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, code, data)
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package actvctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/web/service/actvser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetActivities(c *gin.Context) {
|
||||
var r actvser.GetActitiesRequest
|
||||
if err := c.Bind(&r); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
count, activities, hasNext, err := actvser.GetActities(r)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, gin.H{
|
||||
"total": count,
|
||||
"list": activities,
|
||||
"hasNext": hasNext,
|
||||
})
|
||||
}
|
||||
|
||||
func UpdateActivity(c *gin.Context) {
|
||||
var r actvser.UpdateActivityRequest
|
||||
if err := c.Bind(&r); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if r.ActvID.IsZero() {
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if err := actvser.UpdateActivity(r); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, nil)
|
||||
}
|
||||
|
||||
func AddActivity(c *gin.Context) {
|
||||
var r actvser.AddActivityRequest
|
||||
if err := c.Bind(&r); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if err := actvser.AddActivity(r); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, nil)
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package addwlefarectrl
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/daichong"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/web/service/addwelfareser"
|
||||
"91porn-server/web/webg"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func AddWelfare(ctx *gin.Context) {
|
||||
var args struct {
|
||||
AppID string `form:"appId" json:"appId" binding:"required"`
|
||||
Data string `form:"data" json:"data" binding:"required"`
|
||||
}
|
||||
if err := ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "web activity List arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
if args.AppID != webg.Conf.Welfare.AppID {
|
||||
ctx.JSON(http.StatusOK, gin.H{"data": nil, "code": stderr.ErrAppIDNotExist, "msg": stderr.ErrAppIDNotExist.Msg()})
|
||||
return
|
||||
}
|
||||
var sign = struct {
|
||||
Time string `json:"time"`
|
||||
Uid string `json:"uid"`
|
||||
}{}
|
||||
if err := daichong.Sign2Struct(&sign, args.Data, webg.Conf.Welfare.AppSecret); err != nil {
|
||||
log.Warn("AddWelfare callback sign data fail error", log.E(err))
|
||||
ctx.JSON(http.StatusOK, gin.H{"data": nil, "code": stderr.Failure, "msg": stderr.Failure.Msg()})
|
||||
return
|
||||
}
|
||||
code, err := addwelfareser.AddWelfare(sign.Uid)
|
||||
common.ServeJSON(ctx, code, err)
|
||||
}
|
||||
@@ -0,0 +1,524 @@
|
||||
package adminctrl
|
||||
|
||||
import (
|
||||
"encoding/base32"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/googauth"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/adminmod"
|
||||
"91porn-server/models/v/authoritymod"
|
||||
"91porn-server/web/middleware/authweb"
|
||||
"91porn-server/web/service/adminser"
|
||||
"91porn-server/web/service/authorser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skip2/go-qrcode"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
// Login doc
|
||||
// @Summary 登陆 - 管理员登陆
|
||||
// @Description 管理员登陆
|
||||
// @Tags web-登陆
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param name formData string true "账号"
|
||||
// @Param password formData string true "密码"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/login [post]
|
||||
func Login(c *gin.Context) {
|
||||
var arg struct {
|
||||
Name string `form:"name" json:"name" binding:"required"`
|
||||
Password string `form:"password" json:"password" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "admin Login arg error: "+err.Error())
|
||||
return
|
||||
}
|
||||
adm, err := adminmod.FindOneByName(arg.Name)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, "admin Login FindOne error: "+err.Error())
|
||||
return
|
||||
}
|
||||
if adm.Name == "" {
|
||||
common.ServeJSON(c, stderr.AdminIsNotExist, "Login admin is not exist")
|
||||
return
|
||||
}
|
||||
//校验密码
|
||||
if err = bcrypt.CompareHashAndPassword([]byte(adm.Password), []byte(arg.Password)); err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIsNotExist, "Login admin password error")
|
||||
return
|
||||
}
|
||||
if adm.HasLocked {
|
||||
common.ServeJSON(c, stderr.AdminIsHasLockedErr, "Login admin haslocked")
|
||||
return
|
||||
}
|
||||
var qrCodePNG []byte
|
||||
if !adm.HasBind {
|
||||
url := googauth.New(adm.Secret, adm.Name+"@91porn")
|
||||
qrCodePNG, err = qrcode.Encode(url, qrcode.Medium, 256)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIsNotExist, "Login GetQRCodePNG error: "+err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, gin.H{
|
||||
"qrCodePNG": qrCodePNG,
|
||||
})
|
||||
}
|
||||
|
||||
// SLogin doc
|
||||
// @Summary 管理员sso登陆
|
||||
// @Description 管理员sso登陆
|
||||
// @Tags web-单点登陆
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param name formData string true "账号"
|
||||
// @Param password formData string true "密码"
|
||||
// @Success 200 {string} json "{"msg": "管理员信息""}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/slogin [post]
|
||||
func SLogin(c *gin.Context) {
|
||||
var arg struct {
|
||||
Name string `form:"name" json:"name" binding:"required"`
|
||||
Password string `form:"password" json:"password" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "admin SLogin arg error: "+err.Error())
|
||||
return
|
||||
}
|
||||
adm, err := adminmod.FindOneByName(arg.Name)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, "admin SLogin FindOne error: "+err.Error())
|
||||
return
|
||||
}
|
||||
if adm.Name == "" {
|
||||
common.ServeJSON(c, stderr.AdminIsNotExist, "SLogin admin is not exist")
|
||||
return
|
||||
}
|
||||
//校验密码
|
||||
if err = bcrypt.CompareHashAndPassword([]byte(adm.Password), []byte(arg.Password)); err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIsNotExist, "Login admin password error")
|
||||
return
|
||||
}
|
||||
if adm.HasLocked {
|
||||
common.ServeJSON(c, stderr.AdminIsHasLockedErr, "SLogin admin haslocked")
|
||||
return
|
||||
}
|
||||
// SLogin 仅允许角色名包含"客服"的账号登录,其余角色一律拒绝
|
||||
if !strings.Contains(adm.Role, "客服") {
|
||||
common.ServeJSON(c, stderr.ErrAccessForbid, "SLogin 仅限客服角色登录")
|
||||
return
|
||||
}
|
||||
var cid string
|
||||
token, err := authweb.GenAndSaveToken(&authweb.Claims{Type: authweb.Admin, Act: adm.Name, Role: adm.Role, CID: cid})
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, "SLogin admin GenerateToken error: "+err.Error())
|
||||
return
|
||||
}
|
||||
_ = adminmod.Bind(arg.Name)
|
||||
authJSON, _ := authoritymod.FineOneByRole(adm.Role)
|
||||
common.ServeJSON(c, stderr.Success, gin.H{
|
||||
"token": token,
|
||||
"authJson": authJSON.AuthJson,
|
||||
"actJson": authJSON.ActJson,
|
||||
"admin": adminmod.AdminDoc{
|
||||
ID: &adm.ID,
|
||||
Name: &adm.Name,
|
||||
Role: &adm.Role,
|
||||
Nickname: &adm.Nickname,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// Verify doc
|
||||
// @Summary 管理员二步验证
|
||||
// @Description 管理员二步验证
|
||||
// @Tags web-登陆
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param name formData string true "账号"
|
||||
// @Param otp formData string true "动态口令"
|
||||
// @Success 200 {string} json "{"msg": "管理员信息""}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/verify [post]
|
||||
func Verify(c *gin.Context) {
|
||||
var arg struct {
|
||||
Name string `form:"name" json:"name" binding:"required"`
|
||||
Otp string `form:"otp" json:"otp" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "admin Verification arg error: "+err.Error())
|
||||
return
|
||||
}
|
||||
adm, err := adminmod.FindOneByName(arg.Name)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, "admin Verification FindOne error: "+err.Error())
|
||||
return
|
||||
}
|
||||
if adm.Name == "" {
|
||||
log.Error(fmt.Sprintf("用户[%v]不存在", arg.Name))
|
||||
common.ServeJSON(c, stderr.ErrAccessForbid, "admin is not exist")
|
||||
return
|
||||
}
|
||||
//测试模式不使用两步验证
|
||||
if gin.Mode() != gin.DebugMode {
|
||||
ok, err := googauth.Verify(adm.Secret, arg.Otp)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.GoogleAuthFail, "admin Verification 2-step error: "+err.Error())
|
||||
return
|
||||
}
|
||||
if !ok {
|
||||
common.ServeJSON(c, stderr.GoogleAuthFail, "admin Verification 2-step verification faild")
|
||||
return
|
||||
}
|
||||
}
|
||||
var cid string
|
||||
if adm.Role == "裸聊商家" {
|
||||
common.ServeJSON(c, stderr.GoogleAuthFail, "role faild")
|
||||
return
|
||||
}
|
||||
token, err := authweb.GenAndSaveToken(&authweb.Claims{Type: authweb.Admin, Act: adm.Name, Role: adm.Role, CID: cid})
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, "admin GenerateToken error: "+err.Error())
|
||||
return
|
||||
}
|
||||
_ = adminmod.Bind(arg.Name)
|
||||
authJSON, _ := authoritymod.FineOneByRole(adm.Role)
|
||||
common.ServeJSON(c, stderr.Success, gin.H{
|
||||
"token": token,
|
||||
"authJson": authJSON.AuthJson,
|
||||
"actJson": authJSON.ActJson,
|
||||
"admin": adminmod.AdminDoc{
|
||||
ID: &adm.ID,
|
||||
Name: &adm.Name,
|
||||
Role: &adm.Role,
|
||||
Nickname: &adm.Nickname,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// Logout doc
|
||||
// @Summary 注销 - 管理员注销
|
||||
// @Description 管理员登陆
|
||||
// @Tags web-登陆
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param name formData string true "账号"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/logout [post]
|
||||
func Logout(c *gin.Context) {
|
||||
if name, err := common.GetAdminAct(c); err == nil {
|
||||
authweb.RevokeAdminToken(name)
|
||||
} else {
|
||||
log.Error("admin logout error", log.E(err))
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Logout doc
|
||||
// @Summary 刷新token
|
||||
// @Description 刷新token
|
||||
// @Tags web-登陆
|
||||
// @Accept json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"token": "token1"}"
|
||||
// @Router /web/admin/refresh [post]
|
||||
func Refresh(c *gin.Context) {
|
||||
name, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err)
|
||||
return
|
||||
}
|
||||
cid, err := common.GetJuShangID(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err)
|
||||
return
|
||||
}
|
||||
role, err := common.GetAdminRole(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err)
|
||||
return
|
||||
}
|
||||
token, err := authweb.GenAndSaveToken(&authweb.Claims{Type: authweb.Admin, Act: name, Role: role, CID: cid})
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminRefreshTokenErr, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, gin.H{"token": token})
|
||||
}
|
||||
|
||||
// Add doc
|
||||
// @Summary 登陆 - 添加管理员
|
||||
// @Description 添加管理员
|
||||
// @Tags web-admin
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param name formData string true "账号"
|
||||
// @Param password formData string true "密码"
|
||||
// @Param nickname formData string false "昵称"
|
||||
// @Param email formData string false "邮箱"
|
||||
// @Param privilegeID formData string false "权限ID"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/add [post]
|
||||
func Add(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
Name string `form:"name" json:"name" binding:"required"`
|
||||
Password string `form:"password" json:"password" binding:"required"`
|
||||
Nickname *string `form:"nickname" json:"nickname" binding:""` //昵称
|
||||
Email *string `form:"email" json:"email" binding:"omitempty,email"` //邮箱
|
||||
PrivilegeID *primitive.ObjectID `form:"privilegeID" json:"privilegeID" binding:""`
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, fmt.Errorf("auth Add arg error: %+v", err))
|
||||
return
|
||||
}
|
||||
existed, err := adminmod.ExistsByName(arg.Name)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, fmt.Errorf("auth Add Exists error: %+v", err))
|
||||
return
|
||||
}
|
||||
if existed {
|
||||
common.ServeJSON(c, stderr.AdminIsExisted, fmt.Errorf("auth Add admin is existed"))
|
||||
return
|
||||
}
|
||||
var role *string
|
||||
if arg.PrivilegeID != nil {
|
||||
auth, err := authoritymod.FindOne(authoritymod.AuthorityDoc{ID: *arg.PrivilegeID})
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, fmt.Errorf("auth FindOne error: %+v", err))
|
||||
return
|
||||
}
|
||||
if auth.ID.IsZero() {
|
||||
common.ServeJSON(c, stderr.AuthIsNotExist, gin.H{"privilegeID": arg.PrivilegeID})
|
||||
return
|
||||
}
|
||||
role = &auth.Role
|
||||
}
|
||||
//生成密码
|
||||
hashPwd, _ := bcrypt.GenerateFromPassword([]byte(arg.Password), bcrypt.DefaultCost)
|
||||
hashPwdStr := string(hashPwd)
|
||||
secret := base32.StdEncoding.EncodeToString([]byte(fmt.Sprintf("admin%s", common.RandStr(10))))
|
||||
hasBind := false
|
||||
if err = adminmod.Insert(nil, adminmod.AdminDoc{
|
||||
Name: &arg.Name,
|
||||
Password: &hashPwdStr,
|
||||
Secret: &secret,
|
||||
HasBind: &hasBind,
|
||||
Nickname: arg.Nickname,
|
||||
Email: arg.Email,
|
||||
Role: role,
|
||||
}); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbInsertError, fmt.Errorf("auth Add Admin.Insert error: %+v", err))
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Administrator, constant.Add, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
|
||||
// List doc
|
||||
// @Summary 获取管理员列表
|
||||
// @Description 获取管理员列表
|
||||
// @Tags web-admin
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param pageNumber query int true "当前页"
|
||||
// @Param pageSize query int true "每页条数"
|
||||
// @Param name query string false "过滤条件-管理员账号"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "date": { "total":10, "list":[] }}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/list [get]
|
||||
func List(c *gin.Context) {
|
||||
type Query struct {
|
||||
Name *string `form:"name" json:"name" bson:",omitempty"` //用户名
|
||||
}
|
||||
var arg struct {
|
||||
commod.Page
|
||||
Query
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "admin List arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
skip := int64((arg.PageNumber - 1) * arg.PageSize)
|
||||
limit := int64(arg.PageSize)
|
||||
page, err := adminser.AdminPages(skip, limit, arg.Name)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, "admin List.AdminPages error: "+err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, page)
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 登陆 - 删除管理员
|
||||
// @Description 删除管理员
|
||||
// @Tags web-admin
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param adminID formData string true "目标管理员ID"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/del [delete]
|
||||
func Delete(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
AdminID string `form:"adminID" json:"adminID,omitempty" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "author Delete arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
adminID, err := primitive.ObjectIDFromHex(arg.AdminID)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
// 删除前查询账号名,用于清除token
|
||||
adm, _ := adminmod.FindOneByID(adminID)
|
||||
if err := adminmod.Delete(adminmod.AdminDoc{ID: &adminID}); err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIsNotExist, "author Delete error "+err.Error())
|
||||
return
|
||||
}
|
||||
// 清除已删除账号的token
|
||||
if adm.Name != "" {
|
||||
authweb.RevokeAdminToken(adm.Name)
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Administrator, constant.Delete, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 登陆 - 修改管理员
|
||||
// @Description 修改管理员
|
||||
// @Tags web-admin
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param adminID formData string true "目标管理员ID"
|
||||
// @Param nickname formData string false "昵称"
|
||||
// @Param email formData string false "邮箱"
|
||||
// @Param privilegeID formData string false "权限ID, "": 删除权限"
|
||||
// @Param password formData string false "密码"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/update [post]
|
||||
func Update(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
AdminID string `form:"adminID" json:"adminID" binding:"required"`
|
||||
Nickname *string `form:"nickname" json:"nickname" binding:""` //昵称
|
||||
Email *string `form:"email" json:"email" binding:"omitempty,email"` //邮箱
|
||||
PrivilegeID *primitive.ObjectID `form:"privilegeID" json:"privilegeID" binding:""`
|
||||
Password *string `form:"password" json:"password" binding:""`
|
||||
HasLocked *bool `json:"hasLocked,omitempty" form:"hasLocked"` //已禁止登陆
|
||||
LockReason *string `json:"lockReason,omitempty" form:"lockReason"` //禁止登陆的原因
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "author Update arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
adminID, err := primitive.ObjectIDFromHex(arg.AdminID)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if arg.PrivilegeID != nil {
|
||||
if err := authorser.SetAuthority(adminID, *arg.PrivilegeID); err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, "auth SetAuthority error: "+err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
doc := adminmod.AdminDoc{
|
||||
Nickname: arg.Nickname,
|
||||
Email: arg.Email,
|
||||
HasLocked: arg.HasLocked,
|
||||
LockReason: arg.LockReason,
|
||||
}
|
||||
//更新密码
|
||||
if arg.Password != nil {
|
||||
hashPwd, _ := bcrypt.GenerateFromPassword([]byte(*arg.Password), bcrypt.DefaultCost)
|
||||
hashPwdStr := string(hashPwd)
|
||||
doc.Password = &hashPwdStr
|
||||
}
|
||||
if err := adminmod.UpdateByID(adminID, doc); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbUpdateError, "author UpdateByID error "+err.Error())
|
||||
return
|
||||
}
|
||||
// 禁用账号时清除token,使其立即失效
|
||||
if arg.HasLocked != nil && *arg.HasLocked {
|
||||
adm, _ := adminmod.FindOneByID(adminID)
|
||||
if adm.Name != "" {
|
||||
authweb.RevokeAdminToken(adm.Name)
|
||||
}
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Administrator, constant.Modify, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
|
||||
// RefreshToken doc
|
||||
// @Summary token刷新
|
||||
// @Description token刷新
|
||||
// @Tags web-登陆
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param name formData string true "账号"
|
||||
// @Param password formData string true "密码"
|
||||
// @Param otp formData string true "动态口令"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/channel/user/refresh [get]
|
||||
func RefreshToken(c *gin.Context) {
|
||||
account, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err)
|
||||
return
|
||||
}
|
||||
role, err := common.GetAdminRole(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err)
|
||||
return
|
||||
}
|
||||
cid, err := common.GetJuShangID(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err)
|
||||
return
|
||||
}
|
||||
token, err := authweb.GenAndSaveToken(&authweb.Claims{Type: authweb.Admin, Act: account, Role: role, CID: cid})
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrUnrecognized, "generator token error!")
|
||||
return
|
||||
}
|
||||
c.Writer.Header().Set("Refresh-Authorization", "false")
|
||||
type RefreshTokenResp struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, RefreshTokenResp{Token: token})
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
package adsctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/common/ysurl"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/adreviewmod"
|
||||
"91porn-server/models/v/adsmod"
|
||||
"91porn-server/web/service/adser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 广告列表
|
||||
// @Description 广告列表
|
||||
// @Tags ads
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData string true "id"
|
||||
// @Param position formData integer true "广告位置"
|
||||
// @Param pageNumber formData integer true "查询页码"
|
||||
// @Param pageSize formData integer true "页码大小"
|
||||
// @Param sort formData string true "排序的字段"
|
||||
// @Param desc formData integer true "1 正序 -1倒序"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ads/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
type Query struct {
|
||||
ID *string `form:"id" json:"id"` //id
|
||||
AdsType *adsmod.AdsType `form:"adsType" json:"adsType"` //广告类型
|
||||
Position *adsmod.AdPosition `form:"position" json:"position"` //广告位置
|
||||
DiscCode *string `form:"discCode" json:"discCode"` //商区码
|
||||
}
|
||||
var args struct {
|
||||
commod.Page
|
||||
Query
|
||||
}
|
||||
if err := ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "adsctrl List arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
skip := int64((args.PageNumber - 1) * args.PageSize)
|
||||
limit := int64(args.PageSize)
|
||||
var id *primitive.ObjectID
|
||||
if args.ID != nil {
|
||||
i, err := primitive.ObjectIDFromHex(*args.ID)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "adsctrl List arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
id = &i
|
||||
}
|
||||
page, err := adser.AdPages(skip, limit,
|
||||
adsmod.IDMatch{ID: id},
|
||||
adsmod.AdsTypeMatch{AdsType: args.AdsType},
|
||||
adsmod.AdPositionMatch{Position: args.Position},
|
||||
adsmod.DistrictCodeMatch{DistrictCode: args.DiscCode},
|
||||
)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, "adsctrl AdPages error: "+err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, page)
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新广告信息
|
||||
// @Description 更新广告信息
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData string true "ID"
|
||||
// @Param title formData string false "广告标题"
|
||||
// @Param cover formData string false "广告封面图"
|
||||
// @Param sortCode formData integer false "排序号"
|
||||
// @Param type formData integer false "广告类型"
|
||||
// @Param href formData string false "广告跳转地址"
|
||||
// @Param position formData integer false "广告位置"
|
||||
// @Param active formData boolean false "激活状态"
|
||||
// @Param remark formData string false "备注"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ads/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
type Update struct {
|
||||
Title *string `form:"title" json:"title" binding:""` //广告标题
|
||||
Cover *string `form:"cover" json:"cover" binding:"required_with=Position"` //广告封面图
|
||||
HrefType *adsmod.URLJumpType `form:"hrefType" json:"hrefType" binding:"required_with=Href"` //广告类型
|
||||
Href *string `form:"href" json:"href" binding:"required_with=HrefType"` //广告跳转地址
|
||||
Position *adsmod.AdPosition `form:"position" json:"position" binding:"required_with=Cover"` //广告位置
|
||||
SortCode *int `form:"sortCode" json:"sortCode" binding:""` //排序号
|
||||
Active *bool `form:"active" json:"active" binding:""` //激活状态
|
||||
Remark *string `form:"remark" json:"remark" binding:""` //备注
|
||||
Start *time.Time `form:"start" json:"start" binding:""` //开始时间
|
||||
End *time.Time `form:"end" json:"end" binding:""` //结束时间
|
||||
}
|
||||
var args struct {
|
||||
ID primitive.ObjectID `form:"id" json:"id" binding:"required"`
|
||||
Update
|
||||
}
|
||||
if err := ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "adsctrl Update arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
if args.HrefType != nil && args.Href != nil {
|
||||
if *args.Href != "" && !ysurl.IsValidURL(*args.HrefType, *args.Href) {
|
||||
common.ServeJSON(ctx, stderr.URLInvalid, "")
|
||||
return
|
||||
}
|
||||
}
|
||||
doc := adsmod.UpdateDoc{
|
||||
Title: args.Title,
|
||||
Cover: args.Cover,
|
||||
HrefType: args.HrefType,
|
||||
Href: args.Href,
|
||||
Position: args.Position,
|
||||
SortCode: args.SortCode,
|
||||
Active: args.Active,
|
||||
Remark: args.Remark,
|
||||
Start: args.Start,
|
||||
End: args.End,
|
||||
}
|
||||
if doc.Cover != nil {
|
||||
prop := common.GetPictureProp(common.ImgUrlHost + *doc.Cover)
|
||||
doc.CoverProp = prop
|
||||
}
|
||||
if err = adsmod.UpdateOneByID(nil, args.ID, doc); err != nil {
|
||||
switch err.(type) {
|
||||
case adsmod.ADSNotExistError:
|
||||
common.ServeJSON(ctx, stderr.ADSNotExist, err.Error())
|
||||
default:
|
||||
log.Error("adsctrl Update failed", log.E(err))
|
||||
common.ServeJSON(ctx, stderr.Failure, fmt.Errorf("adsctrl Update error: %+v", err))
|
||||
}
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(args)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AdsManageAdsList, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除广告
|
||||
// @Description 删除广告
|
||||
// @Tags follow
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ids formData array true "广告id数组"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ads/del [delete]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var args struct {
|
||||
ID primitive.ObjectID `form:"id" json:"id" binding:"required"`
|
||||
ArID *primitive.ObjectID `form:"arID" json:"arID" binding:""`
|
||||
}
|
||||
if err = ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "adsctrl Delete arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
if err = adser.DeleteAd(&args.ID, args.ArID); err != nil {
|
||||
switch err.(type) {
|
||||
case adreviewmod.ADReviewNotExistError:
|
||||
common.ServeJSON(ctx, stderr.ADReviewNotExist, err.Error())
|
||||
case adsmod.ADSNotExistError:
|
||||
common.ServeJSON(ctx, stderr.ADSNotExist, err.Error())
|
||||
default:
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(args)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AdsManageAdsList, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// AddSysAds doc
|
||||
// @Summary 增加一条广告
|
||||
// @Description 增加一条广告
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param title formData string false "广告标题"
|
||||
// @Param cover formData string false "广告封面图"
|
||||
// @Param sortCode formData integer false "排序号"
|
||||
// @Param type formData integer false "广告类型"
|
||||
// @Param href formData string false "广告跳转地址"
|
||||
// @Param position formData integer false "广告位置"
|
||||
// @Param active formData bool false "激活状态"
|
||||
// @Param remark formData string false "备注"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ads/add [post]
|
||||
func Add(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var args struct {
|
||||
Title string `form:"title" json:"title" binding:"required"` //广告标题
|
||||
Cover string `form:"cover" json:"cover" binding:"required"` //广告封面图
|
||||
HrefType *adsmod.URLJumpType `form:"hrefType" json:"hrefType" binding:"required"` //广告跳转类型,
|
||||
Href *string `form:"href" json:"href" binding:"required"` //广告跳转地址
|
||||
Position *adsmod.AdPosition `form:"position" json:"position" binding:"required"` //广告位置
|
||||
Active *bool `form:"active" json:"active" binding:"required"` //激活状态
|
||||
SortCode *int `form:"sortCode" json:"sortCode" binding:"required"` //排序号
|
||||
Remark string `form:"remark" json:"remark" binding:""` //备注
|
||||
Start *time.Time `form:"start" json:"start" binding:""` //开始时间
|
||||
End *time.Time `form:"end" json:"end" binding:""` //结束时间
|
||||
}
|
||||
if err = ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if *args.Href != "" && !ysurl.IsValidURL(*args.HrefType, *args.Href) {
|
||||
common.ServeJSON(ctx, stderr.URLInvalid, "")
|
||||
return
|
||||
}
|
||||
doc := adsmod.InsertDoc{
|
||||
AdsType: adsmod.SysAds,
|
||||
Cover: args.Cover,
|
||||
Title: args.Title,
|
||||
HrefType: *args.HrefType,
|
||||
Href: *args.Href,
|
||||
Position: *args.Position,
|
||||
SortCode: *args.SortCode,
|
||||
Active: *args.Active,
|
||||
Remark: args.Remark,
|
||||
Start: *args.Start,
|
||||
End: *args.End,
|
||||
}
|
||||
prop := common.GetPictureProp(common.ImgUrlHost + doc.Cover)
|
||||
doc.CoverProp = prop
|
||||
if _, err = adsmod.InsertOne(nil, doc); err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, fmt.Errorf("adsctrl Add error: %+v", err))
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(args)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AdsManageAdsList, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package adv_group_ctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/web/service/advgroupser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 广告AB测试
|
||||
// @Summary 查询广告统计数据
|
||||
// @Description 查询广告统计数据
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body advgroupser.AdGroupStatReq true "参数列表"
|
||||
// @Success 200 {object} advgroupser.QueryRes "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Router /api/web/admin/adgroup/list [POST]
|
||||
func GetAdGroupStatList(ctx *gin.Context) {
|
||||
var req = &advgroupser.AdGroupStatReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, serr := advgroupser.GetAdGroupStatList(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package advance_config_ctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/advanceconfigmod"
|
||||
"91porn-server/web/service/advance_config_ser"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// QueryAll doc
|
||||
// @Summary 查询预售配置列表
|
||||
// @Description 查询预售配置列表
|
||||
// @Tags 后台-预售配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData primitive.ObjectID true "文档id"
|
||||
// @Param status formData integer true "预售订单状态"
|
||||
// @Param oid formData string true "支付平台订单号"
|
||||
// @Param uid formData integer true "用户ID"
|
||||
// @Param pageNumber formData integer true "查询页码"
|
||||
// @Param pageSize formData integer true "页码大小"
|
||||
// @Success 200 {object} advanceconfigmod.QueryAllRes
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/advance_config/list [get]
|
||||
func QueryAll(c *gin.Context) {
|
||||
var in advanceconfigmod.QueryAllCond
|
||||
if err := c.ShouldBindQuery(&in); err != nil {
|
||||
log.Error(fmt.Sprintf("Query all advance_config param err:%v", err))
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
data, err := advance_config_ser.QueryAll(&in)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Query all advance_config err:%v\n%d", data, err))
|
||||
common.ServeJSON(c, stderr.Failure, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, data)
|
||||
}
|
||||
|
||||
// Create doc
|
||||
// @Summary 新增预售配置
|
||||
// @Description 新增预售配置
|
||||
// @Tags 后台-预售配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query advanceconfigmod.WebCreateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/advance_config/create [post]
|
||||
func Create(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &advanceconfigmod.WebCreateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Create advance_config param err:%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 创建
|
||||
err = advance_config_ser.Create(p, manager)
|
||||
if err != stderr.Success {
|
||||
log.Error(fmt.Sprintf("Create advance_config err:%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AdvanceConfig, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新预售配置
|
||||
// @Description 更新预售配置
|
||||
// @Tags 后台-预售配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query advanceconfigmod.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/advance_config/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &advanceconfigmod.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Update all advance_config param err:%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = advance_config_ser.Update(p, manager)
|
||||
if err != stderr.Success {
|
||||
log.Error(fmt.Sprintf("Update all advance_config err:%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AdvanceConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除预售配置
|
||||
// @Description 删除预售配置
|
||||
// @Tags 后台-预售配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query advanceconfigmod.WebDeleteReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/advance_config/delete [post]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &advanceconfigmod.WebDeleteReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Del all advance_config param err:%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 删除
|
||||
err = advance_config_ser.Del(p, manager)
|
||||
if err != stderr.Success {
|
||||
log.Error(fmt.Sprintf("Del advance_config err:%v", err))
|
||||
common.ServeJSON(ctx, stderr.Failure, nil)
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AdvanceConfig, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package advance_order_ctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/advanceordermod"
|
||||
"91porn-server/models/v/export_task_mod"
|
||||
"91porn-server/web/service/advance_order_ser"
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// QueryAll doc
|
||||
// @Summary 查询预售订单列表
|
||||
// @Description 查询预售订单列表
|
||||
// @Tags 预售订单
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData primitive.ObjectID true "文档id"
|
||||
// @Param status formData integer true "预售订单状态"
|
||||
// @Param oid formData string true "支付平台订单号"
|
||||
// @Param uid formData integer true "用户ID"
|
||||
// @Param pageNumber formData integer true "查询页码"
|
||||
// @Param pageSize formData integer true "页码大小"
|
||||
// @Success 200 {object} advanceordermod.QueryAllRes
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/advance_order [get]
|
||||
func QueryAll(c *gin.Context) {
|
||||
var in advanceordermod.QueryAllCond
|
||||
if err := c.ShouldBindQuery(&in); err != nil {
|
||||
log.Error(fmt.Sprintf("Query all advance_order param err:%v\n", err))
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
data, err := advance_order_ser.QueryAll(&in)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Query all advance_order err:%v\n%d", data, err))
|
||||
common.ServeJSON(c, stderr.Failure, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, data)
|
||||
}
|
||||
|
||||
// Export doc
|
||||
// @Summary 导出预售订单列表
|
||||
// @Description 导出预售订单列表
|
||||
// @Tags 预售订单
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData primitive.ObjectID true "文档id"
|
||||
// @Param status formData integer true "预售订单状态"
|
||||
// @Param oid formData string true "支付平台订单号"
|
||||
// @Param uid formData integer true "用户ID"
|
||||
// @Param pageNumber formData integer true "查询页码"
|
||||
// @Param pageSize formData integer true "页码大小"
|
||||
// @Param timeField formData integer true "时间筛选字段 createdAt 创建时间 endTime 预售尾款结束时间"
|
||||
// @Param start formData integer true "开始时间"
|
||||
// @Param end formData integer true "结束时间"
|
||||
// @Success 200 {object} advanceordermod.QueryAllRes
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/advance_order/export [post]
|
||||
func Export(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req advanceordermod.QueryAllCond
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
log.Error(fmt.Sprintf("Query all advance_order param err:%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
err = export_task_mod.CreateTask(export_task_mod.ExportAdvanceOrderTask, manager, req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrExportFileFail, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, "success")
|
||||
}
|
||||
@@ -0,0 +1,417 @@
|
||||
package ai_changeface_ctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/aichangefaceimgmod"
|
||||
"91porn-server/models/v/aichangefacemod"
|
||||
"91porn-server/models/v/aichangefacevidmod"
|
||||
"91porn-server/web/service/ai_changeface_img_ser"
|
||||
"91porn-server/web/service/ai_changeface_ser"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary AI换脸订单列表
|
||||
// @Description AI换脸订单列表
|
||||
// @Tags AI视频换脸-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param status query int false "记录状态"
|
||||
// @Param pageNumber query int true "第几页"
|
||||
// @Param pageSize query int true "每页数量"
|
||||
// @Success 200 object interface{} "成功后返回"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /ai/changeface/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req aichangefacemod.ListRequest
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
var id *primitive.ObjectID
|
||||
if req.ID != nil {
|
||||
tmpId, err := primitive.ObjectIDFromHex(*req.ID)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if tmpId.IsZero() {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "zero id")
|
||||
return
|
||||
}
|
||||
id = &tmpId
|
||||
}
|
||||
if req.Uid != nil && *req.Uid == 0 {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "zero uid")
|
||||
return
|
||||
}
|
||||
|
||||
list, count, hasNext, err := ai_changeface_ser.List(id, &req)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("ai_changeface_ser web List error%v, manager%v", err.Error(), manager))
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{
|
||||
"list": list,
|
||||
"total": count,
|
||||
"hasNext": hasNext,
|
||||
})
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新AI换脸记录
|
||||
// @Description 更新AI换脸记录
|
||||
// @Tags AI视频换脸-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id formData string true "AI换脸订单ID"
|
||||
// @Param status formData int false "状态 0 未完成; 1 已完成; -1 已退款"
|
||||
// @Param cover formData string false "换脸后封面大图"
|
||||
// @Param url formData string false "换脸后视频地址"
|
||||
// @Param remark formData string false "拒绝理由"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /ai/changeface/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req aichangefacemod.EditAiChangeFace
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
log.Error(fmt.Sprintf("ai changeface Update param err%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if req.ID.IsZero() {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
//if code := ai_changeface_ser.Update(manager, &req); code != stderr.Success {
|
||||
if code := ai_changeface_ser.UpdateNew(manager, &req); code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("ai changeface Update err%v", code))
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
updateLog, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AiChangeface, constant.Modify, string(updateLog), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg())
|
||||
}
|
||||
|
||||
// ModList doc
|
||||
// @Summary AI换脸视频模版列表
|
||||
// @Description AI换脸视频模版列表
|
||||
// @Tags AI模版模块-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param status query int false "记录状态"
|
||||
// @Param pageNumber query int true "第几页"
|
||||
// @Param pageSize query int true "每页数量"
|
||||
// @Success 200 object interface{} "成功后返回"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /ai/changeface/mod/list [get]
|
||||
func ModList(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req aichangefacevidmod.WebListRequest
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
data, code := ai_changeface_ser.ModList(&req)
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("ai_changeface_ser web List error%v,manager%v", code.Error(), manager))
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("ai_changeface_ser web List error%v,manager%v", err.Error(), manager))
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
// ModUpdate doc
|
||||
// @Summary AI换脸视频模版编辑
|
||||
// @Description AI换脸视频模版编辑
|
||||
// @Tags AI模版模块-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param status query int false "记录状态"
|
||||
// @Param pageNumber query int true "第几页"
|
||||
// @Param pageSize query int true "每页数量"
|
||||
// @Success 200 object interface{} "成功后返回"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /ai/changeface/mod/update [post]
|
||||
func ModUpdate(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req aichangefacevidmod.EditAiChangeFaceVid
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if req.ID.IsZero() {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err = ai_changeface_ser.UpdateMod(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
updateLog, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AiChangefaceVidMod, constant.Modify, string(updateLog), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// ModAdd doc
|
||||
// @Summary 添加AI换脸视频模版
|
||||
// @Description 添加AI换脸视频模版
|
||||
// @Tags AI模版模块-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param status query int false "记录状态"
|
||||
// @Param pageNumber query int true "第几页"
|
||||
// @Param pageSize query int true "每页数量"
|
||||
// @Success 200 object interface{} "成功后返回"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /ai/changeface/mod/add [post]
|
||||
func ModAdd(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req aichangefacevidmod.AddAiChangeFaceVidReq
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err = ai_changeface_ser.AddMod(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
addLog, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AiChangefaceVidMod, constant.Add, string(addLog), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// GetById doc
|
||||
// @Summary 根据ID获取AI模版
|
||||
// @Description 根据ID获取AI模版
|
||||
// @Tags AI模版模块-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id query string false "模版ID"
|
||||
// @Success 200 object interface{} "成功后返回"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /ai/changeface/mod/getById [get]
|
||||
func GetById(ctx *gin.Context) {
|
||||
_, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req struct {
|
||||
ID string `form:"id" json:"id" binding:"required"`
|
||||
}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
modId, err := primitive.ObjectIDFromHex(req.ID)
|
||||
if err != nil || modId.IsZero() {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
mod, err := aichangefacevidmod.GetModById(modId)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{
|
||||
"data": mod,
|
||||
})
|
||||
}
|
||||
|
||||
// AIChangeFaceImgList doc
|
||||
// @Summary AI图片换脸列表
|
||||
// @Description AI图片换脸列表
|
||||
// @Tags AI图片换脸-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param status query int false "记录状态"
|
||||
// @Param uid query int false "用户id"
|
||||
// @Param id query int false "流水id"
|
||||
// @Param mId query string false "AI模版id"
|
||||
// @Param pageNumber query int true "第几页"
|
||||
// @Param pageSize query int true "每页数量"
|
||||
// @Success 200 object interface{} "成功后返回"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/change_face_img/list [get]
|
||||
func AIChangeFaceImgList(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req aichangefaceimgmod.WebListRequest
|
||||
if err := ctx.ShouldBindQuery(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
data, code := ai_changeface_img_ser.List(&req)
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("AIChangeFaceImg web List error%v,manager%v", code.Error(), manager))
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// AIChangeFaceImgUpdate doc
|
||||
// @Summary 审核AI图片换脸记录
|
||||
// @Description 审核AI图片换脸记录
|
||||
// @Tags AI图片换脸-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id formData string true "订单ID"
|
||||
// @Param newPic formData []string false "AI图片换脸后新图"
|
||||
// @Param status formData string true "状态 1、进行中 2、生成成功 3、生成失败"
|
||||
// @Param remark formData string false "拒绝理由"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/change_face_img/update [post]
|
||||
func AIChangeFaceImgUpdate(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req aichangefaceimgmod.EditCond
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
log.Error(fmt.Sprintf("AIChangeFaceImg Update param err%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
//code := ai_changeface_img_ser.Update(manager, &req)
|
||||
code := ai_changeface_img_ser.UpdateNew(manager, &req)
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("AIChangeFaceImg Update err%v", code))
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
updateLog, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AiChangeFaceImgList, constant.Modify, string(updateLog), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg())
|
||||
}
|
||||
|
||||
// 回调
|
||||
func Callback(ctx *gin.Context) {
|
||||
var req aichangefacevidmod.CallbackReq
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
log.Error(fmt.Sprintf("ai undress update param err%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code := ai_changeface_ser.CallBackOrder(&req)
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("ai undress Update err%v", code))
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
ctx.String(200, "success", "success")
|
||||
}
|
||||
|
||||
func CallbackByImg(ctx *gin.Context) {
|
||||
var req aichangefacevidmod.CallbackReq
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
log.Error(fmt.Sprintf("ai undress update param err%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code := ai_changeface_img_ser.CallBackOrder(&req)
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("CallbackByImg Update err%v", code))
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
ctx.String(200, "success", "success")
|
||||
}
|
||||
|
||||
// BatchModUpdate doc
|
||||
// @Summary AI换脸视频模版批量修改
|
||||
// @Description AI换脸视频模版批量修改
|
||||
// @Tags AI模版模块-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param q body ai_changeface_ser.BatchUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/changeface/mod/batch/update [post]
|
||||
func BatchModUpdate(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req ai_changeface_ser.BatchUpdateReq
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err = req.BatchUpdateMod(); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
updateLog, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AiChangefaceVidMod, constant.Modify, string(updateLog), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// AllSceneList doc
|
||||
// @Summary AI换脸视频模版列表
|
||||
// @Description AI换脸视频模版列表
|
||||
// @Tags AI模版模块-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 object interface{} "成功后返回"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Security BasicAuth
|
||||
// @Router /api/web/admin/ai/change_face/mod/all/scene [get]
|
||||
func AllSceneList(ctx *gin.Context) {
|
||||
var in ai_changeface_ser.AllSceneListReq
|
||||
if err := ctx.ShouldBind(&in); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
data, err := in.All()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
package ai_image_to_video_ctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/ai_image_to_video_ser"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取AI图生视频列表列表
|
||||
// @Description 获取AI图生视频列表列表
|
||||
// @Tags 后台-AI图生视频列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query ai_image_to_video_ser.WebListReq false "请求参数"
|
||||
// @Success 200 object ai_image_to_video_ser.WebListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/image_to_video/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &ai_image_to_video_ser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新AI图生视频列表
|
||||
// @Description 更新AI图生视频列表
|
||||
// @Tags 后台-AI图生视频列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body ai_image_to_video_ser.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/image_to_video/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &ai_image_to_video_ser.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update()
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("image_to_video update err:%v", err))
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "AI图生视频列表管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除AI图生视频列表
|
||||
// @Description 删除AI图生视频列表
|
||||
// @Tags 后台-AI图生视频列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body ai_image_to_video_ser.WebDeleteReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/image_to_video/delete [post]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &ai_image_to_video_ser.WebDeleteReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 删除
|
||||
err = p.Delete()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "AI图生视频列表管理", "删除", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Callback doc
|
||||
// @Summary 回调AI图生视频订单
|
||||
// @Description 回调AI图生视频订单
|
||||
// @Tags 后台-AI图生视频列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body ai_image_to_video_ser.CallbackReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/image_to_video/callback [post]
|
||||
func Callback(ctx *gin.Context) {
|
||||
var in ai_image_to_video_ser.CallbackReq
|
||||
if err := ctx.ShouldBind(&in); err != nil {
|
||||
log.Error(fmt.Sprintf("ai image_to_video Callback param err:%v", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
err := in.Callback()
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("ai image_to_video Callback err:%v", err))
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
ctx.String(http.StatusOK, stderr.Success.Msg())
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package ai_mate_ctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/web/service/ai_mate_ser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary AI办理交易列表
|
||||
// @Description AI办理交易列表
|
||||
// @Tags AiMate
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData string true "id"
|
||||
// @Param position formData integer true "广告位置"
|
||||
// @Param pageNumber formData integer true "查询页码"
|
||||
// @Param pageSize formData integer true "页码大小"
|
||||
// @Param sort formData string true "排序的字段"
|
||||
// @Param desc formData integer true "1 正序 -1倒序"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/aimate/trans_list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var args struct {
|
||||
Uid uint64 `form:"uid" json:"uid" binding:"required"` //用户id
|
||||
commod.Page
|
||||
}
|
||||
if err := ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "ai_mate_ctrl List arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
code, data := ai_mate_ser.GetUserTransactionsList(args.Uid, args.PageNumber, args.PageSize)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package ai_mate_v2_ctrl
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/web/service/ai_mate_v2_ser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// OrderLogs doc
|
||||
// @Summary AI女友V2消费流水
|
||||
// @Description 查询老司机AI女友V2第三方消费流水
|
||||
// @Tags AiMateV2
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param uid query integer true "用户ID"
|
||||
// @Param pageNumber query integer true "查询页码"
|
||||
// @Param pageSize query integer true "每页条数,最大100"
|
||||
// @Param startTime query string false "开始时间,不传默认近一个月"
|
||||
// @Param endTime query string false "结束时间,不传默认当前时间"
|
||||
// @Success 200 {string} json "{\"msg\": \"操作成功\"}"
|
||||
// @Failure 400 {string} json "{\"msg\": \"操作失败\"}"
|
||||
// @Router /api/web/admin/aimatev2/order_logs [get]
|
||||
func OrderLogs(ctx *gin.Context) {
|
||||
var args struct {
|
||||
UID uint64 `form:"uid" json:"uid" binding:"required"`
|
||||
StartTime time.Time `form:"startTime" json:"startTime"`
|
||||
EndTime time.Time `form:"endTime" json:"endTime"`
|
||||
commod.Page
|
||||
}
|
||||
if err := ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "ai_mate_v2_ctrl OrderLogs arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
endTime := args.EndTime
|
||||
if endTime.IsZero() {
|
||||
endTime = time.Now()
|
||||
}
|
||||
startTime := args.StartTime
|
||||
if startTime.IsZero() {
|
||||
startTime = endTime.AddDate(0, -1, 0)
|
||||
}
|
||||
if !startTime.Before(endTime) {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "开始时间必须早于结束时间")
|
||||
return
|
||||
}
|
||||
|
||||
code, data := ai_mate_v2_ser.GetUserOrderLogs(
|
||||
ctx.Request.Context(),
|
||||
args.UID,
|
||||
args.PageNumber,
|
||||
args.PageSize,
|
||||
startTime,
|
||||
endTime,
|
||||
)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
package ai_template_module_ctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/ai_template_module_ser"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取AI模版模块列表列表
|
||||
// @Description 获取AI模版模块列表列表
|
||||
// @Tags 后台-AI模版模块列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query ai_template_module_ser.WebListReq false "请求参数"
|
||||
// @Success 200 object ai_template_module_ser.WebListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai_template_module/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &ai_template_module_ser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// AllList doc
|
||||
// @Summary 获取所有AI模版模块接口
|
||||
// @Description 获取所有AI模版模块
|
||||
// @Tags 后台-AI模版模块列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query ai_template_module_ser.WebAllListReq false "请求参数"
|
||||
// @Success 200 object ai_template_module_ser.WebAllListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai_template_module/all [get]
|
||||
func AllList(ctx *gin.Context) {
|
||||
var req = &ai_template_module_ser.WebAllListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Create doc
|
||||
// @Summary 新增AI模版模块列表
|
||||
// @Description 新增AI模版模块列表
|
||||
// @Tags 后台-AI模版模块列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body ai_template_module_ser.WebCreateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai_template_module/create [post]
|
||||
func Create(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &ai_template_module_ser.WebCreateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 创建
|
||||
err = p.Create()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "AI模版模块列表管理", "创建", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新AI模版模块列表
|
||||
// @Description 更新AI模版模块列表
|
||||
// @Tags 后台-AI模版模块列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body ai_template_module_ser.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai_template_module/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &ai_template_module_ser.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "AI模版模块列表管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除AI模版模块列表
|
||||
// @Description 删除AI模版模块列表
|
||||
// @Tags 后台-AI模版模块列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body ai_template_module_ser.WebDeleteReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai_template_module/delete [post]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &ai_template_module_ser.WebDeleteReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 删除
|
||||
err = p.Delete()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "AI模版模块列表管理", "删除", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
package ai_text_to_image_ctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/ai_text_to_image_ser"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取AI绘图列表列表
|
||||
// @Description 获取AI绘图列表列表
|
||||
// @Tags 后台-AI绘图列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query ai_text_to_image_ser.WebListReq false "请求参数"
|
||||
// @Success 200 object ai_text_to_image_ser.WebListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/text_to_image/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &ai_text_to_image_ser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新AI绘图列表
|
||||
// @Description 更新AI绘图列表
|
||||
// @Tags 后台-AI绘图列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body ai_text_to_image_ser.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/text_to_image/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &ai_text_to_image_ser.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "AI绘图列表管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除AI绘图列表
|
||||
// @Description 删除AI绘图列表
|
||||
// @Tags 后台-AI绘图列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body ai_text_to_image_ser.WebDeleteReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/text_to_image/delete [post]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &ai_text_to_image_ser.WebDeleteReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 删除
|
||||
err = p.Delete()
|
||||
if err != nil {
|
||||
if code, ok := err.(stderr.Code); ok {
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "AI绘图列表管理", "删除", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Callback doc
|
||||
// @Summary 回调AI图生视频订单
|
||||
// @Description 回调AI图生视频订单
|
||||
// @Tags 后台-AI图生视频列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body ai_text_to_image_ser.CallbackReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/text_to_image/callback [post]
|
||||
func Callback(ctx *gin.Context) {
|
||||
var in ai_text_to_image_ser.CallbackReq
|
||||
if err := ctx.ShouldBind(&in); err != nil {
|
||||
log.Error(fmt.Sprintf("ai text_to_image Callback param err:%v", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
err := in.Callback()
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("ai text_to_image Callback err:%v", err))
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
ctx.String(http.StatusOK, stderr.Success.Msg())
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
package ai_text_to_novel_ctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/ai_text_to_novel_ser"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取AI小说列表列表
|
||||
// @Description 获取AI小说列表列表
|
||||
// @Tags 后台-AI小说列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query ai_text_to_novel_ser.WebListReq false "请求参数"
|
||||
// @Success 200 object ai_text_to_novel_ser.WebListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/text_to_novel/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &ai_text_to_novel_ser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新AI小说列表
|
||||
// @Description 更新AI小说列表
|
||||
// @Tags 后台-AI小说列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body ai_text_to_novel_ser.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/text_to_novel/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &ai_text_to_novel_ser.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "AI小说列表管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除AI小说列表
|
||||
// @Description 删除AI小说列表
|
||||
// @Tags 后台-AI小说列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body ai_text_to_novel_ser.WebDeleteReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/text_to_novel/delete [post]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &ai_text_to_novel_ser.WebDeleteReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 删除
|
||||
err = p.Delete()
|
||||
if err != nil {
|
||||
if code, ok := err.(stderr.Code); ok {
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "AI小说列表管理", "删除", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Callback doc
|
||||
// @Summary 回调AI小说订单
|
||||
// @Description 回调AI小说订单
|
||||
// @Tags 后台-AI小说列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body ai_text_to_novel_ser.CallbackReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/text_to_novel/callback [post]
|
||||
func Callback(ctx *gin.Context) {
|
||||
var in ai_text_to_novel_ser.CallbackReq
|
||||
if err := ctx.ShouldBind(&in); err != nil {
|
||||
log.Error(fmt.Sprintf("ai ai_text_to_novel callback param err:%v", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
err := in.Callback()
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("ai ai_text_to_novel callback err:%v", err))
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
ctx.String(http.StatusOK, stderr.Success.Msg())
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package ai_undress_ctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/aiUnDressmod"
|
||||
"91porn-server/web/service/ai_undress_service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary AI脱衣列表
|
||||
// @Description AI脱衣列表
|
||||
// @Tags AI脱衣-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param status query int false "记录状态"
|
||||
// @Param pageNumber query int true "第几页"
|
||||
// @Param pageSize query int true "每页数量"
|
||||
// @Success 200 object interface{} "成功后返回"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /ai/undress/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req aiUnDressmod.WebListRequest
|
||||
if err := ctx.ShouldBindQuery(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
data, code := ai_undress_service.List(&req)
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("ai_undress_service web List error%v,manager%v", code.Error(), manager))
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 生成AI脱衣记录
|
||||
// @Description 生成AI脱衣记录
|
||||
// @Tags AI脱衣-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param originPic formData string false "脱衣原图"
|
||||
// @Param coin formData string false "金币价格"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /ai/undress/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req aiUnDressmod.EditCond
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
log.Error(fmt.Sprintf("ai undress Generate param err%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
code := ai_undress_service.Update(manager, &req)
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("ai undress Update err%v", code))
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
updateLog, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AiUndressList, constant.Modify, string(updateLog), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg())
|
||||
}
|
||||
|
||||
// Auto doc
|
||||
// @Summary 生成AI脱衣记录,自动处理
|
||||
// @Description 生成AI脱衣记录,自动处理
|
||||
// @Tags AI脱衣-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param originPic formData string false "脱衣原图"
|
||||
// @Param coin formData string false "金币价格"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/undress/auto [post]
|
||||
func Auto(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req aiUnDressmod.AutoCond
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
log.Error(fmt.Sprintf("ai undress auto Generate param err%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
code := ai_undress_service.Auto(manager, &req)
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("ai undress auto err%v", code))
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
updateLog, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AiUndressList, constant.Modify, string(updateLog), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg())
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 生成AI脱衣记录,批量自动处理
|
||||
// @Description 生成AI脱衣记录,批量自动处理
|
||||
// @Tags AI脱衣-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param ids formData []string false "id列表"
|
||||
// @Param pass formData bool false "是否通过"
|
||||
// @Param remark formData string false "不通过的原因"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/undress/auto/batch [post]
|
||||
func AutoBatch(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req aiUnDressmod.AutoBatchCond
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
log.Error(fmt.Sprintf("ai undress auto Generate param err%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
w := &sync.WaitGroup{}
|
||||
errCodes := []stderr.Code{}
|
||||
lock := &sync.Mutex{}
|
||||
for _, v := range req.IDs {
|
||||
w.Add(1)
|
||||
id := v
|
||||
common.Go(func() {
|
||||
defer w.Done()
|
||||
if !req.Pass {
|
||||
status := aiUnDressmod.FAILURE
|
||||
// 拒绝
|
||||
code := ai_undress_service.Update(manager, &aiUnDressmod.EditCond{
|
||||
ID: id,
|
||||
Status: &status,
|
||||
Remark: &req.Remark,
|
||||
})
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
errCodes = append(errCodes, code)
|
||||
return
|
||||
}
|
||||
// 审核通过
|
||||
code := ai_undress_service.Auto(manager, &aiUnDressmod.AutoCond{
|
||||
ID: id,
|
||||
})
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
errCodes = append(errCodes, code)
|
||||
})
|
||||
}
|
||||
w.Wait()
|
||||
|
||||
for _, code := range errCodes {
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("ai undress auto err%v", code))
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
updateLog, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AiUndressList, constant.Modify, string(updateLog), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg())
|
||||
}
|
||||
|
||||
// Callback doc
|
||||
// @Summary AI脱衣回调,自动服务
|
||||
// @Description AI脱衣回调,自动服务
|
||||
// @Tags AI脱衣-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param originPic formData string false "脱衣原图"
|
||||
// @Param coin formData string false "金币价格"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /ai/undress/callback [post]
|
||||
func Callback(ctx *gin.Context) {
|
||||
var req aiUnDressmod.CallBackReq
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
log.Error(fmt.Sprintf("ai undress update param err%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code := ai_undress_service.CallBackOrder(&req)
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("ai undress Update err%v", code))
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
ctx.String(200, "success")
|
||||
}
|
||||
Executable
+178
@@ -0,0 +1,178 @@
|
||||
package aiplazactrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/aiplazaser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取ai广场帖子列表
|
||||
// @Description 获取ai广场帖子列表
|
||||
// @Tags 后台-ai广场帖子
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query aiplazaser.WebListReq false "请求参数"
|
||||
// @Success 200 object aiplazaser.WebListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/aiplaza/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &aiplazaser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Create doc
|
||||
// @Summary 新增ai广场帖子
|
||||
// @Description 新增ai广场帖子
|
||||
// @Tags 后台-ai广场帖子
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body aiplazaser.WebCreateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/aiplaza/create [post]
|
||||
func Create(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &aiplazaser.WebCreateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 创建
|
||||
err = p.Create()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "ai广场帖子管理", "创建", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新ai广场帖子
|
||||
// @Description 更新ai广场帖子
|
||||
// @Tags 后台-ai广场帖子
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body aiplazaser.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/aiplaza/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &aiplazaser.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "ai广场帖子管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// BatchUpdate doc
|
||||
// @Summary 更新ai广场帖子
|
||||
// @Description 更新ai广场帖子
|
||||
// @Tags 后台-ai广场帖子
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body aiplazaser.WebBatchUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/aiplaza/batch/update [post]
|
||||
func BatchUpdate(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &aiplazaser.WebBatchUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "ai广场帖子管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除ai广场帖子
|
||||
// @Description 删除ai广场帖子
|
||||
// @Tags 后台-ai广场帖子
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body aiplazaser.WebDeleteReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/aiplaza/delete [post]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &aiplazaser.WebDeleteReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil || len(p.ID) == 0 {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 删除
|
||||
err = p.Delete()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "ai广场帖子管理", "删除", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package annouctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/annoumod"
|
||||
"91porn-server/web/service/annouser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetAnnouList doc
|
||||
// @Summary 获取公告列表
|
||||
// @Description 获取公告列表
|
||||
// @Tags annou
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param pageNumber formData integer true "查询页码"
|
||||
// @Param pageSize formData integer true "页码大小"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/annou/list [get]
|
||||
func GetAnnouList(ctx *gin.Context) {
|
||||
req := annoumod.ListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := annouser.GetAnnouList(req)
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// UpdateAnnou doc
|
||||
// @Summary 更新公告
|
||||
// @Description 更新公告
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param pageNumber formData integer true "查询页码"
|
||||
// @Param pageSize formData integer true "页码大小"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/annou/update [post]
|
||||
func UpdateAnnou(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := annoumod.EditReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := annouser.UpdateAnnou(req)
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AdsManageAnnousList, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// DeleteAnnou doc
|
||||
// @Summary 删除公告
|
||||
// @Description 删除公告
|
||||
// @Tags follow
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param vids formData []string true "公告id数组"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/annou/del [delete]
|
||||
func DeleteAnnou(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := annoumod.DeleteReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := annouser.DeleteAnnou(req.IDs)
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AdsManageAnnousList, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// AddAnnou doc
|
||||
// @Summary 增加一条公告
|
||||
// @Description 增加一条公告
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param pageNumber formData integer true "查询页码"
|
||||
// @Param pageSize formData integer true "页码大小"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/annou/add [post]
|
||||
func AddAnnou(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := annoumod.AddReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := annouser.AddAnnou(req)
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AdsManageAnnousList, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package annouctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/annoumod"
|
||||
"91porn-server/web/service/annouser"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetAnnounceList doc
|
||||
// @Summary 获取会员中心跑马灯列表
|
||||
// @Description 获取会员中心跑马灯列表
|
||||
// @Tags annou
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param pageNumber formData integer true "查询页码"
|
||||
// @Param pageSize formData integer true "页码大小"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/announce/list [get]
|
||||
func GetAnnounceList(ctx *gin.Context) {
|
||||
req := annoumod.AnnounceInfoReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := annouser.GetAnnounceList()
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// UpdateAnnounce doc
|
||||
// @Summary 更新会员中心跑马灯
|
||||
// @Description 更新会员中心跑马灯
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData integer true "id"
|
||||
// @Param content formData string true "内容"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/announce/update [post]
|
||||
func UpdateAnnounce(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := annoumod.EditAnnounceReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := annouser.UpdateAnnounce(req)
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AdsManageAnnounceList, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// DeleteAnnounce doc
|
||||
// @Summary 删除会员中心跑马灯
|
||||
// @Description 删除会员中心跑马灯
|
||||
// @Tags follow
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param vids formData []string true "跑马灯id数组"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/announce/del [delete]
|
||||
func DeleteAnnounce(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := annoumod.DeleteAnnounceReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := annouser.DeleteAnnounce(req.IDs)
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AdsManageAnnounceList, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// AddAnnounce doc
|
||||
// @Summary 增加一条会员中心跑马灯
|
||||
// @Description 增加一条会员中心跑马灯
|
||||
// @Tags vid
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/announce/add [post]
|
||||
func AddAnnounce(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := annoumod.AddAnnounceReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code := annouser.AddAnnounce(req)
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AdsManageAnnounceList, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
package audiobookctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/constant/redisconst"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/audiobookmod"
|
||||
"91porn-server/web/webg"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// Get doc
|
||||
// @Summary
|
||||
// @Description 查询电子书
|
||||
// @Tags audiobook
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /audiobook/list [post]
|
||||
func List(ctx *gin.Context) {
|
||||
var p struct {
|
||||
audiobookmod.QuerySelector
|
||||
commod.Page
|
||||
}
|
||||
if err := ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, total, err := audiobookmod.StdFind(p.QuerySelector, p.Page)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{
|
||||
"list": data,
|
||||
"total": total,
|
||||
})
|
||||
}
|
||||
|
||||
// Insert doc
|
||||
// @Summary 新增
|
||||
// @Description 新增
|
||||
// @Tags audiobook
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /audiobook/add [post]
|
||||
func Insert(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
v := audiobookmod.AudioBook{}
|
||||
if err = ctx.ShouldBind(&v); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = audiobookmod.InsertAudioBook(&v); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(v)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Audiobook, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 修改
|
||||
// @Description 修改
|
||||
// @Tags audiobook
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /audiobook/edit [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
p := audiobookmod.EditSelector{}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = audiobookmod.UpdateAudioBook(p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, "")
|
||||
return
|
||||
}
|
||||
redisKey := redisconst.DataCachKey(audiobookmod.RedisSetKey, "FindaudiobookByType")
|
||||
_, _ = webg.Redis.Del(redisKey)
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Audiobook, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 修改
|
||||
// @Description 修改
|
||||
// @Tags audiobook
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /audiobook/edit [post]
|
||||
func UpdateBatch(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var p struct {
|
||||
List []audiobookmod.EditSelector `json:"list"`
|
||||
}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = audiobookmod.UpdateAudioBookBatch(p.List); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, "")
|
||||
return
|
||||
}
|
||||
redisKey := redisconst.DataCachKey(audiobookmod.RedisSetKey, "FindaudiobookByType")
|
||||
_, _ = webg.Redis.Del(redisKey)
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Audiobook, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除
|
||||
// @Description 删除
|
||||
// @Tags audiobook
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData int true "audiobook等级""
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /audiobook/del [delete]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var p struct {
|
||||
ID string `json:"id" form:"id"`
|
||||
}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "")
|
||||
return
|
||||
}
|
||||
if err = audiobookmod.RemoveAudioBook(p.ID); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, "")
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Audiobook, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Get doc
|
||||
// @Summary
|
||||
// @Description 查询电子书
|
||||
// @Tags audiobook
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /audiobook/list [post]
|
||||
func Get(ctx *gin.Context) {
|
||||
var p struct {
|
||||
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"`
|
||||
}
|
||||
if err := ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := audiobookmod.GetByID(p.ID)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package authorctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/adminmod"
|
||||
"91porn-server/models/v/authoritymod"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取权限列表
|
||||
// @Description 获取权限列表
|
||||
// @Tags web-权限
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param pageNumber query int true "当前页"
|
||||
// @Param pageSize query int true "每页条数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "date": { "total":10, "list":[] }}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/author/list [get]
|
||||
func List(c *gin.Context) {
|
||||
var arg struct {
|
||||
commod.Page
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "auth List arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
skip := int64((arg.PageNumber - 1) * arg.PageSize)
|
||||
limit := int64(arg.PageSize)
|
||||
page, err := authoritymod.AuthorPages(skip, limit)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, "auth List error: "+err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, page)
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 修改权限
|
||||
// @Description 修改权限
|
||||
// @Tags web-权限
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param authID formData string true "权限ID"
|
||||
// @Param Role formData string true "角色"
|
||||
// @Param AuthJson formData string true "权限数据,json格式"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/author/update [post]
|
||||
func Update(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
AuthID primitive.ObjectID `form:"authID" json:"authID,omitempty" binding:"required"`
|
||||
Role *string `form:"role" json:"role" binding:""` //角色
|
||||
AuthJson *string `form:"authJson" json:"authJson" binding:""` //"路由权限数据,json格式"
|
||||
ActJson *string `form:"actJson" json:"actJson" binding:""` //"功能权限数据,json格式"
|
||||
}
|
||||
if err = c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "author Add arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
doc := authoritymod.AuthorityDoc{
|
||||
Role: arg.Role,
|
||||
AuthJson: arg.AuthJson,
|
||||
ActJson: arg.ActJson,
|
||||
}
|
||||
if err = authoritymod.UpdateTo(arg.AuthID, doc); err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, "auth Update error: "+err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AuthorManager, constant.Modify, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Add doc
|
||||
// @Summary 添加权限
|
||||
// @Description 批量删除权限
|
||||
// @Tags web-权限
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param Role formData string true "角色"
|
||||
// @Param AuthJson formData string false "权限数据,json格式"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/author/add [post]
|
||||
func Add(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
Role *string `form:"role" json:"role" binding:"required"` //角色
|
||||
AuthJson *string `form:"authJson" json:"authJson" binding:""` //"权限数据,json格式"
|
||||
}
|
||||
if err = c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "author Add arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
doc := authoritymod.AuthorityDoc{
|
||||
Role: arg.Role,
|
||||
AuthJson: arg.AuthJson,
|
||||
}
|
||||
if err = authoritymod.Insert(doc); err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, "auth Add error: "+err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AuthorManager, constant.Add, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 批量删除权限
|
||||
// @Description 批量删除权限
|
||||
// @Tags web-权限
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param authIDArray formData array true "权限ID数组"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/author/del [delete]
|
||||
func Delete(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
AuthIDArray []string `form:"authIDArray" json:"authIDArray" binding:"required"`
|
||||
}
|
||||
if err = c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "author Del arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
authIDArray, err := common.IDArray(arg.AuthIDArray)
|
||||
if err != nil || len(authIDArray) == 0 {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
//检查权限是否存在
|
||||
for _, authID := range authIDArray {
|
||||
doc := authoritymod.AuthorityDoc{
|
||||
ID: authID,
|
||||
}
|
||||
auth, err := authoritymod.FindOne(doc)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, "")
|
||||
return
|
||||
}
|
||||
if auth.ID.IsZero() {
|
||||
common.ServeJSON(c, stderr.AuthIsNotExist, "")
|
||||
return
|
||||
}
|
||||
using, err := adminmod.IsUsing(auth.Role)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
if using {
|
||||
common.ServeJSON(c, stderr.AuthInUsing, "")
|
||||
return
|
||||
}
|
||||
}
|
||||
if err = authoritymod.DeleteMany(authIDArray); err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, "auth DeleteMany error: "+err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AuthorManager, constant.Delete, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package backpack_ctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/backpackmod"
|
||||
"91porn-server/web/service/backpack_service"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// QueryAll doc
|
||||
// @Summary 查询用户背包
|
||||
// @Description 查询用户背包
|
||||
// @Tags 用户
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param Uid query int false "搜索用户ID"
|
||||
// @Param page query int64 true "第几页"
|
||||
// @Param limit query int64 true "每页数量"
|
||||
// @Success 200 object backpackmod.QueryAllRes "成功后返回"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/backpack [get]
|
||||
func QueryAll(c *gin.Context) {
|
||||
var in backpackmod.QueryAllWebCond
|
||||
if err := c.ShouldBindQuery(&in); err != nil {
|
||||
log.Error(fmt.Sprintf("Query all backpack param err%v\n", err))
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
data, err := backpack_service.QueryAll(&in)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Query all backpack err%v\n%d", data, err))
|
||||
common.ServeJSON(c, stderr.Failure, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, data)
|
||||
}
|
||||
Executable
+142
@@ -0,0 +1,142 @@
|
||||
package bannerjumpctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/bannerjumpser"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取限时Banner活动列表
|
||||
// @Description 获取限时Banner活动列表
|
||||
// @Tags 后台-限时Banner活动
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query bannerjumpser.WebListReq false "请求参数"
|
||||
// @Success 200 object bannerjumpser.WebListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/bannerjump/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &bannerjumpser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Create doc
|
||||
// @Summary 新增限时Banner活动
|
||||
// @Description 新增限时Banner活动
|
||||
// @Tags 后台-限时Banner活动
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body bannerjumpser.WebCreateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/bannerjump/create [post]
|
||||
func Create(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &bannerjumpser.WebCreateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 创建
|
||||
err = p.Create()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "限时Banner活动管理", "创建", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新限时Banner活动
|
||||
// @Description 更新限时Banner活动
|
||||
// @Tags 后台-限时Banner活动
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body bannerjumpser.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/bannerjump/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &bannerjumpser.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "限时Banner活动管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除限时Banner活动
|
||||
// @Description 删除限时Banner活动
|
||||
// @Tags 后台-限时Banner活动
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body bannerjumpser.WebDeleteReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/bannerjump/delete [post]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &bannerjumpser.WebDeleteReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 删除
|
||||
err = p.Delete()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "限时Banner活动管理", "删除", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package chat_message_ctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/messagemod"
|
||||
"91porn-server/web/service/chat_message_ser"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 用户私信列表
|
||||
// @Description 用户私信列表
|
||||
// @Tags 用户私信
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param sendUid query int false "发送者uid"
|
||||
// @Param takeUid query int false "接收者uid"
|
||||
// @Param isRead query boolean false "消息已读or未读"
|
||||
// @Param pageNumber query int true "第几页"
|
||||
// @Param pageSize query int true "每页数量"
|
||||
// @Success 200 object interface{} "成功后返回"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/user/chatMessage/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req messagemod.WebListRequest
|
||||
if err := ctx.ShouldBindQuery(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
data, code := chat_message_ser.List(&req)
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("chat_message_ser web List error%v,manager%v", code.Error(), manager))
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// Del doc
|
||||
// @Summary 删除用户私信
|
||||
// @Description 删除用户私信
|
||||
// @Tags 用户私信
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param sendUid query int false "发送者uid"
|
||||
// @Param takeUid query int false "接收者uid"
|
||||
// @Param isRead query boolean false "消息已读or未读"
|
||||
// @Param pageNumber query int true "第几页"
|
||||
// @Param pageSize query int true "每页数量"
|
||||
// @Success 200 object interface{} "成功后返回"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/user/chatMessage/del [delete]
|
||||
func Del(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req messagemod.WebDelReq
|
||||
if err := ctx.ShouldBindQuery(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
code := chat_message_ser.Del(&req)
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("chat_message_ser web Del error%v,manager%v", code.Error(), manager))
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, stderr.Success.Msg())
|
||||
}
|
||||
|
||||
// Send doc
|
||||
// @Summary 发送用户私信
|
||||
// @Description 发送用户私信
|
||||
// @Tags 用户私信
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param sender formData int true "发送者uid"
|
||||
// @Param receiver formData int true "接收者uid"
|
||||
// @Param content formData string true "消息内容"
|
||||
// @Success 200 object interface{} "成功后返回"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/user/chatMessage/send [post]
|
||||
func Send(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req messagemod.WebSendReq
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code := chat_message_ser.AddPrivateLetter(&messagemod.SendMsg{
|
||||
Sender: req.Sender,
|
||||
Receiver: req.Receiver,
|
||||
Content: req.Content,
|
||||
MsgType: messagemod.PrivateLetterMsg,
|
||||
})
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("chat_message_ser web Del error%v,manager%v", code.Error(), manager))
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, stderr.Success.Msg())
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package chatrobotctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/chatrobotmod"
|
||||
"91porn-server/web/service/chatrobotser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// RobotConfList doc
|
||||
// @Summary 机器人配置列表
|
||||
// @Description 机器人配置
|
||||
// @Tags Robot config
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param type query string false "机器人类型 COMMENT: 评论机器人 FILM: 影院机器人"
|
||||
// @Param pageNumber query integer true "页数"
|
||||
// @Param pageSize query integer true "每页条数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功" "data": []}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/robot/conf/list [get]
|
||||
func RobotConfList(ctx *gin.Context) {
|
||||
var param chatrobotmod.ReqConfList
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code, data, err := chatrobotser.GetRobotConfList(param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// AddRobotConf doc
|
||||
// @Summary 添加机器人配置
|
||||
// @Description 机器人配置
|
||||
// @Tags Robot config
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param type formData string true "机器人类型 COMMENT: 评论机器人 FILM: 影院机器人"
|
||||
// @Param from formData string true "机器人类型 HH:SS:MM格式"
|
||||
// @Param to formData string true "机器人类型 HH:SS:MM格式"
|
||||
// @Param totalLimit formData integer false "机器人每天评论总数"
|
||||
// @Param pureLimit formData integer false "单个机器人每天评论数"
|
||||
// @Param frequency formData integer false "机器人发表评论频率 单位:秒/条"
|
||||
// @Param isActive formData bool false "是否开启"
|
||||
// @Success 200 {string} json "{"msg": "操作成功" "data": []}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/robot/conf/add [post]
|
||||
func AddRobotConf(ctx *gin.Context) {
|
||||
var param chatrobotmod.ReqAdd
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code, data, err := chatrobotser.AddRobotConf(param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// UpdateRobotConf doc
|
||||
// @Summary 更新机器人配置
|
||||
// @Description 机器人配置
|
||||
// @Tags Robot config
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param type formData string true "机器人类型 COMMENT: 评论机器人 FILM: 影院机器人"
|
||||
// @Param from formData string false "机器人类型 HH:SS:MM格式"
|
||||
// @Param to formData string false "机器人类型 HH:SS:MM格式"
|
||||
// @Param totalLimit formData integer false "机器人每天评论总数"
|
||||
// @Param pureLimit formData integer false "单个机器人每天评论数"
|
||||
// @Param frequency formData integer false "机器人发表评论频率 单位:秒/条"
|
||||
// @Param isActive formData bool false "是否开启"
|
||||
// @Success 200 {string} json "{"msg": "操作成功" "data": []}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/robot/conf/update [post]
|
||||
func UpdateRobotConf(ctx *gin.Context) {
|
||||
var param chatrobotmod.ReqUpdate
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code, data, err := chatrobotser.UpdateRobotConf(param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
package checkinctrl
|
||||
|
||||
import (
|
||||
"91porn-server/app/service/checkinser"
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/checkinconfigmod"
|
||||
"91porn-server/models/v/checkinprizemod"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// ========== 签到配置 ==========
|
||||
|
||||
// GetCheckinConfig 获取签到配置
|
||||
func GetCheckinConfig(c *gin.Context) {
|
||||
cfg, err := checkinser.GetCheckinConfig()
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, cfg)
|
||||
}
|
||||
|
||||
type checkinConfigUpdateReq struct {
|
||||
Enable *bool `json:"enable" bson:"enable,omitempty"`
|
||||
Description *string `json:"description" bson:"description,omitempty"`
|
||||
BackgroundImage *string `json:"backgroundImage" bson:"backgroundImage,omitempty"`
|
||||
RewardBgVideos *[]rewardBgVideoReq `json:"rewardBgVideos" bson:"rewardBgVideos,omitempty"`
|
||||
IntegerExchangeList *[]giftItemReq `json:"integerExchangeList" bson:"integerExchangeList,omitempty"`
|
||||
}
|
||||
|
||||
type rewardBgVideoReq struct {
|
||||
PrizeType int `json:"prizeType" bson:"prizeType"`
|
||||
BgMediaUrl string `json:"bgMediaUrl" bson:"bgMediaUrl"`
|
||||
FsResourceId string `json:"fsResourceId" bson:"fsResourceId"`
|
||||
FsResourceStatus string `json:"-" bson:"fsResourceStatus"`
|
||||
}
|
||||
|
||||
type giftItemReq struct {
|
||||
Name string `json:"name" bson:"name"`
|
||||
Icon string `json:"icon" bson:"icon"`
|
||||
}
|
||||
|
||||
// UpdateCheckinConfig 修改签到配置
|
||||
func UpdateCheckinConfig(c *gin.Context) {
|
||||
var req checkinConfigUpdateReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// BgMediaUrl 不以 .m3u8 结尾时自动追加
|
||||
// fsResourceId 变更时重置 fsResourceStatus
|
||||
if req.RewardBgVideos != nil {
|
||||
// 查询当前配置,用于比对 fsResourceId 是否变更
|
||||
oldCfg, _ := checkinconfigmod.FindOne(bson.M{})
|
||||
oldIdMap := make(map[int]string) // prizeType -> fsResourceId
|
||||
oldStatusMap := make(map[int]string) // prizeType -> fsResourceStatus
|
||||
if oldCfg != nil {
|
||||
for _, v := range oldCfg.RewardBgVideos {
|
||||
oldIdMap[int(v.PrizeType)] = v.FsResourceId
|
||||
oldStatusMap[int(v.PrizeType)] = v.FsResourceStatus
|
||||
}
|
||||
}
|
||||
for i := range *req.RewardBgVideos {
|
||||
item := &(*req.RewardBgVideos)[i]
|
||||
if item.BgMediaUrl != "" && !strings.HasSuffix(item.BgMediaUrl, ".m3u8") {
|
||||
item.BgMediaUrl = item.BgMediaUrl + ".m3u8"
|
||||
}
|
||||
// fsResourceId 不为空且与旧值不同,重置状态让定时任务重新检查
|
||||
if item.FsResourceId != "" && item.FsResourceId != oldIdMap[item.PrizeType] {
|
||||
item.FsResourceStatus = ""
|
||||
} else {
|
||||
item.FsResourceStatus = oldStatusMap[item.PrizeType]
|
||||
}
|
||||
}
|
||||
}
|
||||
update := bson.M{"$set": req}
|
||||
if err := checkinser.UpdateCheckinConfig(update); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbUpdateError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// ========== 签到奖品管理 ==========
|
||||
|
||||
type checkinPrizeListReq struct {
|
||||
PageNumber int64 `json:"pageNumber" form:"pageNumber"`
|
||||
PageSize int64 `json:"pageSize" form:"pageSize"`
|
||||
}
|
||||
|
||||
// GetCheckinPrizeList 获取签到奖品列表
|
||||
func GetCheckinPrizeList(c *gin.Context) {
|
||||
var req checkinPrizeListReq
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if req.PageNumber <= 0 {
|
||||
req.PageNumber = 1
|
||||
}
|
||||
if req.PageSize <= 0 {
|
||||
req.PageSize = 20
|
||||
}
|
||||
list, total, err := checkinser.GetCheckinPrizeList(req.PageNumber, req.PageSize)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, gin.H{
|
||||
"list": list,
|
||||
"total": total,
|
||||
})
|
||||
}
|
||||
|
||||
// AddOneCheckinPrize 添加签到奖品
|
||||
func AddOneCheckinPrize(c *gin.Context) {
|
||||
var req checkinprizemod.CheckinPrize
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err := checkinser.AddCheckinPrize(&req); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbInsertError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, nil)
|
||||
}
|
||||
|
||||
type checkinPrizeUpdateReq struct {
|
||||
ID string `json:"id"`
|
||||
checkinPrizeParams
|
||||
}
|
||||
|
||||
type checkinPrizeParams struct {
|
||||
Title *string `json:"title" bson:"title,omitempty"`
|
||||
Image *string `json:"image" bson:"image,omitempty"`
|
||||
CheckinDays *int64 `json:"checkinDays" bson:"checkinDays,omitempty"`
|
||||
CheckinType *checkinprizemod.CheckinType `json:"checkinType" bson:"checkinType,omitempty"`
|
||||
PrizeId *string `json:"prizeId" bson:"prizeId,omitempty"`
|
||||
PrizeName *string `json:"prizeName" bson:"prizeName,omitempty"`
|
||||
Status *bool `json:"status" bson:"status,omitempty"`
|
||||
BigPrize *bool `json:"bigPrize" bson:"bigPrize,omitempty"`
|
||||
}
|
||||
|
||||
// UpdateOneCheckinPrize 更新签到奖品
|
||||
func UpdateOneCheckinPrize(c *gin.Context) {
|
||||
var req checkinPrizeUpdateReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
id, err := primitive.ObjectIDFromHex(req.ID)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "无效的ID")
|
||||
return
|
||||
}
|
||||
now := time.Now()
|
||||
updateFields := bson.M{"updatedAt": now}
|
||||
if req.Title != nil {
|
||||
updateFields["title"] = *req.Title
|
||||
}
|
||||
if req.Image != nil {
|
||||
updateFields["image"] = *req.Image
|
||||
}
|
||||
if req.CheckinDays != nil {
|
||||
updateFields["checkinDays"] = *req.CheckinDays
|
||||
}
|
||||
if req.CheckinType != nil {
|
||||
updateFields["checkinType"] = *req.CheckinType
|
||||
}
|
||||
if req.PrizeId != nil {
|
||||
pid, err := primitive.ObjectIDFromHex(*req.PrizeId)
|
||||
if err == nil {
|
||||
updateFields["prizeId"] = pid
|
||||
}
|
||||
}
|
||||
if req.PrizeName != nil {
|
||||
updateFields["prizeName"] = *req.PrizeName
|
||||
}
|
||||
if req.Status != nil {
|
||||
updateFields["status"] = *req.Status
|
||||
}
|
||||
if req.BigPrize != nil {
|
||||
updateFields["bigPrize"] = *req.BigPrize
|
||||
}
|
||||
if err := checkinser.UpdateCheckinPrize(id, updateFields); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbUpdateError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, nil)
|
||||
}
|
||||
|
||||
type delReq struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
// DelOneCheckinPrize 删除签到奖品
|
||||
func DelOneCheckinPrize(c *gin.Context) {
|
||||
var req delReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
id, err := primitive.ObjectIDFromHex(req.ID)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "无效的ID")
|
||||
return
|
||||
}
|
||||
if err := checkinser.DeleteCheckinPrize(id); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbDeleteError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// ========== 签到历史记录 ==========
|
||||
|
||||
type userCheckinsReq struct {
|
||||
PageNumber int64 `json:"pageNumber" form:"pageNumber"`
|
||||
PageSize int64 `json:"pageSize" form:"pageSize"`
|
||||
UserId uint64 `json:"userId" form:"userId"`
|
||||
Start time.Time `json:"start" form:"start"`
|
||||
End time.Time `json:"end" form:"end"`
|
||||
}
|
||||
|
||||
// GetUserCheckins 获取用户签到记录列表
|
||||
func GetUserCheckins(c *gin.Context) {
|
||||
var req userCheckinsReq
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if req.PageNumber <= 0 {
|
||||
req.PageNumber = 1
|
||||
}
|
||||
if req.PageSize <= 0 {
|
||||
req.PageSize = 20
|
||||
}
|
||||
filter := bson.M{}
|
||||
if req.UserId != 0 {
|
||||
filter["userId"] = req.UserId
|
||||
}
|
||||
if !req.Start.IsZero() && !req.End.IsZero() {
|
||||
filter["createdAt"] = bson.M{"$gte": req.Start, "$lte": req.End}
|
||||
|
||||
}
|
||||
list, total, err := checkinser.GetUserCheckinList(filter, req.PageNumber, req.PageSize)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, gin.H{
|
||||
"list": list,
|
||||
"total": total,
|
||||
})
|
||||
}
|
||||
|
||||
// DelOneUserCheckin 删除用户签到记录
|
||||
func DelOneUserCheckin(c *gin.Context) {
|
||||
var req delReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
id, err := primitive.ObjectIDFromHex(req.ID)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "无效的ID")
|
||||
return
|
||||
}
|
||||
if err := checkinser.DeleteUserCheckin(id); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbDeleteError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, nil)
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package commentAgentctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/crypt"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/cmtmod"
|
||||
"91porn-server/web/service/commentser"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ComicsTranslatePull(ctx *gin.Context) {
|
||||
var req cmtmod.ComicsTitlePullReq
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
resp, err := commentser.ComicsTranslatePull(&req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
func ComicsTranslatePush(ctx *gin.Context) {
|
||||
var req cmtmod.ComicsTitlePushReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
resp, err := commentser.ComicsTranslatePush(&req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
// Pull doc
|
||||
// @Summary 拉取未审核的评论列表
|
||||
// @Description 拉取未审核的评论列表
|
||||
// @Tags 后台-评论列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query cmtmod.PullReq false "请求参数"
|
||||
// @Success 200 object cmtmod.PullResp "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/v1/comments/pull [get]
|
||||
func Pull(ctx *gin.Context) {
|
||||
param := cmtmod.PullReq{}
|
||||
if err := ctx.ShouldBindQuery(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if param.AppId == "" || param.Sign == "" {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
isTrue := crypt.CheckSign(param.Sign, param, "pull")
|
||||
if !isTrue {
|
||||
log.Error("pull comment list fail", log.Any("param", param), log.Any("isTrue", isTrue))
|
||||
common.ServeJSON(ctx, stderr.Failure, nil)
|
||||
return
|
||||
}
|
||||
data, err := commentser.PullCommentList(param.Status, param.Limit)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, data)
|
||||
}
|
||||
|
||||
// Approve doc
|
||||
// @Summary 评论通过审核
|
||||
// @Description 评论通过审核
|
||||
// @Tags 后台-评论列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query cmtmod.ApproveReq false "请求参数"
|
||||
// @Success 200 object cmtmod.PullResp "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/v1/comments/pull [get]
|
||||
func Approve(ctx *gin.Context) {
|
||||
var arg cmtmod.AppIdJson
|
||||
if err := ctx.ShouldBindQuery(&arg); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
sign := ctx.Query("sign")
|
||||
if arg.AppId == "" || sign == "" {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
param := cmtmod.ApproveReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
isTrue := crypt.CheckSign(sign, arg, "")
|
||||
if !isTrue {
|
||||
common.ServeJSON(ctx, stderr.Failure, nil)
|
||||
return
|
||||
}
|
||||
err := commentser.CommentApprove(param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, gin.H{"code": 200, "message": "success"})
|
||||
}
|
||||
|
||||
func Reply(ctx *gin.Context) {
|
||||
var arg cmtmod.AppIdJson
|
||||
if err := ctx.ShouldBindQuery(&arg); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
sign := ctx.Query("sign")
|
||||
if arg.AppId == "" || sign == "" {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
param := cmtmod.RepliesReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
isTrue := crypt.CheckSign(sign, arg, "")
|
||||
if !isTrue {
|
||||
common.ServeJSON(ctx, stderr.Failure, nil)
|
||||
return
|
||||
}
|
||||
data, err := commentser.ReplyComment(param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, data)
|
||||
}
|
||||
@@ -0,0 +1,503 @@
|
||||
package commentctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/cmtmod"
|
||||
"91porn-server/models/v/likemod"
|
||||
"91porn-server/models/v/vidmod"
|
||||
"91porn-server/web/service/commentser"
|
||||
"91porn-server/web/webg"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tealeg/xlsx"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 评论管理
|
||||
// @Description 评论列表
|
||||
// @Tags Web-Comment
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param vidID query string false "视频id"
|
||||
// @Param uid query integer false "用户id"
|
||||
// @Param content query string false "评论内容"
|
||||
// @Param status query integer false "审核状态"
|
||||
// @Param pageNumber query integer true "页码"
|
||||
// @Param pageSize query integer true "每页条数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/comment/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
param := cmtmod.WebCmtListReqInfo{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
data, err := commentser.GetCommentList(param.VidID, param.UID, param.Content, param.IsRobot, param.IsAdvertiser, param.Status, param.Page)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 评论管理 - 删除评论(逻辑删除)
|
||||
// @Description 评论删除
|
||||
// @Tags Web-Comment
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ids formData array true "需要屏蔽的评论id"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/comment/delete [post]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
param := cmtmod.WebCmtDeleteReqInfo{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if len(param.IDS) == 0 && param.UID == 0 {
|
||||
err := errors.New(fmt.Sprintf("ids is null"))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err := commentser.DeleteCommentsByID(param.IDS, param.UID, param.Content); err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(param)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageComment, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// Info doc
|
||||
// @Summary 评论管理
|
||||
// @Description 评论详情
|
||||
// @Tags Web-Comment
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id query string true "评论id"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/comment/info [get]
|
||||
func Info(ctx *gin.Context) {
|
||||
param := cmtmod.WebCmtReqInfo{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
data, err := commentser.GetCommentInfo(param.ID)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
// Access doc
|
||||
// @Summary 评论管理
|
||||
// @Description 通过审核
|
||||
// @Tags Web-Comment
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id query string true "评论id"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/comment/access [post]
|
||||
func Access(ctx *gin.Context) {
|
||||
param := cmtmod.WebCmtReqInfo{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err := commentser.AccessComment(param.ID); err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// BatchAccess doc
|
||||
// @Summary 评论管理
|
||||
// @Description 批量通过审核
|
||||
// @Tags Web-Comment
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ids query []string true "评论ids"
|
||||
// @Param status query integer true "审核状态"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/comment/batch/access [post]
|
||||
func BatchAccess(ctx *gin.Context) {
|
||||
param := cmtmod.BatchPassReqInfo{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := commentser.BatchAccessComment(param.IDS, param.Status); err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 修改评论管理
|
||||
// @Description 修改评论为神评论
|
||||
// @Tags Web-Comment
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id query string true "评论id"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/comment/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
in := cmtmod.EditCond{}
|
||||
if err := ctx.ShouldBind(&in); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
if code := commentser.UpdateComment(&in); code != stderr.Success {
|
||||
log.Error("web service comment UpdateComment error", log.E(code), log.Any("id", in.ID))
|
||||
common.ServeJSON(ctx, stderr.Failure, code)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// AddContentExcel
|
||||
// 导入评论内容 doc
|
||||
// @Summary 导入评论内容
|
||||
// @Description 导入评论内容
|
||||
// @Tags Web-Comment
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param upload formData file true "需要导入的文件 只支持 .xls .xlsx文件"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/comment/importExcel [post]
|
||||
func AddContentExcel(ctx *gin.Context) {
|
||||
now := time.Now()
|
||||
pwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrServerUnavailable, err)
|
||||
return
|
||||
}
|
||||
file, fHeader, err := ctx.Request.FormFile("upload")
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrServerUnavailable, err)
|
||||
return
|
||||
}
|
||||
ext := filepath.Ext(fHeader.Filename)
|
||||
if !strings.ContainsAny(ext, "xls") {
|
||||
common.ServeJSON(ctx, stderr.ErrMimeType, nil)
|
||||
return
|
||||
}
|
||||
fPath := pwd + "/" + fHeader.Filename
|
||||
//defer os.Remove(fPath)
|
||||
// header调用Filename方法,就可以得到文件名
|
||||
out, err := os.Create(fPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
//defer out.Close()
|
||||
|
||||
// 将file的内容拷贝到out
|
||||
_, err = io.Copy(out, file)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var citys = webg.Static.Cities
|
||||
var uids = webg.Static.SysUser
|
||||
xlFile, err := xlsx.OpenFile(fPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
rand.Seed(time.Now().Unix())
|
||||
comments := make([]*cmtmod.Comment, 0)
|
||||
likes := make([]*likemod.Like, 0)
|
||||
commentCountMap := make(map[primitive.ObjectID]int)
|
||||
// 遍历sheet页读取
|
||||
for _, sheet := range xlFile.Sheets {
|
||||
fmt.Println("sheet name: ", sheet.Name)
|
||||
//遍历行读取
|
||||
for _, row := range sheet.Rows {
|
||||
// 遍历每行的列读取
|
||||
var content string
|
||||
var vid string
|
||||
var likeCount int64
|
||||
|
||||
for k, cell := range row.Cells {
|
||||
str := cell.String()
|
||||
if str == "" {
|
||||
break
|
||||
}
|
||||
if k == 0 {
|
||||
content = strings.TrimSpace(cell.String())
|
||||
}
|
||||
if k == 1 {
|
||||
vid = strings.TrimSpace(cell.String())
|
||||
}
|
||||
if k == 2 {
|
||||
likeCount, _ = strconv.ParseInt(cell.String(), 10, 64)
|
||||
}
|
||||
}
|
||||
v, err := vidmod.GetVideoInfo(vid)
|
||||
if err != nil || v.ID.IsZero() {
|
||||
continue
|
||||
}
|
||||
if _, ok := commentCountMap[v.ID]; !ok {
|
||||
commentCountMap[v.ID] = 0
|
||||
}
|
||||
commentCountMap[v.ID] = commentCountMap[v.ID] + 1
|
||||
reviewT := v.ReviewAt.UTC().Unix()
|
||||
duration := time.Now().UTC().Unix() - reviewT
|
||||
rangeMinu := duration / 60
|
||||
id := primitive.NewObjectID()
|
||||
comments = append(comments, &(cmtmod.Comment{
|
||||
ID: id,
|
||||
ObjID: v.ID,
|
||||
Type: "video",
|
||||
PublisherID: v.PublisherID,
|
||||
UserID: uids[rand.Intn(len(uids)-1)],
|
||||
AuthorMark: true,
|
||||
IsAuthor: false,
|
||||
Content: content,
|
||||
Level: 1,
|
||||
IPAddr: fmt.Sprintf("%d.%d.%d.%d", rand.Intn(255), rand.Intn(255), rand.Intn(255), rand.Intn(255)),
|
||||
Status: 1,
|
||||
City: citys[rand.Intn(len(citys)-1)],
|
||||
IsDelete: false,
|
||||
IsRobot: true,
|
||||
CreatedAt: now.Add(-time.Minute * time.Duration(rand.Intn(int(rangeMinu)+1))),
|
||||
}))
|
||||
for c := int64(0); c < likeCount; c++ {
|
||||
like := likemod.Like{
|
||||
Type: "comment",
|
||||
ObjID: id,
|
||||
UserID: uids[rand.Intn(len(uids)-1)],
|
||||
LikedUserID: v.PublisherID,
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
like.Uniq = likemod.Unique(like.UserID, like.Type, v.ID)
|
||||
likes = append(likes, &like)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
contentCount, _ := cmtmod.InsertManyBulket(comments)
|
||||
|
||||
likeCount, _ := likemod.InsertManyBulk(likes)
|
||||
|
||||
_, _ = vidmod.UpdateManyForContentCount(commentCountMap)
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{
|
||||
"contentCount": contentCount,
|
||||
"likeCount": likeCount,
|
||||
})
|
||||
}
|
||||
|
||||
// ImportComment
|
||||
// 导入评论内容 doc
|
||||
// @Summary 导入评论内容
|
||||
// @Description 导入评论内容
|
||||
// @Tags Web-Comment
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param upload formData file true "需要导入的文件 只支持 .xls .xlsx文件"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/comment/importComment [post]
|
||||
func ImportComment(ctx *gin.Context) {
|
||||
//now := time.Now()
|
||||
pwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrServerUnavailable, err)
|
||||
return
|
||||
}
|
||||
file, fHeader, err := ctx.Request.FormFile("upload")
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrServerUnavailable, err)
|
||||
return
|
||||
}
|
||||
ext := filepath.Ext(fHeader.Filename)
|
||||
if !strings.ContainsAny(ext, "xls") {
|
||||
common.ServeJSON(ctx, stderr.ErrMimeType, nil)
|
||||
return
|
||||
}
|
||||
fPath := pwd + "/" + fHeader.Filename
|
||||
//defer os.Remove(fPath)
|
||||
// header调用Filename方法,就可以得到文件名
|
||||
out, err := os.Create(fPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
//defer out.Close()
|
||||
|
||||
// 将file的内容拷贝到out
|
||||
_, err = io.Copy(out, file)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var citys = webg.Static.Cities
|
||||
//var uids = webg.Static.SysUser
|
||||
xlFile, err := xlsx.OpenFile(fPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
rand.Seed(time.Now().Unix())
|
||||
comments := make([]*cmtmod.Comment, 0)
|
||||
//likes := make([]*likemod.Like, 0)
|
||||
commentCountMap := make(map[primitive.ObjectID]int)
|
||||
// 遍历sheet页读取
|
||||
for _, sheet := range xlFile.Sheets {
|
||||
fmt.Println("sheet name: ", sheet.Name)
|
||||
//遍历行读取
|
||||
for _, row := range sheet.Rows {
|
||||
// 遍历每行的列读取
|
||||
var content string
|
||||
var vid string
|
||||
var contentDateStr string
|
||||
var uid uint64
|
||||
for k, cell := range row.Cells {
|
||||
str := cell.String()
|
||||
if str == "" {
|
||||
break
|
||||
}
|
||||
if k == 0 {
|
||||
// 用户ID
|
||||
cuid, _ := strconv.ParseInt(cell.String(), 10, 64)
|
||||
uid = uint64(cuid)
|
||||
}
|
||||
if k == 1 {
|
||||
// 评论内容
|
||||
content = strings.TrimSpace(cell.String())
|
||||
}
|
||||
if k == 2 {
|
||||
// 评论对象
|
||||
vid = strings.TrimSpace(cell.String())
|
||||
}
|
||||
if k == 3 {
|
||||
// 评论时间
|
||||
contentDateStr = strings.TrimSpace(cell.String())
|
||||
}
|
||||
}
|
||||
v, err := vidmod.GetVideoInfo(vid)
|
||||
if err != nil || v.ID.IsZero() {
|
||||
continue
|
||||
}
|
||||
if _, ok := commentCountMap[v.ID]; !ok {
|
||||
commentCountMap[v.ID] = 0
|
||||
}
|
||||
commentCountMap[v.ID] = commentCountMap[v.ID] + 1
|
||||
//reviewT := v.ReviewAt.UTC().Unix()
|
||||
//duration := time.Now().UTC().Unix() - reviewT
|
||||
//rangeMinu := duration / 60
|
||||
t, _ := time.Parse("2006-01-02 15:04:05", contentDateStr)
|
||||
t = t.Add(-time.Hour * 8)
|
||||
id := primitive.NewObjectID()
|
||||
comments = append(comments, &(cmtmod.Comment{
|
||||
ID: id,
|
||||
ObjID: v.ID,
|
||||
Type: "video",
|
||||
PublisherID: v.PublisherID,
|
||||
UserID: uid,
|
||||
AuthorMark: true,
|
||||
IsAuthor: false,
|
||||
Content: content,
|
||||
Level: 1,
|
||||
IPAddr: fmt.Sprintf("%d.%d.%d.%d", rand.Intn(255), rand.Intn(255), rand.Intn(255), rand.Intn(255)),
|
||||
Status: 1,
|
||||
City: citys[rand.Intn(len(citys)-1)],
|
||||
IsDelete: false,
|
||||
IsRobot: true,
|
||||
CreatedAt: t,
|
||||
}))
|
||||
//for c := int64(0); c < likeCount; c++ {
|
||||
// like := likemod.Like{
|
||||
// Type: "comment",
|
||||
// ObjID: id,
|
||||
// UserID: uids[rand.Intn(len(uids)-1)],
|
||||
// LikedUserID: v.PublisherID,
|
||||
// CreatedAt: time.Now(),
|
||||
// }
|
||||
// like.Uniq = likemod.Unique(like.UserID, like.Type, v.ID)
|
||||
// likes = append(likes, &like)
|
||||
//}
|
||||
}
|
||||
}
|
||||
var contentCount int64
|
||||
if len(comments) > 0 {
|
||||
contentCount, _ = cmtmod.InsertManyBulket(comments)
|
||||
}
|
||||
|
||||
//likeCount, _ := likemod.InsertManyBulk(likes)
|
||||
|
||||
_, _ = vidmod.UpdateManyForContentCount(commentCountMap)
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{
|
||||
"contentCount": contentCount,
|
||||
//"likeCount": likeCount,
|
||||
})
|
||||
}
|
||||
|
||||
// Send doc
|
||||
// @Summary 评论模块 - 发表评论
|
||||
// @Description 用户评论
|
||||
// @Tags Web-Comment
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param objID formData string true "评论对象的ID"
|
||||
// @Param cid formData string false "此评论是对某条评论的评论或回复,如果为空,则为对该视频的评论"
|
||||
// @Param rid formData string false "被回复的评论id"
|
||||
// @Param level formData integer false "评论层级 1:一级评论 2:二级评论"
|
||||
// @Param toUserID formData integer false "对某用户回复评论 用户ID"
|
||||
// @Param content formData string true "评论内容"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/comment/send [post]
|
||||
func Send(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
param := cmtmod.PublishReqInfo{}
|
||||
err = ctx.ShouldBind(¶m)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code, err := commentser.PublishComment(param)
|
||||
|
||||
log, _ := json.Marshal(param)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageComment, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, err)
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package contentlibctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/contentlibmod"
|
||||
"91porn-server/web/service/contentlibser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// ContentList doc
|
||||
// @Summary 机器人聊天内容库列表
|
||||
// @Description 机器人聊天内容库
|
||||
// @Tags Web-Robot Content Library
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param robotType query string false "机器人类型 COMMENT: 评论机器人 FILM: 影院机器人"
|
||||
// @Param pageNumber query integer true "页数"
|
||||
// @Param pageSize query integer true "每页条数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/robot/content/list [get]
|
||||
func ContentList(ctx *gin.Context) {
|
||||
var param = contentlibmod.ReqContentList{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code, data, err := contentlibser.GetContentList(param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// ContentAdd doc
|
||||
// @Summary 增加机器人聊天内容
|
||||
// @Description 机器人聊天内容库
|
||||
// @Tags Web-Robot Content Library
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param robotType query string true "机器人类型 COMMENT: 评论机器人 FILM: 影院机器人"
|
||||
// @Param content query string true "需要发表的内容"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/robot/content/add [post]
|
||||
func ContentAdd(ctx *gin.Context) {
|
||||
var param = contentlibmod.ReqContentAdd{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code, data, err := contentlibser.AddChatContent(param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// ContentDel doc
|
||||
// @Summary 删除内容库的指定内容
|
||||
// @Description 机器人聊天内容库
|
||||
// @Tags Web-Robot Content Library
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ids formData array true "机器人聊天内容的id数组"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/robot/content/del [delete]
|
||||
func ContentDel(ctx *gin.Context) {
|
||||
var param = contentlibmod.ReqContentDel{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code, data, err := contentlibser.DeleteChatContent(param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
@@ -0,0 +1,450 @@
|
||||
package contentreviewctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/contentreviewmod"
|
||||
"91porn-server/models/v/sensitivewordmod"
|
||||
"91porn-server/web/service/contentreviewser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// createReq 发起任务请求体
|
||||
type createReq struct {
|
||||
TaskType string `json:"taskType" binding:"required"` // VIDEO / ACG
|
||||
}
|
||||
|
||||
// Create doc
|
||||
// @Summary 发起内容检测任务
|
||||
// @Description 立即将当前启用的敏感词库做快照写入任务记录,状态为待执行,由 skd 定时调度器异步执行
|
||||
// @Tags Web-ContentReview
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body createReq true "任务参数"
|
||||
// @Success 200 {string} json "{"msg":"操作成功","data":{"id":"..."}}"
|
||||
// @Failure 400 {string} json "{"msg":"操作失败"}"
|
||||
// @Router /api/web/admin/content-review/create [post]
|
||||
func Create(ctx *gin.Context) {
|
||||
var req createReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if req.TaskType != contentreviewmod.TaskTypeVideo && req.TaskType != contentreviewmod.TaskTypeACG {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "invalid taskType")
|
||||
return
|
||||
}
|
||||
|
||||
snap, err := buildSnapshot()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
if len(snap) == 0 {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "敏感词库为空,请先配置")
|
||||
return
|
||||
}
|
||||
|
||||
operator, _ := common.GetAdminAct(ctx)
|
||||
task := &contentreviewmod.ReviewTask{
|
||||
TaskType: req.TaskType,
|
||||
SnapshotWords: snap,
|
||||
Operator: operator,
|
||||
}
|
||||
if err := contentreviewmod.CreateTask(task); err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"id": task.ID.Hex()})
|
||||
}
|
||||
|
||||
// listReq 任务列表请求
|
||||
type listReq struct {
|
||||
Page int64 `form:"page"` // 页码,从 1 开始
|
||||
Size int64 `form:"size"` // 每页条数
|
||||
TaskType string `form:"taskType"` // 任务类型筛选
|
||||
Status *int `form:"status"` // 任务状态筛选
|
||||
}
|
||||
|
||||
// taskWithStat 任务列表返回元素:嵌入 ReviewTask,附带由 IssueCount-ResolvedCount 算出的待解决数
|
||||
type taskWithStat struct {
|
||||
*contentreviewmod.ReviewTask
|
||||
UnresolvedCount int64 `json:"unresolvedCount"` // 待解决问题数 = IssueCount - ResolvedCount
|
||||
}
|
||||
|
||||
// List doc
|
||||
// @Summary 检测任务列表
|
||||
// @Description 分页查询检测任务;待解决问题数 unresolvedCount = issueCount - resolvedCount,读时算差值,无需实时聚合
|
||||
// @Tags Web-ContentReview
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "页码,默认1"
|
||||
// @Param size query int false "每页条数,默认20"
|
||||
// @Param taskType query string false "任务类型 VIDEO/ACG"
|
||||
// @Param status query int false "状态 0待执行 1执行中 2已完成 3失败"
|
||||
// @Success 200 {string} json "{"msg":"操作成功","data":{"list":[{...,"resolvedCount":0,"unresolvedCount":0}],"total":0}}"
|
||||
// @Failure 400 {string} json "{"msg":"操作失败"}"
|
||||
// @Router /api/web/admin/content-review/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req listReq
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
list, total, err := contentreviewmod.ListTasks(req.Page, req.Size, req.TaskType, req.Status)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
enriched := make([]taskWithStat, 0, len(list))
|
||||
for _, t := range list {
|
||||
unresolved := t.IssueCount - t.ResolvedCount
|
||||
if unresolved < 0 {
|
||||
unresolved = 0
|
||||
}
|
||||
enriched = append(enriched, taskWithStat{ReviewTask: t, UnresolvedCount: unresolved})
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"list": enriched, "total": total})
|
||||
}
|
||||
|
||||
// Detail doc
|
||||
// @Summary 检测任务详情
|
||||
// @Description 根据任务ID查询任务详情(含敏感词快照、进度、状态等)
|
||||
// @Tags Web-ContentReview
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id query string true "任务ID"
|
||||
// @Success 200 {string} json "{"msg":"操作成功","data":{}}"
|
||||
// @Failure 400 {string} json "{"msg":"操作失败"}"
|
||||
// @Router /api/web/admin/content-review/detail [get]
|
||||
func Detail(ctx *gin.Context) {
|
||||
idStr := ctx.Query("id")
|
||||
id, err := primitive.ObjectIDFromHex(idStr)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "invalid id")
|
||||
return
|
||||
}
|
||||
t, err := contentreviewmod.GetTaskByID(id)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
if t == nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "task not found")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, t)
|
||||
}
|
||||
|
||||
// issuesReq 命中记录列表请求
|
||||
type issuesReq struct {
|
||||
TaskID string `form:"taskId" binding:"required"` // 所属任务 ID
|
||||
Page int64 `form:"page"` // 页码
|
||||
Size int64 `form:"size"` // 每页条数
|
||||
ResolveStatus *int `form:"resolveStatus"` // 解决状态筛选 0未解决 1待审核 2已解决
|
||||
}
|
||||
|
||||
// Issues doc
|
||||
// @Summary 检测命中记录列表
|
||||
// @Description 分页查询某个任务下命中的问题记录;Title/Content/Tags/RichText 字段已通过 <mark>...</mark> 标红;支持按解决状态筛选
|
||||
// @Tags Web-ContentReview
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param taskId query string true "任务ID"
|
||||
// @Param page query int false "页码,默认1"
|
||||
// @Param size query int false "每页条数,默认20"
|
||||
// @Param resolveStatus query int false "解决状态筛选 0未解决 1待审核 2已解决"
|
||||
// @Success 200 {string} json "{"msg":"操作成功","data":{"list":[],"total":0}}"
|
||||
// @Failure 400 {string} json "{"msg":"操作失败"}"
|
||||
// @Router /api/web/admin/content-review/issues [get]
|
||||
func Issues(ctx *gin.Context) {
|
||||
var req issuesReq
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
tid, err := primitive.ObjectIDFromHex(req.TaskID)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "invalid taskId")
|
||||
return
|
||||
}
|
||||
list, total, err := contentreviewmod.ListIssues(tid, req.Page, req.Size, req.ResolveStatus)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"list": list, "total": total})
|
||||
}
|
||||
|
||||
// resolveReq 解决(提交修改并直接生效)请求
|
||||
type resolveReq struct {
|
||||
ID string `json:"id" binding:"required"` // 命中记录 ID
|
||||
SubmittedTitle string `json:"submittedTitle"` // 修改后的标题(VIDEO.Title / ACG_MEDIA.Title / ACG_CONTENT.Name)
|
||||
SubmittedContent string `json:"submittedContent"` // 修改后的内容(VIDEO.Content / ACG_MEDIA.Summary / ACG_CONTENT.Text)
|
||||
SubmittedRichText string `json:"submittedRichText"` // 修改后的富文本(仅 VIDEO 有效)
|
||||
}
|
||||
|
||||
// ResolveIssue doc
|
||||
// @Summary 解决命中记录(提交修改并直接生效)
|
||||
// @Description 管理员提交修改即刻生效:先对提交文本做敏感词复校验(仍命中则拒绝并返回详细命中信息),通过后按 TargetType 把 Submitted* 写回数据源(VideoModel/Media/MediaContent),写回成功后标记 issue 为已解决;必须提供至少一个 submittedXxx 字段
|
||||
// @Tags Web-ContentReview
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body resolveReq true "解决参数"
|
||||
// @Success 200 {string} json "{"msg":"操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg":"操作失败"}"
|
||||
// @Router /api/web/admin/content-review/issue/resolve [post]
|
||||
func ResolveIssue(ctx *gin.Context) {
|
||||
var req resolveReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if req.SubmittedTitle == "" && req.SubmittedContent == "" && req.SubmittedRichText == "" {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "至少提交一个修改字段")
|
||||
return
|
||||
}
|
||||
id, err := primitive.ObjectIDFromHex(req.ID)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "invalid id")
|
||||
return
|
||||
}
|
||||
issue, err := contentreviewmod.GetIssueByID(id)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
if issue == nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "记录不存在")
|
||||
return
|
||||
}
|
||||
if issue.ResolveStatus == contentreviewmod.ResolveStatusResolved {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "记录已解决,无需再次提交")
|
||||
return
|
||||
}
|
||||
// 复校验:管理员提交的修正文本不得再含敏感词,否则拒绝写回并返回详细命中信息
|
||||
if tip := checkSubmittedSensitive(req.SubmittedTitle, req.SubmittedContent, req.SubmittedRichText); tip != "" {
|
||||
common.ServeJSON(ctx, stderr.ContentSensitiveHit, tip)
|
||||
return
|
||||
}
|
||||
// 用提交内容覆盖 issue 字段(仅用于 applier 的入参,不持久化到这里)
|
||||
issue.SubmittedTitle = req.SubmittedTitle
|
||||
issue.SubmittedContent = req.SubmittedContent
|
||||
issue.SubmittedRichText = req.SubmittedRichText
|
||||
// 先写回数据源;成功后才把 issue 标记为已解决
|
||||
if err := contentreviewser.ApplyResolution(issue); err != nil {
|
||||
log.Error("apply resolution fail", log.Any("issueId", id), log.E(err))
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
operator, _ := common.GetAdminAct(ctx)
|
||||
ok, err := contentreviewmod.ResolveIssue(id, issue.TaskID, req.SubmittedTitle, req.SubmittedContent, req.SubmittedRichText, operator)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
if !ok {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "记录状态已变化,请刷新")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// checkSubmittedSensitive 对管理员提交的修正文本做敏感词复校验。
|
||||
// 任一字段仍命中启用状态的敏感词即返回详细提示(命中字段 + 命中词),全部通过返回空串。
|
||||
// 词库为空(含 DB 降级)时不拦截,返回空串。
|
||||
func checkSubmittedSensitive(title, content, richText string) string {
|
||||
terms := sensitivewordmod.LoadEnabledTerms()
|
||||
if len(terms) == 0 {
|
||||
return ""
|
||||
}
|
||||
titleHits := sensitivewordmod.MatchHits(title, terms)
|
||||
contentHits := sensitivewordmod.MatchHits(content, terms)
|
||||
richHits := sensitivewordmod.MatchHits(richText, terms)
|
||||
if len(titleHits) == 0 && len(contentHits) == 0 && len(richHits) == 0 {
|
||||
return ""
|
||||
}
|
||||
return "提交的修正文本仍含敏感词,请修改后重新提交:" +
|
||||
sensitivewordmod.FormatHitDetail(titleHits, contentHits, richHits)
|
||||
}
|
||||
|
||||
// batchOffShelfReq 批量下架命中请求
|
||||
type batchOffShelfReq struct {
|
||||
IDs []string `json:"ids" binding:"required,min=1"` // 命中记录 ID 列表
|
||||
}
|
||||
|
||||
// batchOffShelfFailure 单条失败明细
|
||||
type batchOffShelfFailure struct {
|
||||
ID string `json:"id"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
// batchOffShelfResp 批量下架返回
|
||||
type batchOffShelfResp struct {
|
||||
Success int `json:"success"` // 成功条数
|
||||
Fail int `json:"fail"` // 失败条数
|
||||
Failures []batchOffShelfFailure `json:"failures,omitempty"` // 失败明细
|
||||
}
|
||||
|
||||
// BatchOffShelfIssues doc
|
||||
// @Summary 批量下架命中记录
|
||||
// @Description 对一批命中记录直接执行"下架"处置:按 TargetType 分组下架对应资源(VIDEO→status=5;ACG_MEDIA→Media.status=0;ACG_CONTENT→MediaContent.isActive=false),下架成功后把 issue 标记为已解决,resolveAction=offshelf。前置校验阶段(id 非法 / 记录不存在 / 已解决)逐条剔除并返回原因;下架与标记走批量 UpdateMany,整体失败则该批全记入 failures。
|
||||
// @Tags Web-ContentReview
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body batchOffShelfReq true "批量下架参数"
|
||||
// @Success 200 {object} batchOffShelfResp
|
||||
// @Failure 400 {string} json "{"msg":"操作失败"}"
|
||||
// @Router /api/web/admin/content-review/issue/batch-offshelf [post]
|
||||
func BatchOffShelfIssues(ctx *gin.Context) {
|
||||
var req batchOffShelfReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
operator, _ := common.GetAdminAct(ctx)
|
||||
resp := batchOffShelfResp{Failures: make([]batchOffShelfFailure, 0)}
|
||||
|
||||
// 1. 解析 ID,非法的直接计入失败
|
||||
objIDs := make([]primitive.ObjectID, 0, len(req.IDs))
|
||||
rawByID := make(map[primitive.ObjectID]string, len(req.IDs))
|
||||
for _, raw := range req.IDs {
|
||||
id, err := primitive.ObjectIDFromHex(raw)
|
||||
if err != nil {
|
||||
resp.Fail++
|
||||
resp.Failures = append(resp.Failures, batchOffShelfFailure{ID: raw, Reason: "invalid id"})
|
||||
continue
|
||||
}
|
||||
objIDs = append(objIDs, id)
|
||||
rawByID[id] = raw
|
||||
}
|
||||
if len(objIDs) == 0 {
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
return
|
||||
}
|
||||
|
||||
// 2. 一次性拉取 issue
|
||||
issues, err := contentreviewmod.GetIssuesByIDs(objIDs)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
found := make(map[primitive.ObjectID]*contentreviewmod.ReviewIssue, len(issues))
|
||||
for _, iss := range issues {
|
||||
found[iss.ID] = iss
|
||||
}
|
||||
|
||||
// 3. 过滤出可下架的 issue(存在 + 未解决)
|
||||
eligible := make([]*contentreviewmod.ReviewIssue, 0, len(objIDs))
|
||||
for _, id := range objIDs {
|
||||
iss, ok := found[id]
|
||||
if !ok {
|
||||
resp.Fail++
|
||||
resp.Failures = append(resp.Failures, batchOffShelfFailure{ID: rawByID[id], Reason: "记录不存在"})
|
||||
continue
|
||||
}
|
||||
if iss.ResolveStatus == contentreviewmod.ResolveStatusResolved {
|
||||
resp.Fail++
|
||||
resp.Failures = append(resp.Failures, batchOffShelfFailure{ID: rawByID[id], Reason: "记录已解决"})
|
||||
continue
|
||||
}
|
||||
eligible = append(eligible, iss)
|
||||
}
|
||||
if len(eligible) == 0 {
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
return
|
||||
}
|
||||
|
||||
// 4. 按类型分组批量下架资源
|
||||
if err := contentreviewser.ApplyOffShelfBatch(eligible); err != nil {
|
||||
log.Error("batch offshelf apply fail", log.E(err))
|
||||
reason := "下架失败: " + err.Error()
|
||||
for _, iss := range eligible {
|
||||
resp.Fail++
|
||||
resp.Failures = append(resp.Failures, batchOffShelfFailure{ID: rawByID[iss.ID], Reason: reason})
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
return
|
||||
}
|
||||
|
||||
// 5. 批量标记已解决 + 按 taskID 聚合 $inc resolvedCount
|
||||
eligibleIDs := make([]primitive.ObjectID, 0, len(eligible))
|
||||
perTask := make(map[primitive.ObjectID]int64, len(eligible))
|
||||
for _, iss := range eligible {
|
||||
eligibleIDs = append(eligibleIDs, iss.ID)
|
||||
perTask[iss.TaskID]++
|
||||
}
|
||||
if err := contentreviewmod.BatchOffShelfResolveIssues(eligibleIDs, perTask, operator); err != nil {
|
||||
log.Error("batch mark resolved fail", log.E(err))
|
||||
reason := "标记已解决失败: " + err.Error()
|
||||
for _, iss := range eligible {
|
||||
resp.Fail++
|
||||
resp.Failures = append(resp.Failures, batchOffShelfFailure{ID: rawByID[iss.ID], Reason: reason})
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
return
|
||||
}
|
||||
|
||||
resp.Success = len(eligible)
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
// rejectReq 搁置/驳回请求
|
||||
type rejectReq struct {
|
||||
ID string `json:"id" binding:"required"` // 命中记录 ID
|
||||
Reason string `json:"reason" binding:"required"` // 搁置原因
|
||||
}
|
||||
|
||||
// RejectIssue doc
|
||||
// @Summary 搁置命中记录
|
||||
// @Description 管理员认为暂不需要修改数据源,仅记录搁置原因;状态保持未解决,后续可重新提交解决
|
||||
// @Tags Web-ContentReview
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body rejectReq true "搁置参数"
|
||||
// @Success 200 {string} json "{"msg":"操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg":"操作失败"}"
|
||||
// @Router /api/web/admin/content-review/issue/reject [post]
|
||||
func RejectIssue(ctx *gin.Context) {
|
||||
var req rejectReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
id, err := primitive.ObjectIDFromHex(req.ID)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "invalid id")
|
||||
return
|
||||
}
|
||||
operator, _ := common.GetAdminAct(ctx)
|
||||
ok, err := contentreviewmod.RejectIssue(id, operator, req.Reason)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
if !ok {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "记录不存在或已解决")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// buildSnapshot 拉取当前启用的敏感词作为任务快照
|
||||
func buildSnapshot() ([]contentreviewmod.SensitiveWordSnap, error) {
|
||||
enabled := sensitivewordmod.StatusEnabled
|
||||
list, err := sensitivewordmod.FindAll(&sensitivewordmod.ListReq{Status: &enabled})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := make([]contentreviewmod.SensitiveWordSnap, 0, len(list))
|
||||
for _, w := range list {
|
||||
out = append(out, contentreviewmod.SensitiveWordSnap{
|
||||
Word: w.Word,
|
||||
Category: w.Category,
|
||||
})
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package currencyctrl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/web/service/currencyser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Add(c *gin.Context) {
|
||||
var in *currencyser.AddCond
|
||||
if err := c.ShouldBindJSON(&in); err != nil {
|
||||
log.Error(fmt.Sprintf("新增裸聊 参数异常 [%v]", err))
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if code := currencyser.Add(in); code != stderr.Success {
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, "success")
|
||||
}
|
||||
|
||||
func Edit(c *gin.Context) {
|
||||
var in *currencyser.EditCond
|
||||
if err := c.ShouldBindJSON(&in); err != nil {
|
||||
log.Error(fmt.Sprintf("编辑裸聊 参数异常 [%v]", err))
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if code := currencyser.Edit(in); code != stderr.Success {
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, "success")
|
||||
}
|
||||
|
||||
func QueryAll(c *gin.Context) {
|
||||
var in *currencyser.QueryAllCond
|
||||
if err := c.ShouldBindQuery(&in); err != nil {
|
||||
log.Error(fmt.Sprintf("查询裸聊 参数异常 [%v]", err))
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
data, code := currencyser.QueryAll(in)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, code, data)
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package daichongctrl
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"91porn-server/common/daichong"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/e/daichongmod"
|
||||
"91porn-server/models/v/usermod"
|
||||
"91porn-server/models/v/walletmod"
|
||||
"91porn-server/web/webg"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 查询玩家信息 doc
|
||||
// @Summary 查询玩家信息 通知订单生成
|
||||
// @Description 通知订单生成
|
||||
// @Tags WEB-daichong
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param appId formData string true "代充平台提供的appId"
|
||||
// @Param data formData string true "加密结果字符串"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /daichong/api/chat/queryPlayerInfo [post]
|
||||
func QueryPlayerInfo(ctx *gin.Context) {
|
||||
param := daichongmod.CommnReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
log.Warn("daichong callback api queryPlayerInfo post param fail error", log.E(err))
|
||||
ctx.JSON(http.StatusOK, gin.H{"data": nil, "code": stderr.ErrParamError, "msg": stderr.ErrParamError.Msg()})
|
||||
return
|
||||
}
|
||||
if param.AppId != webg.Conf.DaiChong.AppID {
|
||||
ctx.JSON(http.StatusOK, gin.H{"data": nil, "code": stderr.ErrAppIDNotExist, "msg": stderr.ErrAppIDNotExist.Msg()})
|
||||
return
|
||||
}
|
||||
querySign := daichongmod.BalanceSign{}
|
||||
if err := daichong.Sign2Struct(&querySign, param.Data, webg.Conf.DaiChong.AppSecret); err != nil {
|
||||
log.Warn("daichong callback api queryPlayerInfo decrypt sign data fail error", log.E(err))
|
||||
ctx.JSON(http.StatusOK, gin.H{"data": nil, "code": stderr.Failure, "msg": stderr.Failure.Msg()})
|
||||
return
|
||||
}
|
||||
uidstr := strings.Split(strings.TrimSpace(querySign.Uids), ",")
|
||||
type userForThird struct {
|
||||
Uid string `json:"uid"`
|
||||
NickName string `json:"nickName"`
|
||||
CoinNum string `json:"coinNum"`
|
||||
BankCoin string `json:"bankCoin"`
|
||||
}
|
||||
ut := make([]userForThird, len(uidstr))
|
||||
for i, v := range uidstr {
|
||||
uid, _ := strconv.Atoi(strings.TrimSpace(v))
|
||||
user, err := usermod.FindUserByUID(uint64(uid))
|
||||
if err != nil || user == nil {
|
||||
continue
|
||||
}
|
||||
w, _ := walletmod.GetWallet(uint64(uid))
|
||||
coinNum := w.Amount
|
||||
ut[i] = userForThird{
|
||||
Uid: strings.TrimSpace(v),
|
||||
NickName: user.Name,
|
||||
CoinNum: strconv.Itoa(int(coinNum)),
|
||||
BankCoin: "0",
|
||||
}
|
||||
}
|
||||
ctx.JSON(http.StatusOK, gin.H{"data": ut, "code": stderr.Success, "msg": stderr.Success.Msg()})
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package daichongctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/daichong"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/rchgordmod"
|
||||
"91porn-server/web/service/daichongser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 代充 doc
|
||||
// @Summary 手动回调代充订单结果
|
||||
// @Description 手动回调代充订单结果
|
||||
// @Tags 代充-订单
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param oid formData string true "订单ID"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /daichong/order/handScore [post]
|
||||
func HandAddScore(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
OID string `form:"oid" json:"oid" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
order, _ := rchgordmod.FindRechargeOrderByThirdOrderId(arg.OID)
|
||||
if order.NotifyStatus == rchgordmod.Notify_SUCCESS {
|
||||
c.JSON(http.StatusOK, gin.H{"code": stderr.Failure, "msg": "不可重复手动通知,已经成功通知的订单"})
|
||||
return
|
||||
}
|
||||
var orderStatus int
|
||||
switch order.Status {
|
||||
case rchgordmod.SUCCESS:
|
||||
orderStatus = daichong.Success
|
||||
case rchgordmod.FAILURE:
|
||||
orderStatus = daichong.Failed
|
||||
}
|
||||
if orderStatus != daichong.Success && orderStatus != daichong.Failed {
|
||||
c.JSON(http.StatusOK, gin.H{"code": stderr.Failure, "msg": "订单状态不是成功或失败状态,无法手动通知"})
|
||||
return
|
||||
}
|
||||
resp, code := daichongser.OrderCallBack(c, daichong.OrderCallSign{
|
||||
OrderId: arg.OID,
|
||||
Time: order.NotifyTime,
|
||||
Status: orderStatus,
|
||||
})
|
||||
selector := rchgordmod.ReplaceEditSelector{}
|
||||
if code == http.StatusOK {
|
||||
notifySuccess := rchgordmod.Notify_SUCCESS
|
||||
selector.NotifyStatus = ¬ifySuccess
|
||||
log.InfoX(c, "daichong order call back send http request successfully",
|
||||
log.Any("msg", resp.Msg),
|
||||
log.Any("orderStatus", orderStatus),
|
||||
log.Any("orderId", arg.OID),
|
||||
log.Any("time", time.Now().Format(time.RFC3339)))
|
||||
} else {
|
||||
notifySuccess := rchgordmod.Notify_SUCCESS
|
||||
selector.NotifyStatus = ¬ifySuccess
|
||||
log.WarnX(c, "daichong order call back send http request failed", log.Any("responseCode", code),
|
||||
log.Any("msg", resp.Msg))
|
||||
}
|
||||
_ = rchgordmod.UpdateBaseOnOidAndStatus(nil, arg.OID, order.Status, selector)
|
||||
logFiled, _ := json.Marshal(&arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.TradeManageRechargeOrder, constant.Modify, string(logFiled),
|
||||
c.Request.URL.RequestURI())
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package dramatopicctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/dramatopicser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func List(ctx *gin.Context) {
|
||||
var req dramatopicser.ListRequest
|
||||
if err := ctx.ShouldBindQuery(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
response, err := req.List(time.Now())
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, response)
|
||||
}
|
||||
|
||||
func Create(ctx *gin.Context) {
|
||||
manager, ok := admin(ctx)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var req dramatopicser.CreateRequest
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
id, err := req.Create(time.Now())
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
record(ctx, manager, "创建", req)
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"topicId": id.Hex()})
|
||||
}
|
||||
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, ok := admin(ctx)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var req dramatopicser.UpdateRequest
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err := req.Update(time.Now()); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
record(ctx, manager, "修改", req)
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, ok := admin(ctx)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var req dramatopicser.DeleteRequest
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err := req.Delete(time.Now()); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
record(ctx, manager, "删除", req)
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
func Sort(ctx *gin.Context) {
|
||||
manager, ok := admin(ctx)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var req dramatopicser.SortRequest
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err := req.Update(time.Now()); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
record(ctx, manager, "排序", req)
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
func UpdateWorks(ctx *gin.Context) {
|
||||
manager, ok := admin(ctx)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var req dramatopicser.UpdateWorksRequest
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
response, err := req.Update(time.Now())
|
||||
if err != nil {
|
||||
var conflict *dramatopicser.WorksConflictError
|
||||
if errors.As(err, &conflict) {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, conflict)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
record(ctx, manager, "配置作品", req)
|
||||
common.ServeJSON(ctx, stderr.Success, response)
|
||||
}
|
||||
|
||||
func admin(ctx *gin.Context) (string, bool) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err)
|
||||
return "", false
|
||||
}
|
||||
return manager, true
|
||||
}
|
||||
|
||||
func record(ctx *gin.Context, manager, action string, request interface{}) {
|
||||
data, _ := json.Marshal(request)
|
||||
_ = operatorlgmod.RecordOperation(manager, "短剧专题管理", action, string(data), ctx.Request.URL.RequestURI())
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package errfeedbackctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/errfedbkmod"
|
||||
"91porn-server/models/v/verifyreportmod"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary
|
||||
// @Description 查询楼凤举报信息
|
||||
// @Tags loufeng
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /loufeng/getVerifyReport [post]
|
||||
func List(ctx *gin.Context) {
|
||||
var p struct {
|
||||
errfedbkmod.QuerySelector
|
||||
commod.Page
|
||||
}
|
||||
if err := ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, total, err := errfedbkmod.StdFind(p.QuerySelector, p.Page)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{
|
||||
"list": data,
|
||||
"total": total,
|
||||
"v": verifyreportmod.VerifyReport{},
|
||||
})
|
||||
}
|
||||
|
||||
// Process doc
|
||||
// @Summary 处理举报信息
|
||||
// @Description 处理举报信息
|
||||
// @Tags loufeng
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /loufeng/processVerifyReport [post]
|
||||
func Process(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
s := errfedbkmod.EditSelector{}
|
||||
if err = ctx.ShouldBind(&s); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if _, err = errfedbkmod.FindUpdate(&s); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(s)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VerifyReport, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// DelFeedback doc
|
||||
// @Summary 删除举报信息
|
||||
// @Description 处理举报信息
|
||||
// @Tags loufeng
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /verifyReport/del [post]
|
||||
func DelVerifyReport(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var p struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = verifyreportmod.Remove(p.ID); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VerifyReport, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package exchcodectrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/exchcodemod"
|
||||
"91porn-server/web/service/exchcodeser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// CodeList doc
|
||||
// @Summary 兑换码列表
|
||||
// @Description 兑换码管理
|
||||
// @Tags Web-ExchangeCode
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param batchNum query string false "批次号"
|
||||
// @Param channel query string false "渠道号"
|
||||
// @Param code query string false "兑换码"
|
||||
// @Param app query string false "APP:ysAppVideo--音色短视频 pfAppVideo--泡芙视频 ltAppVpn--雷霆加速器"
|
||||
// @Param authority formData string false "兑换权限:shortVideoVip--短视频vip filmVip--影视vip(影院)superVip--超级vip(可以兑换短视频,也可兑换影视) gold--兑换金币"
|
||||
// @Param status query string false "状态 unused--未使用,used--已兑换,expired--已过期"
|
||||
// @Param pageNumber query integer true "页码"
|
||||
// @Param pageSize query integer true "每页条数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/exchange/code/list [get]
|
||||
func CodeList(ctx *gin.Context) {
|
||||
var manager, err = common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var param = exchcodemod.ListReqParam{}
|
||||
if err = ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code, data, err := exchcodeser.GetExchangeCodeList(param, manager)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// CodeAdd doc
|
||||
// @Summary 添加兑换码
|
||||
// @Description 兑换码管理
|
||||
// @Tags Web-ExchangeCode
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param app formData string true "APP类型:ysAppVideo--音色短视频 pfAppVideo--泡芙视频 ltAppVpn--雷霆加速器"
|
||||
// @Param channels formData array true "渠道号列表"
|
||||
// @Param authority formData string true "兑换权限:shortVideoVip--短视频vip filmVip--影视vip(影院)superVip--超级vip(可以兑换短视频,也可兑换影视) gold--兑换金币"
|
||||
// @Param reward formData integer true "兑换量"
|
||||
// @Param count formData integer true "兑换码生成数量"
|
||||
// @Param effectiveAt formData string true "生效时间"
|
||||
// @Param invalidAt formData string true "失效时间"
|
||||
// @Param remark formData string false "备注"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/exchange/code/add [post]
|
||||
func CodeAdd(ctx *gin.Context) {
|
||||
var manager, err = common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var param = exchcodemod.AddReqParam{}
|
||||
if err = ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code, err := exchcodeser.AddExchangeCode(param, manager)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(param)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ExchangeCode, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
}
|
||||
|
||||
// CodeUpdate doc
|
||||
// @Summary 编辑兑换码
|
||||
// @Description 兑换码管理
|
||||
// @Tags Web-ExchangeCode
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id query string true "兑换码id"
|
||||
// @Param status query string false "状态"
|
||||
// @Param authority query string false "兑换权限"
|
||||
// @Param reward query integer false "兑换量(奖励值)"
|
||||
// @Param remark query integer false "备注"
|
||||
// @Param effectiveAt query string false "生效时间"
|
||||
// @Param invalidAt query string false "失效时间"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/exchange/code/update [post]
|
||||
func CodeUpdate(ctx *gin.Context) {
|
||||
var manager, err = common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var param = exchcodemod.UpdateReqParam{}
|
||||
if err = ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code, err := exchcodeser.UpdateExchangeCode(param, manager)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(param)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ExchangeCode, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
}
|
||||
|
||||
func ChannelList(ctx *gin.Context) {
|
||||
common.ServeJSON(ctx, 200, gin.H{"total": 1, "list": []map[string]interface{}{{"device": "any", "channel": "system"}}})
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package exchcodectrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/exchlogmod"
|
||||
"91porn-server/web/service/exchcodeser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// ExchangeLogList doc
|
||||
// @Summary 兑换码兑换日志列表
|
||||
// @Description 兑换码类型管理
|
||||
// @Tags Web-ExchangeCode
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param code query string false "兑换码"
|
||||
// @Param userID query integer false "兑换者"
|
||||
// @Param channel query string false "所属渠道"
|
||||
// @Param authority query string false "兑换权限"
|
||||
// @Param pageNumber query integer true "页码"
|
||||
// @Param pageSize query integer true "每页条数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/exchange/log/list [get]
|
||||
func LogList(ctx *gin.Context) {
|
||||
var param = exchlogmod.ListReqParam{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code, data, err := exchcodeser.GetExchangeTypeList(param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
@@ -0,0 +1,558 @@
|
||||
package exportctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common/timeutil"
|
||||
"91porn-server/models/v/export_task_mod"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/common/timeutil/timerange"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/models/l/playlgmod"
|
||||
"91porn-server/models/s/statordermod"
|
||||
"91porn-server/models/s/statvidmod"
|
||||
"91porn-server/models/v/exchcodemod"
|
||||
"91porn-server/models/v/rchgordmod"
|
||||
"91porn-server/models/v/txnmod"
|
||||
"91porn-server/models/v/usermod"
|
||||
"91porn-server/models/v/vidmod"
|
||||
"91porn-server/models/v/wdordmod"
|
||||
"91porn-server/web/service/exchcodeser"
|
||||
"91porn-server/web/service/exportser"
|
||||
"91porn-server/web/service/withdrawser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/shopspring/decimal"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type userListReq struct {
|
||||
usermod.UserListSelector
|
||||
common.StandQuery
|
||||
IsPretendAcc *int `form:"isPretendAcc" json:"isPretendAcc"` //是否马甲账号
|
||||
}
|
||||
|
||||
// Export doc
|
||||
// @Summary 导出文件
|
||||
// @Description 导出excel文件
|
||||
// @Tags Web-Export
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param fileType query integer true "导出文件的类型"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/export/:fileType [get]
|
||||
func Export(c *gin.Context) {
|
||||
typeFile := c.Param("fileType")
|
||||
t, err := strconv.ParseInt(typeFile, 10, 64)
|
||||
if typeFile == "" || err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
fpath, err := exportser.Export(t)
|
||||
if err != nil {
|
||||
log.Warn("request multipart wrong ", log.E(err))
|
||||
common.ServeJSON(c, stderr.ErrExportFileFail, err.Error())
|
||||
return
|
||||
}
|
||||
c.Writer.WriteHeader(http.StatusOK)
|
||||
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filepath.Base(fpath)))
|
||||
c.Header("Content-Type", "application/octet-stream")
|
||||
c.File(fpath)
|
||||
}
|
||||
|
||||
func getMuchUser(arg userListReq) []*usermod.User {
|
||||
uInfo := []*usermod.User{}
|
||||
cond, opt := common.StandQueryMap(arg.StandQuery, arg.UserListSelector)
|
||||
//马甲账户
|
||||
if arg.IsPretendAcc != nil && *arg.IsPretendAcc == 1 {
|
||||
cond["devID"] = bson.M{"$regex": usermod.SystemDevIDPrex, "$options": "i"}
|
||||
}
|
||||
//total, err := usermod.GetTotalCnt(cond, opt)
|
||||
//if err != nil {
|
||||
// return uInfo
|
||||
//}
|
||||
|
||||
// 每次最多导出1000条
|
||||
uInfo, _ = usermod.FindMany(cond, opt, int64(arg.PageNumber), int64(1000))
|
||||
return uInfo
|
||||
|
||||
//if total < 1000 {
|
||||
// uInfo, err = usermod.FindMany(cond, opt, int64(0), int64(1000))
|
||||
// return uInfo
|
||||
//}
|
||||
////创建多个协程去拉取
|
||||
//const goRoutineCnt int = 60
|
||||
//var wg sync.WaitGroup
|
||||
//size := total / int64(goRoutineCnt)
|
||||
//wg.Add(goRoutineCnt)
|
||||
//var mData [goRoutineCnt][]*usermod.User
|
||||
//for i := 0; i < goRoutineCnt-1; i++ {
|
||||
// common.GoParam(i, func(i int) {
|
||||
// defer wg.Done()
|
||||
// skip := int64(i) * size
|
||||
// mData[i], err = usermod.FindMany(cond, opt, int64(skip), int64(size))
|
||||
// })
|
||||
//}
|
||||
//common.Go(func() {
|
||||
// defer wg.Done()
|
||||
// skip := int64(goRoutineCnt-1) * size
|
||||
// mData[goRoutineCnt-1], err = usermod.FindMany(cond, opt, int64(skip), int64(size+size))
|
||||
//})
|
||||
//wg.Wait()
|
||||
//for i := 0; i < goRoutineCnt; i++ {
|
||||
// uInfo = append(uInfo, mData[i]...)
|
||||
//}
|
||||
//return uInfo
|
||||
}
|
||||
|
||||
func setArray2Map(datas []playlgmod.UIDCount) map[uint64]int {
|
||||
m := make(map[uint64]int)
|
||||
for _, d := range datas {
|
||||
m[d.UID] = d.Count
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func calWatchedVideoCnt(uids []uint64) []playlgmod.UIDCount {
|
||||
le := len(uids)
|
||||
if le < 1000 {
|
||||
datas, _ := playlgmod.HasWatchedVideoCnt(uids)
|
||||
return datas
|
||||
}
|
||||
//创建多个协程去拉取
|
||||
const goRoutineCnt = 10
|
||||
var wg sync.WaitGroup
|
||||
var mData [goRoutineCnt][]playlgmod.UIDCount
|
||||
size := le / goRoutineCnt
|
||||
wg.Add(goRoutineCnt)
|
||||
for i := 0; i < goRoutineCnt-1; i++ {
|
||||
common.GoParam(i, func(i int) {
|
||||
defer wg.Done()
|
||||
begin := i * size
|
||||
end := begin + size - 1
|
||||
mData[i], _ = playlgmod.HasWatchedVideoCnt(uids[begin:end])
|
||||
})
|
||||
}
|
||||
common.Go(func() {
|
||||
defer wg.Done()
|
||||
begin := (goRoutineCnt - 1) * size
|
||||
end := le - 1
|
||||
mData[goRoutineCnt-1], _ = playlgmod.HasWatchedVideoCnt(uids[begin:end])
|
||||
})
|
||||
wg.Wait()
|
||||
datas := []playlgmod.UIDCount{}
|
||||
for i := 0; i < goRoutineCnt; i++ {
|
||||
datas = append(datas, mData[i]...)
|
||||
}
|
||||
return datas
|
||||
}
|
||||
|
||||
//
|
||||
//func encodeUsers(users []*usermod.User, videoCntMap map[uint64]int, unDealVideoCntMap map[uint64]int) []usermod.ExportUser {
|
||||
// usersLen := len(users)
|
||||
// uids := make([]uint64, 0, usersLen)
|
||||
// uInfos := make([]usermod.ExportUser, 0, usersLen)
|
||||
// for _, u := range users {
|
||||
// if u != nil {
|
||||
// user := usermod.ExportUser{
|
||||
// UID: u.UID,
|
||||
// DevID: u.DevID,
|
||||
// DevType: u.DevType,
|
||||
// RegisterIP: u.RegisterIP,
|
||||
// Mobile: u.Mobile,
|
||||
// Gender: u.Gender,
|
||||
// Channel: u.DistrictCode,
|
||||
// Name: u.Name,
|
||||
// PromotionCode: u.PromCode,
|
||||
// Summary: u.Summary,
|
||||
// Region: u.Region,
|
||||
// Birthday: u.Birthday,
|
||||
// VipLevel: u.VipLevel,
|
||||
// VipExpireDate: u.VipExpireDate,
|
||||
// CreatedAt: u.CreatedAt,
|
||||
// MobileBindAt: u.MobileBindAt,
|
||||
// HasLocked: u.HasLocked,
|
||||
// HasBanned: u.HasBanned,
|
||||
// TotalVideoCnt: videoCntMap[u.UID],
|
||||
// UndealVideoCnt: unDealVideoCntMap[u.UID],
|
||||
// LastVisitAt: u.LastVisitAt,
|
||||
// }
|
||||
// uInfos = append(uInfos, user)
|
||||
// uids = append(uids, u.UID)
|
||||
// }
|
||||
// }
|
||||
// wCnt := setArray2Map(calWatchedVideoCnt(uids))
|
||||
// for i, u := range uInfos {
|
||||
// uInfos[i].WatchCount = wCnt[u.UID]
|
||||
// }
|
||||
// return uInfos
|
||||
//}
|
||||
|
||||
func getUIDs(users []*usermod.User) []uint64 {
|
||||
uids := make([]uint64, 0, len(users))
|
||||
for _, v := range users {
|
||||
if v == nil {
|
||||
continue
|
||||
}
|
||||
uids = append(uids, v.UID)
|
||||
}
|
||||
return uids
|
||||
}
|
||||
|
||||
// Export doc
|
||||
// @Summary 导出文件
|
||||
// @Description 导出excel文件
|
||||
// @Tags Web-Export
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param fileType query integer true "导出文件的类型"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/export/:fileType [get]
|
||||
func UserList(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg userListReq
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "user List arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
if code := IsWithinWeek(arg.StartTime, arg.EndTime); code != stderr.Success {
|
||||
common.ServeJSON(c, code, code)
|
||||
return
|
||||
}
|
||||
err = export_task_mod.CreateTask(export_task_mod.ExportUserTask, manager, arg)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrExportFileFail, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, "成功")
|
||||
}
|
||||
|
||||
// IsWithinWeek 判断是否是一周内
|
||||
func IsWithinWeek(start *string, end *string) (code stderr.Code) {
|
||||
if start == nil || end == nil {
|
||||
return stderr.ErrTimeIsEmpty
|
||||
}
|
||||
startTime := timeutil.StrTimeToTime(*start)
|
||||
endTime := timeutil.StrTimeToTime(*end)
|
||||
hours := endTime.Sub(startTime).Hours()
|
||||
if hours > 24*7 {
|
||||
return stderr.ErrTimeWithinWeek
|
||||
}
|
||||
return stderr.Success
|
||||
}
|
||||
|
||||
// RechargeOrder doc
|
||||
// @Summary 导出文件
|
||||
// @Description 导出excel文件
|
||||
// @Tags Web-Export
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param fileType query integer true "导出文件的类型"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/export/rechargeOrder [get]
|
||||
func RechargeOrder(ctx *gin.Context) {
|
||||
var arg struct {
|
||||
common.StandQuery
|
||||
rchgordmod.RchgQueryReq
|
||||
}
|
||||
if err := ctx.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
//导出条数写死
|
||||
arg.StandQuery.PageNumber = 1
|
||||
arg.StandQuery.PageSize = 100000
|
||||
_, data, err := rchgordmod.FindRechargesOrders(common.StandQueryMap(arg.StandQuery, arg.RchgQueryReq))
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
exptData := make([]*rchgordmod.RchargeOrderExport, len(data))
|
||||
_100 := decimal.NewFromInt(100)
|
||||
for i, v := range data {
|
||||
exptData[i] = &rchgordmod.RchargeOrderExport{
|
||||
ID: v.ID,
|
||||
UID: v.UID,
|
||||
DevID: v.DevID,
|
||||
OID: v.OID,
|
||||
UserIP: v.UserIP,
|
||||
Name: v.Name,
|
||||
Tel: v.Tel,
|
||||
PayAct: v.PayAct,
|
||||
DevType: v.DevType,
|
||||
Amount: decimal.NewFromInt(v.Amount).Div(_100).StringFixed(4),
|
||||
Money: decimal.NewFromInt(v.Money).Div(_100).StringFixed(4),
|
||||
PayMoney: decimal.NewFromInt(v.PayMoney).Div(_100).StringFixed(4),
|
||||
RechargeType: v.RechargeType,
|
||||
ProductID: v.ProductID,
|
||||
VipID: v.VipID,
|
||||
Channel: v.Channel,
|
||||
Status: v.Status,
|
||||
StatusDesc: v.StatusDesc,
|
||||
ProgressAt: v.ProgressAt,
|
||||
FailureAt: v.FailureAt,
|
||||
SuccessAt: v.SuccessAt,
|
||||
PaymentAt: v.PaymentAt,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
SourcePage: v.SourcePage,
|
||||
SourceRef: v.SourceRef,
|
||||
VideoID: v.VideoID,
|
||||
ActivityID: v.ActivityID,
|
||||
ExperimentID: v.ExperimentID,
|
||||
ExperimentVariant: v.ExperimentVariant,
|
||||
SessionID: v.SessionID,
|
||||
}
|
||||
}
|
||||
fpath, err := exportser.RechargeOrderExport(exptData)
|
||||
if err != nil {
|
||||
log.Warn("request multipart wrong ", log.E(err))
|
||||
common.ServeJSON(ctx, stderr.ErrExportFileFail, err.Error())
|
||||
return
|
||||
}
|
||||
ctx.Writer.WriteHeader(http.StatusOK)
|
||||
ctx.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filepath.Base(fpath)))
|
||||
ctx.Header("Content-Type", "application/octet-stream")
|
||||
ctx.File(fpath)
|
||||
}
|
||||
|
||||
// WithdrawOrder doc
|
||||
// @Summary 导出文件
|
||||
// @Description 导出excel文件
|
||||
// @Tags Web-Export
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param fileType query integer true "导出文件的类型"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/export/withdrawOrder [get]
|
||||
func WithdrawOrder(ctx *gin.Context) {
|
||||
var arg struct {
|
||||
common.StandQuery
|
||||
wdordmod.WithdrawWebQueryReq
|
||||
}
|
||||
if err := ctx.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
//导出条数写死
|
||||
arg.StandQuery.PageNumber = 1
|
||||
arg.StandQuery.PageSize = 100000
|
||||
_, data, err := withdrawser.GetAllOrders(common.StandQueryMap(arg.StandQuery, arg.WithdrawWebQueryReq))
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
fpath, err := exportser.WithdrawOrderExport(data)
|
||||
if err != nil {
|
||||
log.Warn("request multipart wrong ", log.E(err))
|
||||
common.ServeJSON(ctx, stderr.ErrExportFileFail, err.Error())
|
||||
return
|
||||
}
|
||||
ctx.Writer.WriteHeader(http.StatusOK)
|
||||
ctx.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filepath.Base(fpath)))
|
||||
ctx.Header("Content-Type", "application/octet-stream")
|
||||
ctx.File(fpath)
|
||||
}
|
||||
|
||||
// GoldTurnover doc
|
||||
// @Summary 导出文件
|
||||
// @Description 导出excel文件
|
||||
// @Tags Web-Export
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param fileType query integer true "导出文件的类型"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/export/withdrawOrder [get]
|
||||
func GoldTurnover(ctx *gin.Context) {
|
||||
req := txnmod.CoinLogReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
m := make(map[string]interface{})
|
||||
if req.UID > 0 {
|
||||
m["uid"] = req.UID
|
||||
}
|
||||
if req.Balance == 1 {
|
||||
i := make(map[string]interface{})
|
||||
i["$gt"] = 0
|
||||
m["amount"] = i
|
||||
}
|
||||
if req.Balance == 2 {
|
||||
i := make(map[string]interface{})
|
||||
i["$lt"] = 0
|
||||
m["amount"] = i
|
||||
}
|
||||
if !req.End.IsZero() {
|
||||
i := make(map[string]interface{})
|
||||
i["$gte"] = req.Start
|
||||
i["$lt"] = req.End
|
||||
m["createdAt"] = i
|
||||
}
|
||||
if len(req.TranType) != 0 {
|
||||
m["tranType"] = req.TranType
|
||||
}
|
||||
infos, _, _, _ := txnmod.GetCoinLogs(1, 100000, m)
|
||||
fpath, err := exportser.GoldTurnoverExport(infos)
|
||||
if err != nil {
|
||||
log.Warn("request multipart wrong ", log.E(err))
|
||||
common.ServeJSON(ctx, stderr.ErrExportFileFail, err.Error())
|
||||
return
|
||||
}
|
||||
ctx.Writer.WriteHeader(http.StatusOK)
|
||||
ctx.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filepath.Base(fpath)))
|
||||
ctx.Header("Content-Type", "application/octet-stream")
|
||||
ctx.File(fpath)
|
||||
}
|
||||
|
||||
// VideoIncome doc
|
||||
// @Summary 导出文件
|
||||
// @Description 导出excel文件
|
||||
// @Tags Web-Export
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param fileType query integer true "导出文件的类型"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/export/withdrawOrder [get]
|
||||
func VideoIncome(ctx *gin.Context) {
|
||||
type Query struct {
|
||||
StartTime *time.Time `form:"startTime" json:"startTime" binding:""` //开始时间
|
||||
EndTime *time.Time `form:"endTime" json:"endTime" binding:""` //结束时间
|
||||
UID *uint64 `form:"uid" json:"uid" binding:""` //uid
|
||||
Vid *string `form:"vid" json:"vid" binding:""` //vid
|
||||
}
|
||||
var arg struct {
|
||||
commod.Page
|
||||
Query
|
||||
}
|
||||
if err := ctx.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "stat VideoEarnStats arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
endTime := time.Now()
|
||||
if arg.EndTime != nil {
|
||||
endTime = timerange.LocDayRange(*arg.EndTime).Head
|
||||
}
|
||||
startTime := time.Time{}
|
||||
if arg.StartTime != nil {
|
||||
startTime = timerange.LocDayRange(*arg.StartTime).Head
|
||||
}
|
||||
var vid *primitive.ObjectID
|
||||
if arg.Vid != nil {
|
||||
id, _ := primitive.ObjectIDFromHex(*arg.Vid)
|
||||
vid = &id
|
||||
}
|
||||
var vids []primitive.ObjectID
|
||||
if arg.UID != nil {
|
||||
list, _ := vidmod.FindMany((&vidmod.PublisherIDMatch{PublisherID: arg.UID}).New())
|
||||
vids = list.IDs()
|
||||
}
|
||||
limit := int64(100000)
|
||||
skip := int64(0)
|
||||
page, _ := statvidmod.VideoStatPages(skip, limit,
|
||||
statvidmod.SumDateGTEAndLTMatch{GTE: &startTime, LT: &endTime},
|
||||
statvidmod.VidMatch{Vid: vid},
|
||||
statvidmod.VidInMatch{Vids: vids},
|
||||
)
|
||||
fpath, err := exportser.VideoIncomeExport(page.List)
|
||||
if err != nil {
|
||||
log.Warn("request multipart wrong ", log.E(err))
|
||||
common.ServeJSON(ctx, stderr.ErrExportFileFail, err.Error())
|
||||
return
|
||||
}
|
||||
ctx.Writer.WriteHeader(http.StatusOK)
|
||||
ctx.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filepath.Base(fpath)))
|
||||
ctx.Header("Content-Type", "application/octet-stream")
|
||||
ctx.File(fpath)
|
||||
}
|
||||
|
||||
// OrderStat doc
|
||||
// @Summary 导出文件
|
||||
// @Description 导出excel文件
|
||||
// @Tags Web-Export
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param fileType query integer true "导出文件的类型"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/export/withdrawOrder [get]
|
||||
func OrderStat(ctx *gin.Context) {
|
||||
var args struct {
|
||||
Type *int `form:"type" json:"type"` //订单类型
|
||||
Channel *string `form:"channel" json:"channel"`
|
||||
Start *time.Time `form:"start" json:"start"`
|
||||
End *time.Time `form:"end" json:"end"`
|
||||
}
|
||||
if err := ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
endTime := time.Now()
|
||||
if args.End != nil {
|
||||
endTime = *args.End
|
||||
}
|
||||
var startTime time.Time
|
||||
if args.Start != nil {
|
||||
startTime = *args.Start
|
||||
}
|
||||
skip := int64(0)
|
||||
limit := int64(100000)
|
||||
mats := []statordermod.Matcher{
|
||||
(&statordermod.ChannelMatch{}).New(),
|
||||
(&statordermod.TypeMatch{}).New(),
|
||||
(&statordermod.SumDateGTEAndLTMatch{GTE: &startTime, LT: &endTime}).New(),
|
||||
}
|
||||
list, err := statordermod.List(nil, &skip, &limit, mats...)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
fpath, err := exportser.OrderStatExport(list)
|
||||
if err != nil {
|
||||
log.Warn("request multipart wrong ", log.E(err))
|
||||
common.ServeJSON(ctx, stderr.ErrExportFileFail, err.Error())
|
||||
return
|
||||
}
|
||||
ctx.Writer.WriteHeader(http.StatusOK)
|
||||
ctx.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filepath.Base(fpath)))
|
||||
ctx.Header("Content-Type", "application/octet-stream")
|
||||
ctx.File(fpath)
|
||||
}
|
||||
|
||||
// CodeList 导出兑换码
|
||||
func CodeList(ctx *gin.Context) {
|
||||
var param = exchcodemod.ListReqParam{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
data := exchcodeser.ExchangeCodes(param)
|
||||
fpath, err := exportser.ExchangeCodeExport(data)
|
||||
if err != nil {
|
||||
log.Warn("request multipart wrong ", log.E(err))
|
||||
common.ServeJSON(ctx, stderr.ErrExportFileFail, err.Error())
|
||||
return
|
||||
}
|
||||
ctx.Writer.WriteHeader(http.StatusOK)
|
||||
ctx.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filepath.Base(fpath)))
|
||||
ctx.Header("Content-Type", "application/octet-stream")
|
||||
ctx.File(fpath)
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package extctrl
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/constant/redisconst"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/maths"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/common/ysphone"
|
||||
"91porn-server/web/service/vidser"
|
||||
"91porn-server/web/webg"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 拓展功能接口 doc
|
||||
// @Summary 查看用户验证码
|
||||
// @Description 查看用户验证码
|
||||
// @Tags Ext-拓展功能
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param mobile formData string true "手机号"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/extend/viewCaptcha [get]
|
||||
func ViewCaptcha(ctx *gin.Context) {
|
||||
var args struct {
|
||||
Mobile string `form:"mobile" json:"mobile" binding:"required"`
|
||||
}
|
||||
if err := ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
args.Mobile = strings.TrimSpace(args.Mobile)
|
||||
args.Mobile = ysphone.FormatPhoneNumber(args.Mobile)
|
||||
redisKey := redisconst.MobileCaptchaKey(args.Mobile)
|
||||
redisCode, _ := webg.Redis.Get(redisKey)
|
||||
var captcha string
|
||||
if redisCode == nil {
|
||||
captcha = maths.RandDigits(constant.CaptchaLen)
|
||||
if err := webg.Redis.Set(redisKey, captcha, redisconst.MobileCaptchaExpire); err != nil {
|
||||
log.Error("SendCaptcha Save Redis error", log.Any("mobile", args.Mobile), log.E(err))
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
} else {
|
||||
captcha = *redisCode
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"captcha": captcha})
|
||||
}
|
||||
|
||||
// 从Server-file同步基础信息 doc
|
||||
// @Summary
|
||||
// @Description 从Server-file同步基础信息
|
||||
// @Tags Ext-拓展功能
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param mobile formData string true "手机号"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/extend/syncServerFile [post]
|
||||
func SyncServerFile(ctx *gin.Context) {
|
||||
var args struct {
|
||||
IDs []string `form:"ids" json:"ids" binding:"required"`
|
||||
Token string `form:"token" json:"token" binding:"required"`
|
||||
}
|
||||
if err := ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if args.Token != "q7ydjHVIVBYiTqQ&" {
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, nil)
|
||||
return
|
||||
}
|
||||
var successCnt, failCount int64
|
||||
failIds := make([]string, 0, len(args.IDs))
|
||||
for _, v := range args.IDs {
|
||||
code := vidser.SyncBaseInfoFromFs(v)
|
||||
if code != stderr.UpLoadFileComplete {
|
||||
failCount++
|
||||
failIds = append(failIds, v)
|
||||
continue
|
||||
}
|
||||
successCnt++
|
||||
}
|
||||
ctx.JSON(http.StatusOK, gin.H{"successCnt": successCnt, "failCount": failCount, "failIds": failIds})
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
package fictionctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/constant/redisconst"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/fictionmod"
|
||||
"91porn-server/web/webg"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// Get doc
|
||||
// @Summary
|
||||
// @Description 查询电子书
|
||||
// @Tags fiction
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /fiction/list [post]
|
||||
func List(ctx *gin.Context) {
|
||||
var p struct {
|
||||
fictionmod.QuerySelector
|
||||
commod.Page
|
||||
}
|
||||
if err := ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, total, err := fictionmod.StdFind(p.QuerySelector, p.Page)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{
|
||||
"list": data,
|
||||
"total": total,
|
||||
})
|
||||
}
|
||||
|
||||
// Insert doc
|
||||
// @Summary 新增
|
||||
// @Description 新增
|
||||
// @Tags fiction
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /fiction/add [post]
|
||||
func Insert(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
v := fictionmod.Fiction{}
|
||||
if err = ctx.ShouldBind(&v); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = fictionmod.InsertFiction(&v); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(v)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Fiction, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 修改
|
||||
// @Description 修改
|
||||
// @Tags fiction
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /fiction/edit [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
p := fictionmod.EditSelector{}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = fictionmod.UpdateFiction(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, "")
|
||||
return
|
||||
}
|
||||
redisKey := redisconst.DataCachKey(fictionmod.RedisSetKey, "FindfictionByType")
|
||||
_, _ = webg.Redis.Del(redisKey)
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Fiction, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除
|
||||
// @Description 删除
|
||||
// @Tags fiction
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData int true "fiction等级""
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /fiction/del [delete]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var p struct {
|
||||
ID string `json:"id" form:"id"`
|
||||
}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "")
|
||||
return
|
||||
}
|
||||
if err = fictionmod.RemoveFiction(p.ID); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, "")
|
||||
return
|
||||
}
|
||||
redisKey := redisconst.DataCachKey(fictionmod.RedisSetKey, "FindfictionByType")
|
||||
_, _ = webg.Redis.Del(redisKey)
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Fiction, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Get doc
|
||||
// @Summary
|
||||
// @Description 查询电子书
|
||||
// @Tags fiction
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /fiction/list [post]
|
||||
func Get(ctx *gin.Context) {
|
||||
var p struct {
|
||||
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"`
|
||||
}
|
||||
if err := ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := fictionmod.GetByID(p.ID)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package filterctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/filtermod"
|
||||
"91porn-server/web/service/filterser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 过滤词管理
|
||||
// @Description 过滤词列表
|
||||
// @Tags Web-WordsFilter
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param content query string false "搜索内容"
|
||||
// @Param pageNumber query integer true "评论id"
|
||||
// @Param pageSize query integer true "评论id"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/filter/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var param filtermod.WordListReq
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
log.Error("api web filter List bind param error", log.E(err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code, data, err := filterser.GetFilterWordList(param.Content, param.Page)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// Add doc
|
||||
// @Summary 过滤词管理
|
||||
// @Description 添加过滤词
|
||||
// @Tags Web-WordsFilter
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param words formData array true "过滤词数组"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/filter/add [post]
|
||||
func Add(ctx *gin.Context) {
|
||||
var param filtermod.WordAddReq
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
log.Error("api web filter Add bind param error", log.E(err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code, err := filterser.AddFilterWord(param.Words)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 过滤词管理
|
||||
// @Description 删除过滤词
|
||||
// @Tags Web-WordsFilter
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ids formData array true "过滤词id数组"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/filter/delete [delete]
|
||||
func Delete(ctx *gin.Context) {
|
||||
var param filtermod.WordDeleteReq
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
log.Error("api web filter Delete bind param error", log.E(err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code, err := filterser.DeleteFilterWords(param.IDS)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package goldcfgctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/goldcfgmod"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// 支付优惠配置 doc
|
||||
// @Summary 支付优惠配置新增
|
||||
// @Description 支付优惠新增
|
||||
// @Tags 支付-配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param amount formData integer true "基础货币额度"
|
||||
// @Param incrAmount formData integer false "增加的优惠额度 incrAmount与incTax 不可同时为空"
|
||||
// @Param incTax formData number false "按比率增加额外优惠额"
|
||||
// @Param type formData string true "充值方式"
|
||||
// @Param typeName formData string true "类型名称:支付宝,微信,代充"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /gold/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 := goldcfgmod.Incr{}
|
||||
if err := c.ShouldBind(&incr); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if incr.IncTax > 1 || incr.IncTax < 0 {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err = goldcfgmod.InsertOne(&incr); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbInsertError, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(&incr)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.GoldConfig, 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 id formData string true "id"
|
||||
// @Param amount formData integer false "基础货币额度"
|
||||
// @Param incrAmount formData integer false "增加的优惠额度"
|
||||
// @Param incTax formData number false "按比率增加额外优惠额"
|
||||
// @Param type formData string false "充值方式"
|
||||
// @Param typeName formData string false "类型名称:支付宝,微信,代充"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /gold/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 {
|
||||
ID primitive.ObjectID `json:"id" bson:"id" binding:"required"` //基础货币额度
|
||||
goldcfgmod.EditDoc
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if arg.IncTax != nil {
|
||||
if *arg.IncTax > 1 || *arg.IncTax < 0 {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
if _, err = goldcfgmod.Update(arg.ID, arg.EditDoc); err != nil {
|
||||
//判断是否有重复插入
|
||||
if strings.Contains(err.Error(), "E11000 duplicate key error") {
|
||||
common.ServeJSON(c, stderr.ErrDbUpdateError, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Failure, fmt.Errorf("goldcfgmod updateOne error: %+v", err))
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(&arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.GoldConfig, 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 amount formData integer true "基础货币额度"
|
||||
// @Param type formData string true "充值方式"
|
||||
// @Param typeName formData string true "类型名称:支付宝,微信,代充"
|
||||
// @Param pageNumber query integer true "当前页" mininum(1)
|
||||
// @Param pageSize query integer true "每页条数" mininum(1)
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /gold/cfg/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
param := goldcfgmod.ListParam{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "web gold config list arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
result, err := goldcfgmod.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 ids formData array true "ID数组"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /gold/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 {
|
||||
IDs []primitive.ObjectID `form:"ids" json:"ids" binding:"required"`
|
||||
}
|
||||
if err = ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if _, err = goldcfgmod.Delete(param.IDs); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(¶m)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.GoldConfig, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package imagetopctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/imagetopmod"
|
||||
"91porn-server/web/service/imagetopser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 获取置顶帖子列表
|
||||
func GetImageTopList(ctx *gin.Context) {
|
||||
req := imagetopmod.ImageTopListReq{}
|
||||
err := ctx.ShouldBind(&req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code, data := imagetopser.FindImageTopList(req)
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// 更新帖子置顶列表
|
||||
func UpdateImageTop(ctx *gin.Context) {
|
||||
req := imagetopmod.EditReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
//更新置顶帖子信息
|
||||
code, data := imagetopser.UpdateImageTop(req)
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// 置顶帖子列表
|
||||
func DeleteImageTop(ctx *gin.Context) {
|
||||
req := imagetopmod.DeleteReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
//删除置顶贴子
|
||||
code, data := imagetopser.DeleteImageTop(req)
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
Executable
+106
@@ -0,0 +1,106 @@
|
||||
package imgroupctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/imgroupser"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取im群组列表
|
||||
// @Description 获取im群组列表
|
||||
// @Tags 后台-im群组
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query imgroupser.WebListReq false "请求参数"
|
||||
// @Success 200 object imgroupser.WebListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/imgroup/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &imgroupser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Create doc
|
||||
// @Summary 新增im群组
|
||||
// @Description 新增im群组
|
||||
// @Tags 后台-im群组
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body imgroupser.WebCreateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/imgroup/create [post]
|
||||
func Create(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &imgroupser.WebCreateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 创建
|
||||
err = p.Create()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "im群组管理", "创建", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新im群组
|
||||
// @Description 更新im群组
|
||||
// @Tags 后台-im群组
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body imgroupser.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/imgroup/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &imgroupser.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "im群组管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
Executable
+106
@@ -0,0 +1,106 @@
|
||||
package imgroupmemberctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/imgroupmemberser"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取im群组成员列表
|
||||
// @Description 获取im群组成员列表
|
||||
// @Tags 后台-im群组成员
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query imgroupmemberser.WebListReq false "请求参数"
|
||||
// @Success 200 object imgroupmemberser.WebListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/imgroupmember/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &imgroupmemberser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Create doc
|
||||
// @Summary 新增im群组成员
|
||||
// @Description 新增im群组成员
|
||||
// @Tags 后台-im群组成员
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body imgroupmemberser.WebCreateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/imgroupmember/create [post]
|
||||
func Create(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &imgroupmemberser.WebCreateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 创建
|
||||
err = p.Create()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "im群组成员管理", "创建", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新im群组成员
|
||||
// @Description 更新im群组成员
|
||||
// @Tags 后台-im群组成员
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body imgroupmemberser.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/imgroupmember/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &imgroupmemberser.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "im群组成员管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
Executable
+142
@@ -0,0 +1,142 @@
|
||||
package immessagectrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/immessageser"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取im消息列表
|
||||
// @Description 获取im消息列表
|
||||
// @Tags 后台-im消息
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query immessageser.WebListReq false "请求参数"
|
||||
// @Success 200 object immessageser.WebListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/immessage/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &immessageser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Create doc
|
||||
// @Summary 新增im消息
|
||||
// @Description 新增im消息
|
||||
// @Tags 后台-im消息
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body immessageser.WebCreateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/immessage/create [post]
|
||||
func Create(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &immessageser.WebCreateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 创建
|
||||
err = p.Create()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "im消息管理", "创建", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新im消息
|
||||
// @Description 更新im消息
|
||||
// @Tags 后台-im消息
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body immessageser.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/immessage/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &immessageser.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "im消息管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除im消息
|
||||
// @Description 删除im消息
|
||||
// @Tags 后台-im消息
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body immessageser.WebDeleteReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/immessage/delete [post]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &immessageser.WebDeleteReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 删除
|
||||
err = p.Delete()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "im消息管理", "删除", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,459 @@
|
||||
package infmtctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/noticefmtmod"
|
||||
"91porn-server/web/service/infmtser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type Sender = noticefmtmod.Sender
|
||||
|
||||
type Receiver = noticefmtmod.Receiver
|
||||
|
||||
type NoticeType = noticefmtmod.NoticeType
|
||||
|
||||
type UIDSlice = noticefmtmod.UIDSlice
|
||||
|
||||
type TimeUnit = noticefmtmod.TimeUnit
|
||||
|
||||
type TimeSlice = noticefmtmod.TimeSlice
|
||||
|
||||
type ObjectID = primitive.ObjectID
|
||||
|
||||
type RegularNotice = noticefmtmod.RegularNotice
|
||||
|
||||
type PlanNotice = noticefmtmod.PlanNotice
|
||||
|
||||
type SpecifyNotice = noticefmtmod.SpecifyNotice
|
||||
|
||||
type MailNotice = noticefmtmod.MailNotice
|
||||
|
||||
type AfterRegistNotice = noticefmtmod.AfterRegistNotice
|
||||
|
||||
// NoticeList doc
|
||||
// @Summary 通知列表
|
||||
// @Description 通知列表
|
||||
// @Tags web-Notice
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param noticeCode query string false "通知码"
|
||||
// @Param title query string false "标题"
|
||||
// @Param noticeType query string false "通知类型"
|
||||
// @Param sender query string false "发送者"
|
||||
// @Param receiver query string false "接受者"
|
||||
// @Param enable query bool false "开关"
|
||||
// @Param pageNumber query int true "当前页"
|
||||
// @Param pageSize query int true "每页条数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "date": { "total":10, "list":[] }}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/infmt/notice/list [get]
|
||||
func NoticeList(c *gin.Context) {
|
||||
type Query struct {
|
||||
NoticeCode *string `form:"noticeCode" json:"noticeCode" binding:""` //通知码 唯一标记不同的通知计划,可代替_id,方便复制数据
|
||||
Title *string `form:"title" json:"title" binding:""` //标题
|
||||
NoticeType *NoticeType `form:"noticeType" json:"noticeType" binding:""` //通知类型
|
||||
Sender *Sender `form:"sender" json:"sender" binding:""` //发送者
|
||||
Receiver *Receiver `form:"receiver" json:"receiver" binding:""` //接受者
|
||||
Enable *bool `form:"enable" json:"enable" binding:""` //开关
|
||||
}
|
||||
var arg struct {
|
||||
commod.Page
|
||||
Query
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "infmtctrl NoticeList arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
titleMatch := infmtser.TitleMatch{Title: arg.Title}
|
||||
noticeCodeMatch := infmtser.NoticeCodeMatch{NoticeCode: arg.NoticeCode}
|
||||
noticeTypeMatch := infmtser.NoticeTypeMatch{NoticeType: arg.NoticeType}
|
||||
senderMatch := infmtser.SenderMatch{Sender: arg.Sender}
|
||||
receiverMatch := infmtser.ReceiverMatch{Receiver: arg.Receiver}
|
||||
enableMatch := infmtser.EnableMatch{Enable: arg.Enable}
|
||||
skip := int64((arg.PageNumber - 1) * arg.PageSize)
|
||||
limit := int64(arg.PageSize)
|
||||
page, err := infmtser.NoticePages(skip, limit, titleMatch, noticeCodeMatch, noticeTypeMatch, senderMatch, receiverMatch, enableMatch)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, "web infmtctrl NoticeList error: "+err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, page)
|
||||
}
|
||||
|
||||
// NoticeUpdate doc
|
||||
// @Summary 编辑通知
|
||||
// @Description 编辑通知
|
||||
// @Tags web-Notice
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ID formData string true "id"
|
||||
// @Param title query string false "标题"
|
||||
// @Param sender query string false "发送者"
|
||||
// @Param receiver query string false "接受者"
|
||||
// @Param enable query bool false "开关"
|
||||
// @Param uidList query array false "用户列表"
|
||||
// @Param content query string false "内容"
|
||||
// @Param remark query string false "备注"
|
||||
// @Param noticeType query string false "通知类型"
|
||||
// @Param startAt query string false "开始时间"
|
||||
// @Param timeUnit query string false "单位 分钟/小时/天/周"
|
||||
// @Param timeCount query int false "量"
|
||||
// @Param endAt query string false "结束时间"
|
||||
// @Param planCount query int false "执行次数"
|
||||
// @Param specifyTimeList query array false "指定执行时间数组"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/infmt/notice/update [post]
|
||||
func NoticeUpdate(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
type NoticeFMT struct {
|
||||
StartAt *time.Time `form:"startAt" json:"startAt" binding:""` //开始时间
|
||||
TimeUnit *TimeUnit `form:"timeUnit" json:"timeUnit" binding:""` //单位 分钟/小时/天/周
|
||||
TimeCount *int64 `form:"timeCount" json:"timeCount" binding:""` //量
|
||||
EndAt *time.Time `form:"endAt" json:"endAt" binding:""` //结束时间
|
||||
PlanCount *int64 `form:"planCount" json:"planCount" binding:""` //执行次数
|
||||
SpecifyTimeList TimeSlice `form:"specifyTimeList" json:"specifyTimeList" binding:""` //指定执行时间数组
|
||||
}
|
||||
type Update struct {
|
||||
Title *string `form:"title" json:"title" binding:""` //标题
|
||||
Sender *Sender `form:"sender" json:"sender" binding:""` //发送者
|
||||
Receiver *Receiver `form:"receiver" json:"receiver" binding:""` //接受者
|
||||
Enable *bool `form:"enable" json:"enable" binding:""` //开关
|
||||
UIDList UIDSlice `form:"uidList" json:"uidList" binding:""` //用户列表
|
||||
Content *string `form:"content" json:"content" binding:""` //内容
|
||||
Remark *string `form:"remark" json:"remark" binding:""` //备注
|
||||
NoticeType *NoticeType `form:"noticeType" json:"noticeType" binding:""` //通知类型
|
||||
NoticeFMT
|
||||
}
|
||||
var arg struct {
|
||||
ID ObjectID `form:"id" json:"id" binding:"required"`
|
||||
Update
|
||||
}
|
||||
if err = c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "web infmtctrl NoticeUpdate arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
updateDoc := noticefmtmod.UpdateDoc{
|
||||
Sender: arg.Sender,
|
||||
Receiver: arg.Receiver,
|
||||
UIDList: arg.UIDList,
|
||||
Title: arg.Title,
|
||||
Content: arg.Content,
|
||||
Enable: arg.Enable,
|
||||
Remark: arg.Remark,
|
||||
NoticeType: arg.NoticeType,
|
||||
}
|
||||
if arg.NoticeType != nil {
|
||||
switch *arg.NoticeType {
|
||||
case noticefmtmod.RegularNoticeType:
|
||||
updateDoc.RegularNotice = RegularNotice{
|
||||
StartAt: arg.StartAt,
|
||||
TimeUnit: arg.TimeUnit,
|
||||
TimeCount: arg.TimeCount,
|
||||
}
|
||||
case noticefmtmod.PlanNoticeType:
|
||||
updateDoc.PlanNotice = PlanNotice{
|
||||
StartAt: arg.StartAt,
|
||||
EndAt: arg.EndAt,
|
||||
PlanCount: arg.PlanCount,
|
||||
}
|
||||
case noticefmtmod.SpecifyNoticeType:
|
||||
updateDoc.SpecifyNotice = SpecifyNotice{
|
||||
SpecifyTimeList: arg.SpecifyTimeList,
|
||||
}
|
||||
case noticefmtmod.AfterRegistNoticeType:
|
||||
updateDoc.AfterRegistNotice = AfterRegistNotice{
|
||||
TimeUnit: arg.TimeUnit,
|
||||
TimeCount: arg.TimeCount,
|
||||
}
|
||||
}
|
||||
}
|
||||
if err = noticefmtmod.UpdateOne(arg.ID, updateDoc); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbUpdateError, "web infmtctrl NoticeUpdate error: "+err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.UserManageList, constant.Modify, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
|
||||
// NoticeAdd doc
|
||||
// @Summary 添加通知
|
||||
// @Description 添加通知
|
||||
// @Tags web-Notice
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param noticeType query string true "通知类型"
|
||||
// @Param title query string true "标题"
|
||||
// @Param sender query string true "发送者"
|
||||
// @Param receiver query string true "接受者"
|
||||
// @Param enable query bool true "开关"
|
||||
// @Param uidList query array false "用户列表"
|
||||
// @Param content query string false "内容"
|
||||
// @Param remark query string false "备注"
|
||||
// @Param startAt query string false "开始时间"
|
||||
// @Param timeUnit query string false "单位 分钟/小时/天/周"
|
||||
// @Param timeCount query int false "量"
|
||||
// @Param endAt query string false "结束时间"
|
||||
// @Param planCount query int false "执行次数"
|
||||
// @Param specifyTimeList query array false "指定执行时间数组"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/infmt/notice/add [post]
|
||||
func NoticeAdd(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
type NoticeFMT struct {
|
||||
StartAt *time.Time `form:"startAt" json:"startAt" binding:""` //开始时间
|
||||
TimeUnit *TimeUnit `form:"timeUnit" json:"timeUnit" binding:""` //单位 分钟/小时/天/周
|
||||
TimeCount *int64 `form:"timeCount" json:"timeCount" binding:""` //量
|
||||
EndAt *time.Time `form:"endAt" json:"endAt" binding:""` //结束时间
|
||||
PlanCount *int64 `form:"planCount" json:"planCount" binding:""` //执行次数
|
||||
SpecifyTimeList TimeSlice `form:"specifyTimeList" json:"specifyTimeList" binding:""` //指定执行时间数组
|
||||
}
|
||||
type Insert struct {
|
||||
NoticeType NoticeType `form:"noticeType" json:"noticeType" binding:"required"` //通知类型
|
||||
Title string `form:"title" json:"title" binding:"required"` //标题
|
||||
Sender Sender `form:"sender" json:"sender" binding:"required"` //发送者
|
||||
Receiver Receiver `form:"receiver" json:"receiver" binding:"required"` //接受者
|
||||
Enable *bool `form:"enable" json:"enable" binding:"required"` //开关
|
||||
UIDList UIDSlice `form:"uidList" json:"uidList" binding:""` //用户列表
|
||||
Content *string `form:"content" json:"content" binding:""` //内容
|
||||
Remark *string `form:"remark" json:"remark" binding:""` //备注
|
||||
NoticeFMT
|
||||
}
|
||||
var arg struct {
|
||||
Insert
|
||||
}
|
||||
if err = c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "web infmtctrl NoticeAdd arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
insertDoc := noticefmtmod.InsertDoc{
|
||||
Sender: arg.Sender,
|
||||
Receiver: arg.Receiver,
|
||||
UIDList: arg.UIDList,
|
||||
Title: arg.Title,
|
||||
NoticeType: arg.NoticeType,
|
||||
Enable: *arg.Enable,
|
||||
}
|
||||
insertDoc.NoticeCode = common.UUID()
|
||||
if arg.Content != nil {
|
||||
insertDoc.Content = *arg.Content
|
||||
}
|
||||
if arg.Remark != nil {
|
||||
insertDoc.Remark = *arg.Remark
|
||||
}
|
||||
switch arg.NoticeType {
|
||||
case noticefmtmod.RegularNoticeType:
|
||||
insertDoc.RegularNotice = RegularNotice{
|
||||
StartAt: arg.StartAt,
|
||||
TimeUnit: arg.TimeUnit,
|
||||
TimeCount: arg.TimeCount,
|
||||
}
|
||||
case noticefmtmod.PlanNoticeType:
|
||||
insertDoc.PlanNotice = PlanNotice{
|
||||
StartAt: arg.StartAt,
|
||||
EndAt: arg.EndAt,
|
||||
PlanCount: arg.PlanCount,
|
||||
}
|
||||
case noticefmtmod.SpecifyNoticeType:
|
||||
insertDoc.SpecifyNotice = SpecifyNotice{
|
||||
SpecifyTimeList: arg.SpecifyTimeList,
|
||||
}
|
||||
case noticefmtmod.AfterRegistNoticeType:
|
||||
insertDoc.AfterRegistNotice = AfterRegistNotice{
|
||||
TimeUnit: arg.TimeUnit,
|
||||
TimeCount: arg.TimeCount,
|
||||
}
|
||||
}
|
||||
sort.Sort(insertDoc.UIDList)
|
||||
if err = noticefmtmod.InsertOne(insertDoc); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbInsertError, "web infmtctrl NoticeAdd InsertOne error: "+err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.UserManageList, constant.Add, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
|
||||
// NoticeDel doc
|
||||
// @Summary 删除通知
|
||||
// @Description 删除通知
|
||||
// @Tags web-Notice
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ID formData string true "id"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/infmt/notice/delete [delete]
|
||||
func NoticeDel(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
ID ObjectID `form:"id" json:"id" binding:"required"`
|
||||
}
|
||||
if err = c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "web infmtctrl NoticeDel arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
if err = noticefmtmod.DeleteOne(arg.ID); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbDeleteError, "web infmtctrl NoticeDel DeleteOne error: "+err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.UserManageList, constant.Delete, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
|
||||
// MailList doc
|
||||
// @Summary 邮件通知列表
|
||||
// @Description 邮件通知列表
|
||||
// @Tags web-Mail
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param noticeCode query string false "通知码"
|
||||
// @Param title query string false "标题"
|
||||
// @Param receiver query string false "接受者"
|
||||
// @Param pageNumber query int true "当前页"
|
||||
// @Param pageSize query int true "每页条数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "date": { "total":10, "list":[] }}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/infmt/mail/list [get]
|
||||
func MailList(c *gin.Context) {
|
||||
type Query struct {
|
||||
NoticeCode *string `form:"noticeCode" json:"noticeCode" binding:""` //通知码 唯一标记不同的通知计划,可代替_id,方便复制数据
|
||||
Title *string `form:"title" json:"title" binding:""` //标题
|
||||
Receiver *Receiver `form:"receiver" json:"receiver" binding:""` //接受者
|
||||
}
|
||||
var arg struct {
|
||||
commod.Page
|
||||
Query
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "infmtctrl MailList arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
titleMatch := infmtser.TitleMatch{Title: arg.Title}
|
||||
noticeCodeMatch := infmtser.NoticeCodeMatch{NoticeCode: arg.NoticeCode}
|
||||
receiverMatch := infmtser.ReceiverMatch{Receiver: arg.Receiver}
|
||||
skip := int64((arg.PageNumber - 1) * arg.PageSize)
|
||||
limit := int64(arg.PageSize)
|
||||
page, err := infmtser.MailPages(skip, limit, titleMatch, noticeCodeMatch, receiverMatch)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, "web infmtctrl MailList error: "+err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, page)
|
||||
}
|
||||
|
||||
// MailAdd doc
|
||||
// @Summary 添加邮件
|
||||
// @Description 添加邮件
|
||||
// @Tags web-Mail
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param title query string true "标题"
|
||||
// @Param receiver query string true "接受者"
|
||||
// @Param content query string true "内容"
|
||||
// @Param uidList query array false "用户列表"
|
||||
// @Param remark query string false "备注"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/infmt/mail/add [post]
|
||||
func MailAdd(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
type Insert struct {
|
||||
Title string `form:"title" json:"title" binding:"required"` //标题
|
||||
Receiver Receiver `form:"receiver" json:"receiver" binding:"required"` //接受者
|
||||
Content string `form:"content" json:"content" binding:"required"` //内容
|
||||
UIDList UIDSlice `form:"uidList" json:"uidList" binding:""` //用户列表
|
||||
Remark *string `form:"remark" json:"remark" binding:""` //备注
|
||||
}
|
||||
var arg struct {
|
||||
Insert
|
||||
}
|
||||
if err = c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "web infmtctrl NoticeAdd arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
sendAt := time.Now()
|
||||
insertDoc := noticefmtmod.InsertDoc{
|
||||
NoticeCode: common.UUID(),
|
||||
NoticeType: noticefmtmod.MailNoticeType,
|
||||
Sender: noticefmtmod.System,
|
||||
Enable: true,
|
||||
Receiver: arg.Receiver,
|
||||
UIDList: arg.UIDList,
|
||||
Title: arg.Title,
|
||||
Content: arg.Content,
|
||||
MailNotice: MailNotice{SendAt: &sendAt},
|
||||
}
|
||||
if arg.Remark != nil {
|
||||
insertDoc.Remark = *arg.Remark
|
||||
}
|
||||
if err = noticefmtmod.InsertOne(insertDoc); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbInsertError, "web infmtctrl MailAdd InsertOne error: "+err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.UserManageList, constant.Add, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
|
||||
// MailDel doc
|
||||
// @Summary 删除邮件通知
|
||||
// @Description 删除邮件通知
|
||||
// @Tags web-Mail
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ID formData string true "id"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/infmt/mail/delete [delete]
|
||||
func MailDel(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
ID ObjectID `form:"id" json:"id" binding:"required"`
|
||||
}
|
||||
if err = c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "web infmtctrl MailDel arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
if err = noticefmtmod.DeleteOne(arg.ID); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbDeleteError, "web infmtctrl MailDel DeleteOne error: "+err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.UserManageList, constant.Delete, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package integral_config_ctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/integralconfigmod"
|
||||
"91porn-server/web/service/integralconfigser"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// QueryAll doc
|
||||
// @Summary 查询积分配置
|
||||
// @Description 查询积分配置
|
||||
// @Tags 积分配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData primitive.ObjectID false "积分配置id"
|
||||
// @Param status formData bool false "积分状态"
|
||||
// @Param page formData string true "当前页面"
|
||||
// @Param limit formData string true "页码"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/integral_config [get]
|
||||
func QueryAll(c *gin.Context) {
|
||||
var in integralconfigmod.QueryAllCond
|
||||
if err := c.ShouldBindQuery(&in); err != nil {
|
||||
log.Error(fmt.Sprintf("Query all integralconfigser param err%v\n", err))
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
data, err := integralconfigser.QueryAll(&in)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Query all integralconfigser err%v\n%d", data, err))
|
||||
common.ServeJSON(c, stderr.Failure, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, data)
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 修改积分配置
|
||||
// @Description 修改积分配置
|
||||
// @Tags 积分配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ID formData primitive.ObjectID true "文档id"
|
||||
// @Param name formData string false "积分名称"
|
||||
// @Param duration formData integer false "积分持续天数"
|
||||
// @Param desc formData integer false "描述"
|
||||
// @Param price formData integer false "积分价格"
|
||||
// @Param status formData boolean false "积分状态"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/integral_config [put]
|
||||
func Update(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var in integralconfigmod.EditCond
|
||||
if err = c.ShouldBind(&in); err != nil {
|
||||
log.Error(fmt.Sprintf("Update integralconfigser param err%v\n", err))
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
if err = integralconfigser.Edit(&in, manager); err != nil {
|
||||
log.Error(fmt.Sprintf("Update integralconfigser err%v\n", err))
|
||||
common.ServeJSON(c, stderr.Failure, nil)
|
||||
return
|
||||
}
|
||||
updateLog, _ := json.Marshal(in)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.IntegralConfig, constant.Modify, string(updateLog), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, stderr.Success.Msg())
|
||||
}
|
||||
|
||||
// Add doc
|
||||
// @Summary 新增积分配置
|
||||
// @Description 新增积分配置
|
||||
// @Tags 积分配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param name formData string true "积分名称"
|
||||
// @Param duration formData integer true "积分持续天数"
|
||||
// @Param desc formData integer false "描述"
|
||||
// @Param price formData integer true "积分价格"
|
||||
// @Param sortCode formData integer true "排序码"
|
||||
// @Param status formData boolean true "积分状态"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/integral_config [post]
|
||||
func Add(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var in integralconfigmod.AddCond
|
||||
if err = c.ShouldBind(&in); err != nil {
|
||||
log.Error(fmt.Sprintf("Add integralconfigser param err%v\n", err))
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
if code := integralconfigser.Add(&in, manager); code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("Add integralconfigser err%v\n", code))
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
updateLog, _ := json.Marshal(in)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.IntegralConfig, constant.Add, string(updateLog), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, stderr.Success.Msg())
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package integral_exchange_ctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/integralexcangemod"
|
||||
"91porn-server/web/service/integarl_exchange_ser"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// QueryAll doc
|
||||
// @Summary 查询兑换列表
|
||||
// @Description 查询兑换列表
|
||||
// @Tags 积分兑换列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData primitive.ObjectID false "积分兑换id"
|
||||
// @Param status formData bool false "状态"
|
||||
// @Param uid formData integer false "用户ID"
|
||||
// @Param pageNumber formData integer true "当前页面"
|
||||
// @Param pageSize formData integer true "页码"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/integral_exchange [get]
|
||||
func QueryAll(c *gin.Context) {
|
||||
var in integralexcangemod.WebListRequest
|
||||
if err := c.ShouldBindQuery(&in); err != nil {
|
||||
log.Error(fmt.Sprintf("Query all integralexchangeser param err%v\n", err))
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
data, err := integarl_exchange_ser.QueryAll(&in)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Query all integralexchangeser err%v\n%d", data, err))
|
||||
common.ServeJSON(c, stderr.Failure, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, data)
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 修改兑换列表
|
||||
// @Description 修改兑换列表
|
||||
// @Tags 积分兑换列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData primitive.ObjectID true "文档id"
|
||||
// @Param remark formData string false "拒绝理由"
|
||||
// @Param status formData integer false "状态 2、发货中 3、已发货 4、拒绝发货"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/integral_exchange [put]
|
||||
func Update(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var in integralexcangemod.EditCond
|
||||
if err = c.ShouldBind(&in); err != nil {
|
||||
log.Error(fmt.Sprintf("Update integralexchangeser param err%v\n", err))
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
if err = integarl_exchange_ser.Edit(&in, manager); err != nil {
|
||||
log.Error(fmt.Sprintf("Update integralexchangeser err:%v\n", err))
|
||||
common.ServeJSON(c, stderr.Failure, nil)
|
||||
return
|
||||
}
|
||||
updateLog, _ := json.Marshal(in)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.IntegralExchange, constant.Modify, string(updateLog), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, stderr.Success.Msg())
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package ipblockctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/constant/redisconst"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/ipblockmod"
|
||||
"91porn-server/web/webg"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// IPBlockAdd doc
|
||||
// @Summary 添加IP限制 类型
|
||||
// @Description 添加IP限制
|
||||
// @Tags WEB-IPBlock IP限制
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ip formData array true "ip"
|
||||
// @Param type formData string true "限制的类型"
|
||||
// @Param remark formData string false "备注"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/ipblock/add [post]
|
||||
func IPBlockAdd(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
p := ipblockmod.IPBlock{}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = ipblockmod.Insert(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
common.Go(func() {
|
||||
//加入到redis中
|
||||
_, _ = webg.Redis.SAdd(redisconst.IPBlockKey(string(p.Type)), p.IP)
|
||||
_, _ = webg.Redis.ExpireKey(redisconst.IPBlockKey(string(p.Type)), redisconst.IPBlockExpire)
|
||||
})
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.IPBlockList, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// IPBlockList doc
|
||||
// @Summary ip限制列表
|
||||
// @Description ip限制列表
|
||||
// @Tags WEB-IPBlock IP限制
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param type query string false "限制类型"
|
||||
// @Param pageNumber query integer true "当前页" mininum(1)
|
||||
// @Param pageSize query integer true "每页条数" mininum(1)
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/ipblock/list [get]
|
||||
func IpBlockList(ctx *gin.Context) {
|
||||
param := ipblockmod.ListParam{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "web ipblock List arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
result, err := ipblockmod.List(param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, result)
|
||||
}
|
||||
|
||||
// IPBlockDel doc
|
||||
// @Summary ip限制删除
|
||||
// @Description 删除ip限制
|
||||
// @Tags WEB-IPBlock IP限制
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData string true "id字符串"
|
||||
// @Param ip formData string true "ip地址"
|
||||
// @Param type formData string true "操作类型"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/ipblock/del [delete]
|
||||
func IPBlockDel(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
type Param struct {
|
||||
ID primitive.ObjectID `form:"id" json:"id" binding:"required"`
|
||||
Type string `form:"type" json:"type" binding:"required"`
|
||||
IP string `form:"ip" json:"ip" binding:"required"`
|
||||
}
|
||||
var args struct {
|
||||
Params []Param `form:"params" json:"params" binding:"required"`
|
||||
}
|
||||
if err = ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
objIds := make([]primitive.ObjectID, len(args.Params))
|
||||
for i, v := range args.Params {
|
||||
objIds[i] = v.ID
|
||||
}
|
||||
if err = ipblockmod.DeleteMany(objIds); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
common.Go(func() {
|
||||
for _, v := range args.Params {
|
||||
_, _ = webg.Redis.SRem(redisconst.IPBlockKey(v.Type), v.IP)
|
||||
}
|
||||
})
|
||||
log, _ := json.Marshal(args)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.IPBlockList, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// IPBlockEdit doc
|
||||
// @Summary ip限制修改
|
||||
// @Description IP限制修改
|
||||
// @Tags WEB-IPBlock IP限制
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData string true "记录id"
|
||||
// @Param ip formData string false "ip"
|
||||
// @Param type formData string true "限制的类型"
|
||||
// @Param remark formData string false "备注"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/ipblock/edit [post]
|
||||
func IPBlockEdit(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var args struct {
|
||||
ID primitive.ObjectID `form:"id" json:"id" binding:"required"`
|
||||
ipblockmod.IPBlockEdit
|
||||
}
|
||||
if err = ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = ipblockmod.Update(args.ID, args.IPBlockEdit); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, "")
|
||||
return
|
||||
}
|
||||
if args.IP != nil {
|
||||
common.Go(func() {
|
||||
_, _ = webg.Redis.SAdd(redisconst.IPBlockKey(string(*args.Type)), *args.IP)
|
||||
_, _ = webg.Redis.ExpireKey(redisconst.IPBlockKey(string(*args.Type)), redisconst.IPBlockExpire)
|
||||
})
|
||||
}
|
||||
log, _ := json.Marshal(args)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.IPBlockList, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package ipwhitectrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/ipwhitemod"
|
||||
"91porn-server/web/webg"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
// IPWhiteAdd doc
|
||||
// @Summary 添加IP白名单
|
||||
// @Description 添加IP白名单
|
||||
// @Tags WEB-IPBlock IP白名单
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param ip formData array true "ip"
|
||||
// @Param remark formData string false "备注"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/ipwhite/add [post]
|
||||
func IPWhiteAdd(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
p := ipwhitemod.IPWhite{}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
p.CreateUser = manager
|
||||
if err = ipwhitemod.Insert(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
common.Go(func() {
|
||||
//加入到redis中
|
||||
_, _ = webg.Redis.SAdd(constant.IPWhiteRedisKey, p.IP)
|
||||
})
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.IPWhiteList, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// IPWhiteList doc
|
||||
// @Summary ip白名单列表
|
||||
// @Description ip白名单列表
|
||||
// @Tags WEB-IPBlock IP白名单
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param type query string false "限制类型"
|
||||
// @Param pageNumber query integer true "当前页" mininum(1)
|
||||
// @Param pageSize query integer true "每页条数" mininum(1)
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/ipwhite/list [get]
|
||||
func IpWhiteList(ctx *gin.Context) {
|
||||
param := ipwhitemod.ListParam{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "web ipwhite List arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
result, err := ipwhitemod.List(param)
|
||||
if err != nil && err != mongo.ErrNoDocuments {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, result)
|
||||
}
|
||||
|
||||
// IPWhiteDel doc
|
||||
// @Summary ip白名单删除
|
||||
// @Description 删除ip白名单
|
||||
// @Tags WEB-IPWhite IP白名单
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData string true "id字符串"
|
||||
// @Param ip formData string true "ip地址"
|
||||
// @Param type formData string true "操作类型"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/ipwhite/del [delete]
|
||||
func IPWhiteDel(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
type Param struct {
|
||||
ID primitive.ObjectID `form:"id" json:"id" binding:"required"`
|
||||
IP string `form:"ip" json:"ip"`
|
||||
}
|
||||
var args struct {
|
||||
Params []Param `form:"params" json:"params" binding:"required"`
|
||||
}
|
||||
if err = ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
objIds := make([]primitive.ObjectID, len(args.Params))
|
||||
for i, v := range args.Params {
|
||||
objIds[i] = v.ID
|
||||
}
|
||||
filter := bson.M{"_id": bson.M{"$in": objIds}}
|
||||
ipWhiteList, _ := ipwhitemod.FindMany(filter)
|
||||
if err = ipwhitemod.DeleteMany(objIds); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
common.Go(func() {
|
||||
for _, v := range ipWhiteList {
|
||||
_, _ = webg.Redis.SRem(constant.IPWhiteRedisKey, v.IP)
|
||||
}
|
||||
})
|
||||
log, _ := json.Marshal(args)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.IPWhiteList, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// IPWhiteEdit doc
|
||||
// @Summary ip白名单修改
|
||||
// @Description IP白名单修改
|
||||
// @Tags WEB-IPWhite IP白名单
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData string true "记录id"
|
||||
// @Param ip formData string false "ip"
|
||||
// @Param type formData string true "限制的类型"
|
||||
// @Param remark formData string false "备注"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/admin/ipwhite/edit [post]
|
||||
func IPWhiteEdit(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var args struct {
|
||||
ID primitive.ObjectID `form:"id" json:"id" binding:"required"`
|
||||
ipwhitemod.IPWhiteEdit
|
||||
}
|
||||
if err = ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = ipwhitemod.Update(args.ID, args.IPWhiteEdit); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, "")
|
||||
return
|
||||
}
|
||||
if args.IP != nil {
|
||||
common.Go(func() {
|
||||
_, _ = webg.Redis.SAdd(constant.IPWhiteRedisKey, *args.IP)
|
||||
})
|
||||
}
|
||||
log, _ := json.Marshal(args)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.IPWhiteList, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package jingangctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/jingangmod"
|
||||
"91porn-server/web/service/jingangser"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List 金刚区 doc
|
||||
// @Summary 金刚区列表详情
|
||||
// @Description 金刚区列表详情
|
||||
// @Tags vipzz
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/jingang/list [get]
|
||||
func List(c *gin.Context) {
|
||||
var req jingangser.JingangListRequest
|
||||
if err := c.Bind(&req); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
skip := (req.PageNum - 1) * req.PageSize
|
||||
count, err := jingangmod.GetAllJingangCount(nil)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
if uint64(count) <= skip {
|
||||
common.ServeJSON(c, stderr.Success, struct {
|
||||
List interface{} `json:"list"`
|
||||
Total int64 `json:"total"`
|
||||
HasNext bool `json:"hasNext"`
|
||||
}{
|
||||
List: nil,
|
||||
Total: count,
|
||||
HasNext: false,
|
||||
})
|
||||
return
|
||||
}
|
||||
limit := req.PageSize + 1
|
||||
jingangList, err := jingangmod.GetAllJingangList(nil, skip, limit)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
hasNext := false
|
||||
if uint64(len(jingangList)) > req.PageSize {
|
||||
jingangList = jingangList[:req.PageSize]
|
||||
hasNext = true
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, struct {
|
||||
List interface{} `json:"list"`
|
||||
Total int64 `json:"total"`
|
||||
HasNext bool `json:"hasNext"`
|
||||
}{
|
||||
List: jingangList,
|
||||
Total: count,
|
||||
HasNext: hasNext,
|
||||
})
|
||||
}
|
||||
|
||||
// Update 金刚区 doc
|
||||
// @Summary 更新金刚区区块
|
||||
// @Description 更新金刚区区块
|
||||
// @Tags vipzz
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData string true "被更新的金刚区块id 必需参数"
|
||||
// @Param name formData string true "金刚区块名称"
|
||||
// @Param img formData string true "图片地址"
|
||||
// @Param desc formData string true "说明"
|
||||
// @Param link_type formData string true "1 内部链接; 2 外部链接"
|
||||
// @Param link_url formData string true "链接地址"
|
||||
// @Param sort formData integer true " 排序"
|
||||
// @Param status formData integer true " 1 正常; 2 禁用"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/jingang/update [post]
|
||||
func Update(c *gin.Context) {
|
||||
var r jingangser.UpdateJingangReq
|
||||
if err := c.Bind(&r); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if r.ID.IsZero() {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "empty id")
|
||||
return
|
||||
}
|
||||
if err := jingangser.UpdateJingang(r); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// Add 金刚区 doc
|
||||
// @Summary 金刚区 添加金刚区区块
|
||||
// @Description 金刚区 添加金刚区区块
|
||||
// @Tags vipzz
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param name formData string true "金刚区块名称"
|
||||
// @Param img formData string true "图片地址"
|
||||
// @Param desc formData string true "说明"
|
||||
// @Param link_type formData string true "1 内部链接; 2 外部链接"
|
||||
// @Param link_url formData string true "链接地址"
|
||||
// @Param sort formData integer true " 排序"
|
||||
// @Param status formData integer true " 1 正常; 2 禁用"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/jingang/add [post]
|
||||
func Add(c *gin.Context) {
|
||||
var r jingangser.AddJingangReq
|
||||
if err := c.Bind(&r); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if r.Name == "" {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "empty name")
|
||||
return
|
||||
}
|
||||
if _, err := jingangser.AddJingang(r); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// Delete 金刚区 doc
|
||||
// @Summary 金刚区 删除金刚区块
|
||||
// @Description 金刚区 删除金刚区块
|
||||
// @Tags vipzz
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData string true "Id必需参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/jingang/delete [post]
|
||||
func Delete(c *gin.Context) {
|
||||
var r jingangser.DeleteJingangReq
|
||||
if err := c.Bind(&r); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if r.ID.IsZero() {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "empty id")
|
||||
return
|
||||
}
|
||||
if err := jingangser.DeleteJingang(r); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, nil)
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package laosijictrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/laosiji"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/web/service/laosijiser"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 老司机
|
||||
// @Summary 查询漫画列表
|
||||
// @Description 查询漫画列表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body laosiji.ComicsSearchListReq true "参数列表"
|
||||
// @Success 200 {object} laosiji.ComicsSearchListResp "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/web/admin/laosiji/comics/search [POST]
|
||||
func ComicsSearch(ctx *gin.Context) {
|
||||
param := laosiji.ComicsSearchListReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := laosijiser.ComicsSearch(ctx, param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 老司机
|
||||
// @Summary 查询漫画详情
|
||||
// @Description 查询漫画详情
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body laosiji.ComicsDetailReq true "参数列表"
|
||||
// @Success 200 {object} laosiji.ComicsDetailResp "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/web/admin/laosiji/comics/detail [POST]
|
||||
func ComicsDetail(ctx *gin.Context) {
|
||||
param := laosiji.ComicsDetailReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := laosijiser.ComicsDetail(ctx, param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrInterServerError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 老司机
|
||||
// @Summary 添加漫画到本地
|
||||
// @Description 添加漫画到本地
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body laosiji.ComicsSyncReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/web/admin/laosiji/comics/add [POST]
|
||||
func ComicsAdd(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
param := laosiji.ComicsSyncReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
hits, err := laosijiser.ComicsAddList(ctx, param, manager)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrInterServerError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, buildAddResp(hits))
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package laosijictrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/laosiji"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/web/service/laosijiser"
|
||||
"91porn-server/web/service/vidser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 老司机
|
||||
// @Summary 查询影片列表
|
||||
// @Description 查询影片列表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body laosiji.MovieSearchReq true "参数列表"
|
||||
// @Success 200 {object} laosiji.MovieSearchResp "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/web/admin/laosiji/movie/search [POST]
|
||||
func MovieSearch(ctx *gin.Context) {
|
||||
param := laosiji.MovieSearchReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := laosijiser.MovieSearch(ctx, param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 老司机
|
||||
// @Summary 查询影片详情
|
||||
// @Description 查询影片详情
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body laosiji.MovieDetailReq true "参数列表"
|
||||
// @Success 200 {object} laosiji.MovieDetailResp "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/web/admin/laosiji/movie/detail [POST]
|
||||
func MovieDetail(ctx *gin.Context) {
|
||||
param := laosiji.MovieDetailReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := laosijiser.MovieDetail(ctx, param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 老司机
|
||||
// @Summary 添加影片到本地
|
||||
// @Description 添加影片到本地
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body laosiji.MovieAddListReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/web/admin/laosiji/movie/add [POST]
|
||||
func MovieAdd(ctx *gin.Context) {
|
||||
param := laosiji.MovieAddListReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
hits, err := laosijiser.MovieAddList(ctx, param, manager)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, buildAddResp(hits))
|
||||
}
|
||||
|
||||
// buildAddResp 老司机 *Add 接口统一应答结构:data 中带 sensitiveHits 与提示文案
|
||||
// hits 为空时也返回,便于前端固定字段读取
|
||||
func buildAddResp(hits []vidser.SensitiveHit) gin.H {
|
||||
resp := gin.H{
|
||||
"sensitiveHits": hits,
|
||||
}
|
||||
if len(hits) > 0 {
|
||||
resp["sensitiveTip"] = vidser.SensitiveForcedOfflineTip
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package laosijictrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/laosiji"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/web/service/laosijiser"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 老司机
|
||||
// @Summary 查询小说列表
|
||||
// @Description 查询小说列表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body laosiji.NovelSearchListReq true "参数列表"
|
||||
// @Success 200 {object} laosiji.NovelSearchListResp "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/web/admin/laosiji/novel/search [POST]
|
||||
func NovelSearch(ctx *gin.Context) {
|
||||
param := laosiji.NovelSearchListReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := laosijiser.NovelSearch(ctx, param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 老司机
|
||||
// @Summary 查询小说详情
|
||||
// @Description 查询小说详情
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body laosiji.NovelDetailReq true "参数列表"
|
||||
// @Success 200 {object} laosiji.NovelDetailResp "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/web/admin/laosiji/novel/detail [POST]
|
||||
func NovelDetail(ctx *gin.Context) {
|
||||
param := laosiji.NovelDetailReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := laosijiser.NovelDetail(ctx, param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 老司机
|
||||
// @Summary 添加小说到本地
|
||||
// @Description 添加小说到本地
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body laosiji.NovelAddListReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/web/admin/laosiji/novel/add [POST]
|
||||
func NovelAdd(ctx *gin.Context) {
|
||||
param := laosiji.NovelAddListReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
err = laosijiser.NovelAddList(ctx, param, manager)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package laosijictrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/laosiji"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/web/service/laosijiser"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 老司机
|
||||
// @Summary 查询帖子列表
|
||||
// @Description 查询帖子列表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body laosiji.PostSearchListReq true "参数列表"
|
||||
// @Success 200 {object} laosiji.PostSearchListResp "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/web/admin/laosiji/post/search [POST]
|
||||
func PostSearch(ctx *gin.Context) {
|
||||
param := laosiji.PostSearchListReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := laosijiser.PostSearch(ctx, param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrInterServerError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 老司机
|
||||
// @Summary 查询帖子详情
|
||||
// @Description 查询帖子详情
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body laosiji.PostDetailReq true "参数列表"
|
||||
// @Success 200 {object} laosiji.PostDetailResp "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/web/admin/laosiji/post/detail [POST]
|
||||
func PostDetail(ctx *gin.Context) {
|
||||
param := laosiji.PostDetailReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := laosijiser.PostDetail(ctx, param)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrInterServerError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 老司机
|
||||
// @Summary 添加帖子到本地
|
||||
// @Description 添加帖子到本地
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body laosiji.PostAddListReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/web/admin/laosiji/post/add [POST]
|
||||
func PostAdd(ctx *gin.Context) {
|
||||
param := laosiji.PostAddListReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
hits, err := laosijiser.PostAddList(ctx, param, manager)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrInterServerError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, buildAddResp(hits))
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package ldyctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/ldycfgmod"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// GetCfg doc
|
||||
// @Summary 获取落地页配置
|
||||
// @Description 获取落地页配置
|
||||
// @Tags 落地页
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {object} ldycfgmod.LdyCfg "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ldy/cfg [get]
|
||||
func GetCfg(ctx *gin.Context) {
|
||||
cfg := ldycfgmod.FindOne()
|
||||
common.ServeJSON(ctx, stderr.Success, cfg)
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新落地页配置
|
||||
// @Description 更新落地页配置
|
||||
// @Tags 落地页
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param param body ldycfgmod.LdyCfg true "参数列表"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ldy/update [post]
|
||||
func Update(c *gin.Context) {
|
||||
var arg struct {
|
||||
ID primitive.ObjectID `json:"id" binding:"required"`
|
||||
ldycfgmod.LdyCfgUpdateDoc
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "ldyctrl Update arg error: "+err.Error())
|
||||
return
|
||||
}
|
||||
if arg.ID.IsZero() {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "ldyctrl Update ID is zero")
|
||||
return
|
||||
}
|
||||
if err := ldycfgmod.UpsertOneByID(arg.ID, arg.LdyCfgUpdateDoc); err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, "ldyctrl Update failed: "+err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package locationctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/locmod"
|
||||
"91porn-server/web/service/locationser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// CityList doc
|
||||
// @Summary 获取城市列表
|
||||
// @Description 获取城市列表
|
||||
// @Tags web-视频管理
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param pageNumber query int true "当前页"
|
||||
// @Param pageSize query int true "每页条数"
|
||||
// @Param city query string false "过滤条件:城市"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "date": { "total":10, "list":[] }}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/vid/location/city/list [get]
|
||||
func CityList(c *gin.Context) {
|
||||
req := locmod.CityPageReq{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "hotCity city List arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
page, err := locationser.CityPages(req.City, req.PageNumber, req.PageSize)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, "city List error: "+err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, page)
|
||||
}
|
||||
|
||||
// CityUpdate doc
|
||||
// @Summary 编辑城市
|
||||
// @Description 编辑城市
|
||||
// @Tags web-视频管理
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param targetID formData string true "目标文档ID"
|
||||
// @Param cover formData string false "封面""
|
||||
// @Param fakeVisit formData int false "假播访问量"
|
||||
// @Param sortKey formData int false "排序键"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/vid/location/city/update [post]
|
||||
func CityUpdate(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
type Update struct {
|
||||
Cover *string `form:"cover" json:"cover" binding:""` //封面
|
||||
FakeVisit *int `form:"fakeVisit" json:"fakeVisit" binding:""` //播发假数据
|
||||
SortKey *int `form:"sortKey" json:"sortKey" binding:""`
|
||||
}
|
||||
var arg struct {
|
||||
TargetID string `form:"targetID" json:"targetID,omitempty" binding:"required"`
|
||||
Update
|
||||
}
|
||||
if err = c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "hotCity Update arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
doc := locmod.LocationDoc{
|
||||
Cover: arg.Cover,
|
||||
FakeVisit: arg.FakeVisit,
|
||||
SortKey: arg.SortKey,
|
||||
}
|
||||
targetID, err := primitive.ObjectIDFromHex(arg.TargetID)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err = locmod.UpdateToLocation(targetID, doc); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbUpdateError, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageCity, constant.Modify, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package locationctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/pageopt"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/locmod"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// HotCityList doc
|
||||
// @Summary 获取热门城市列表
|
||||
// @Description 获取热门城市列表
|
||||
// @Tags web-视频管理-HotCity
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param pageNumber query int true "当前页"
|
||||
// @Param pageSize query int true "每页条数"
|
||||
// @Param city query string false "过滤条件:城市"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "date": { "total":10, "list":[] }}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/vid/location/hotCity/list [get]
|
||||
func HotCityList(c *gin.Context) {
|
||||
type Query struct {
|
||||
City *string `form:"city" json:"city" bson:"city,omitempty"` //角色类型
|
||||
}
|
||||
var arg struct {
|
||||
commod.Page
|
||||
Query
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "hotCity List arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
match := &pageopt.AssignMatch{
|
||||
Key: "city",
|
||||
Val: arg.City,
|
||||
}
|
||||
sort := bson.D{{Key: "createdAt", Value: -1}}
|
||||
skip := int64((arg.PageNumber - 1) * arg.PageSize)
|
||||
limit := int64(arg.PageSize)
|
||||
page, err := locmod.HotCityPages(sort, skip, limit, match)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, "hotCity List error: "+err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, page)
|
||||
}
|
||||
|
||||
// HotCityUpdate doc
|
||||
// @Summary 编辑热门城市
|
||||
// @Description 编辑热门城市
|
||||
// @Tags web-视频管理-HotCity
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param targetID formData string true "目标文档ID"
|
||||
// @Param sortKey formData int false "排序键"
|
||||
// @Param enable formData bool false "使能"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/vid/location/hotCity/update [post]
|
||||
func HotCityUpdate(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
type Update struct {
|
||||
SortKey *int `form:"sortKey" json:"sortKey" binding:""`
|
||||
Enable *bool `form:"enable" json:"enable" binding:""`
|
||||
Province *string `form:"province" json:"province" binding:""`
|
||||
}
|
||||
var arg struct {
|
||||
TargetID string `form:"targetID" json:"targetID,omitempty" binding:"required"`
|
||||
Update
|
||||
}
|
||||
if err = c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "hotCity Update arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
cityDoc := locmod.HotCityDoc{
|
||||
SortKey: arg.SortKey,
|
||||
Enable: arg.Enable,
|
||||
Province: arg.Province,
|
||||
}
|
||||
targetID, err := primitive.ObjectIDFromHex(arg.TargetID)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err = locmod.UpdateTo(targetID, cityDoc); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbUpdateError, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageHotCity, constant.Modify, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
|
||||
// HotCityAdd doc
|
||||
// @Summary 新增热门城市
|
||||
// @Description 新增热门城市
|
||||
// @Tags web-视频管理-HotCity
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param city formData string true "城市"
|
||||
// @Param sortKey formData int true "排序"
|
||||
// @Param enable formData bool true "使能"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/vid/location/hotCity/add [post]
|
||||
func HotCityAdd(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
City *string `form:"city" json:"city" binding:"required"` //城市
|
||||
Province *string `form:"province" json:"province" binding:"required"` //省份
|
||||
SortKey *int `form:"sortKey" json:"sortKey" binding:"required"` //排序
|
||||
Enable *bool `form:"enable" json:"enable" binding:"required"` //使能
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "tone Add arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
doc := locmod.HotCityDoc{
|
||||
City: arg.City,
|
||||
Province: arg.Province,
|
||||
SortKey: arg.SortKey,
|
||||
Enable: arg.Enable,
|
||||
}
|
||||
if err = locmod.Insert(doc); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbInsertError, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageHotCity, constant.Add, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
|
||||
// HotCityDelete doc
|
||||
// @Summary 批量删除热门城市
|
||||
// @Description 批量删除热门城市
|
||||
// @Tags web-视频管理-HotCity
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param idArray formData array true "ID数组"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/vid/location/hotCity/delete [delete]
|
||||
func HotCityDelete(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
IDArray []string `form:"idArray" json:"idArray" binding:"required"`
|
||||
}
|
||||
if err = c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "hotCity Delete arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
idArray, err := common.IDArray(arg.IDArray)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err = locmod.DeleteMany(idArray); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbDeleteError, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoManageHotCity, constant.Delete, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package logctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/adminmod"
|
||||
"91porn-server/models/v/txnmod"
|
||||
"91porn-server/web/service/logser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func accountTransfer2Nick(infos []*operatorlgmod.WebOperatorLog) []*operatorlgmod.WebOperatorLog {
|
||||
accounts := make([]string, len(infos))
|
||||
for i, v := range infos {
|
||||
accounts[i] = v.Manager
|
||||
}
|
||||
mNick, err := adminmod.GetNickByAccount(accounts)
|
||||
if err != nil {
|
||||
return infos
|
||||
}
|
||||
for _, v := range infos {
|
||||
v.Manager = mNick[v.Manager]
|
||||
}
|
||||
return infos
|
||||
}
|
||||
|
||||
// GetRechargeGoldLog doc
|
||||
// @Summary 获取用户金币日志
|
||||
// @Description 获取用户金币日志
|
||||
// @Tags log
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param pageNumber formData integer true "查询页码"
|
||||
// @Param pageSize formData integer true "页码大小"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/log/gold [get]
|
||||
func GetRechargeGoldLog(ctx *gin.Context) {
|
||||
req := txnmod.CoinLogReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
m := make(map[string]interface{})
|
||||
if req.UID > 0 {
|
||||
m["uid"] = req.UID
|
||||
}
|
||||
if req.Balance == 1 {
|
||||
i := make(map[string]interface{})
|
||||
i["$gt"] = 0
|
||||
m["amount"] = i
|
||||
}
|
||||
if req.Balance == 2 {
|
||||
i := make(map[string]interface{})
|
||||
i["$lt"] = 0
|
||||
m["amount"] = i
|
||||
}
|
||||
if !req.End.IsZero() {
|
||||
i := make(map[string]interface{})
|
||||
i["$gte"] = req.Start
|
||||
i["$lt"] = req.End
|
||||
m["createdAt"] = i
|
||||
}
|
||||
if len(req.TranType) != 0 {
|
||||
m["tranType"] = req.TranType
|
||||
}
|
||||
if req.DistrictCode != "" {
|
||||
m["districtCode"] = req.DistrictCode
|
||||
}
|
||||
code, data := logser.GetRechargeGoldLog(m, req.PageNumber, req.PageSize)
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// GetRechargeGoldTranType doc
|
||||
// @Summary 获取用户金币类型
|
||||
// @Description获取用户金币类型
|
||||
// @Tags log
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/log/goldType [get]
|
||||
func GetRechargeGoldTranType(ctx *gin.Context) {
|
||||
data, err := txnmod.GetTranTypes()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"list": data})
|
||||
}
|
||||
|
||||
// GetOperatorLog doc
|
||||
// @Summary 获取后台操作日志
|
||||
// @Description 获取后台操作日志
|
||||
// @Tags log
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param pageNumber formData integer true "查询页码"
|
||||
// @Param pageSize formData integer true "页码大小"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/log/operator [get]
|
||||
func GetOperatorLog(ctx *gin.Context) {
|
||||
if _, err := common.GetAdminAct(ctx); err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := operatorlgmod.OperatorListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if len(req.Manager) != 0 {
|
||||
account, err := adminmod.GetNameByNick(req.Manager)
|
||||
if err != nil {
|
||||
req.Manager = ""
|
||||
} else {
|
||||
req.Manager = account
|
||||
}
|
||||
}
|
||||
infos, total, err := operatorlgmod.GetOperatorLog(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
infos = accountTransfer2Nick(infos)
|
||||
common.ServeJSON(ctx, stderr.Success, operatorlgmod.OperatorListResp{Infos: infos, Total: total})
|
||||
}
|
||||
|
||||
// ModifyOperatorLog doc
|
||||
// @Summary 修改后台操作日志
|
||||
// @Description 修改后台操作日志
|
||||
// @Tags log
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param pageNumber formData integer true "查询页码"
|
||||
// @Param pageSize formData integer true "页码大小"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/log/operator/modify [post]
|
||||
func ModifyOperatorLog(ctx *gin.Context) {
|
||||
req := operatorlgmod.OperatorModifyReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if err := operatorlgmod.EditRemarks(req.ID, req.Remarks); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package media_resource
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/web/service/mediaresourceser"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取媒资库动漫列表列表
|
||||
// @Description 获取媒资库动漫列表列表
|
||||
// @Tags 后台-动漫列表-媒体库相关
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediaresourceser.MediaListReq false "请求参数"
|
||||
// @Success 200 object mediaresourceser.MediaListResp "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/mediaResource/media/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &mediaresourceser.MediaListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err := req.Validate(); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// ContentList doc
|
||||
// @Summary 获取媒资库动漫子集列表列表
|
||||
// @Description 获取媒资库动漫子集列表列表
|
||||
// @Tags 后台-动漫列表-媒体库相关
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediaresourceser.MediaContentListReq false "请求参数"
|
||||
// @Success 200 object mediaresourceser.MediaContentListResp "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/mediaResource/media/content_list [get]
|
||||
func ContentList(ctx *gin.Context) {
|
||||
var req = &mediaresourceser.MediaContentListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err := req.Validate(); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// UseMedia doc
|
||||
// @Summary 使用媒资库动漫
|
||||
// @Description 使用媒资库动漫
|
||||
// @Tags 后台-动漫列表-媒体库相关
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param q body mediaresourceser.MediaUseReq false "请求参数"
|
||||
// @Router /api/web/admin/mediaResource/media/use [post]
|
||||
func UseMedia(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
var p mediaresourceser.MediaUseReq
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if err = p.Validate(); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = p.Use(manager); err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// IgnoreMedia doc
|
||||
// @Summary 忽略媒资库动漫
|
||||
// @Description 忽略媒资库动漫
|
||||
// @Tags 后台-动漫列表-媒体库相关
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param q body mediaresourceser.MediaIgnoreReq false "请求参数"
|
||||
// @Router /api/web/admin/mediaResource/media/ignore [post]
|
||||
func IgnoreMedia(ctx *gin.Context) {
|
||||
var p mediaresourceser.MediaIgnoreReq
|
||||
if err := ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if err := p.Ignore(); err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// SyncMedia doc
|
||||
// @Summary 同步媒资库动漫
|
||||
// @Description 同步媒资库动漫
|
||||
// @Tags 后台-动漫列表-媒体库相关
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Router /api/web/admin/mediaResource/media/sync [post]
|
||||
func SyncMedia(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
p := &mediaresourceser.MediaSyncReq{}
|
||||
p.Sync(manager)
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
Executable
+236
@@ -0,0 +1,236 @@
|
||||
package mediacontentctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/models/v/mediamod"
|
||||
"91porn-server/web/service/mediaser"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/mediacontentser"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取动漫内容列表列表
|
||||
// @Description 获取动漫内容列表列表
|
||||
// @Tags 后台-动漫内容列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediacontentser.WebListReq false "请求参数"
|
||||
// @Success 200 object mediacontentser.WebListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media_content/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &mediacontentser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Create doc
|
||||
// @Summary 新增动漫内容列表
|
||||
// @Description 新增动漫内容列表
|
||||
// @Tags 后台-动漫内容列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediacontentser.WebCreateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media_content/create [post]
|
||||
func Create(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &mediacontentser.WebCreateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Create media content param err:%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if p.EpisodeNumber == 0 {
|
||||
log.Error("Create media content EpisodeNumber == 0")
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "剧集编号必须大于0")
|
||||
return
|
||||
}
|
||||
if p.MediaType == mediamod.MediaTypeDrama {
|
||||
code := mediaser.SendBaseInfo2AWs(mediamod.SendBaseInfo2AWsReq{
|
||||
SourceID: p.SourceID,
|
||||
Md5: p.Md5,
|
||||
Title: p.Name,
|
||||
Filename: p.Filename,
|
||||
})
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(ctx, code, "视频资源登记失败")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 创建
|
||||
err, vid := p.Create(manager)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Create media content err:%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
if p.MediaType == mediamod.MediaTypeVideo {
|
||||
code := mediaser.SendBaseInfo2AWs(mediamod.SendBaseInfo2AWsReq{
|
||||
SourceID: p.SourceID,
|
||||
Md5: p.Md5,
|
||||
Title: p.Name,
|
||||
Filename: p.Filename,
|
||||
})
|
||||
if code != stderr.Success {
|
||||
_, _ = mediaser.DeleteManyByTTL(vid)
|
||||
}
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "动漫内容列表管理", "创建", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"contentId": vid})
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新动漫内容列表
|
||||
// @Description 更新动漫内容列表
|
||||
// @Tags 后台-动漫内容列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediacontentser.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media_content/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &mediacontentser.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update(manager)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "动漫内容列表管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// BatchUpdate doc
|
||||
// @Summary 批量更新动漫内容
|
||||
// @Description 批量更新动漫内容
|
||||
// @Tags 后台-动漫内容列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediacontentser.WebBatchUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media_content/batch/update [post]
|
||||
func BatchUpdate(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &mediacontentser.WebBatchUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if _, err = p.ValidatedIDs(); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update(manager)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "动漫内容列表管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除动漫内容列表
|
||||
// @Description 删除动漫内容列表
|
||||
// @Tags 后台-动漫内容列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediacontentser.WebDeleteReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media_content/delete [post]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &mediacontentser.WebDeleteReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 删除
|
||||
err = p.Delete()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "动漫内容列表管理", "删除", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// ViewMedia doc
|
||||
// @Summary 查看媒体状态
|
||||
// @Description 查看媒体状态
|
||||
// @Tags 后台-动漫内容列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData string true "查看媒体id"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/media/view/:id [get]
|
||||
func ViewMedia(ctx *gin.Context) {
|
||||
id := ctx.Param("id")
|
||||
if id == "" {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := mediacontentser.ViewMediaFromFs(id)
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
Executable
+313
@@ -0,0 +1,313 @@
|
||||
package mediactrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/mediamod"
|
||||
"91porn-server/web/service/mediaser"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取动漫列表列表
|
||||
// @Description 获取动漫列表列表
|
||||
// @Tags 后台-动漫列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediaser.WebListReq false "请求参数"
|
||||
// @Success 200 object mediaser.WebListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &mediaser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
log.Error(fmt.Sprintf("Query media List param err:%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("media GetList err:%v", err))
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Find doc
|
||||
// @Summary 获取动漫信息
|
||||
// @Description 获取动漫信息
|
||||
// @Tags 后台-动漫列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediaser.WebFindMediaReq false "请求参数"
|
||||
// @Success 200 object mediaser.WebFindMediaRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media/find [get]
|
||||
func Find(ctx *gin.Context) {
|
||||
var req = &mediaser.WebFindMediaReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
log.Error(fmt.Sprintf("Query media find param err:%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetMediaByID()
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("media find err:%v", err))
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Create doc
|
||||
// @Summary 新增动漫列表
|
||||
// @Description 新增动漫列表
|
||||
// @Tags 后台-动漫列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediaser.WebCreateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media/create [post]
|
||||
func Create(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &mediaser.WebCreateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("media create param err:%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = p.Validate(); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 创建
|
||||
code, resultID := p.Create(manager)
|
||||
if code != stderr.Success {
|
||||
if p.MediaType == mediamod.MediaTypeVideo {
|
||||
_, _ = mediaser.DeleteManyByTTL(resultID)
|
||||
}
|
||||
log.Error(fmt.Sprintf("media create err:%v\n", err))
|
||||
common.ServeJSON(ctx, code, resultID)
|
||||
return
|
||||
}
|
||||
if p.MediaType == mediamod.MediaTypeVideo {
|
||||
code = mediaser.SendBaseInfo2AWs(mediamod.SendBaseInfo2AWsReq{
|
||||
SourceID: p.SourceID,
|
||||
Md5: p.Md5,
|
||||
Title: p.EpisodeNumberName,
|
||||
PlayTime: p.PlayTime,
|
||||
MediaSize: p.MediaSize,
|
||||
Filename: p.Filename,
|
||||
Tags: p.Tags,
|
||||
})
|
||||
if code != stderr.Success {
|
||||
_, _ = mediaser.DeleteManyByTTL(resultID)
|
||||
}
|
||||
}
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "动漫列表管理", "创建", string(log), ctx.Request.URL.RequestURI())
|
||||
if p.MediaType == mediamod.MediaTypeDrama {
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"mediaId": resultID})
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新动漫列表
|
||||
// @Description 更新动漫列表
|
||||
// @Tags 后台-动漫列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediaser.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &mediaser.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("media update param err:%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 上架相关时做敏感词校验,命中直接拒绝
|
||||
if detail, hit := p.CheckSensitive(); hit {
|
||||
common.ServeJSON(ctx, stderr.ContentSensitiveHit, detail)
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update(manager)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("media update err:%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "动漫列表管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// BatchUpdate doc
|
||||
// @Summary 批量更新动漫列表
|
||||
// @Description 批量更新动漫列表
|
||||
// @Tags 后台-动漫列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediaser.WebBatchUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media/batch/update [post]
|
||||
func BatchUpdate(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &mediaser.WebBatchUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("media BatchUpdate param err:%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if _, err = p.ValidatedIDs(); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 批量上架时做敏感词校验,命中直接拒绝
|
||||
if detail, hit := p.CheckSensitive(); hit {
|
||||
common.ServeJSON(ctx, stderr.ContentSensitiveHit, detail)
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update(manager)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("media BatchUpdate err:%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "动漫列表管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除动漫列表
|
||||
// @Description 删除动漫列表
|
||||
// @Tags 后台-动漫列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediaser.WebDeleteReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media/delete [post]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &mediaser.WebDeleteReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 删除
|
||||
err = p.Delete()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "动漫列表管理", "删除", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// BatchDelete doc
|
||||
// @Summary 批量删除动漫列表
|
||||
// @Description 批量删除动漫列表
|
||||
// @Tags 后台-动漫列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body mediaser.WebBatchDeleteReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media/batch/delete [post]
|
||||
func BatchDelete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &mediaser.WebBatchDeleteReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 删除
|
||||
err = p.Delete()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "动漫列表管理", "删除", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Export doc
|
||||
// @Summary 导出动漫列表
|
||||
// @Description 导出动漫列表
|
||||
// @Tags 后台-动漫管理
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediaser.WebListReq false "请求参数"
|
||||
// @Success 200 {string} string "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media/export [post]
|
||||
func Export(ctx *gin.Context) {
|
||||
var req = &mediaser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
buff, err := req.Export()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeFile(ctx, "动漫列表", common.FileExcel, &buff)
|
||||
}
|
||||
Executable
+167
@@ -0,0 +1,167 @@
|
||||
package mediatagctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/mediatagser"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取动漫标签列表
|
||||
// @Description 获取动漫标签列表
|
||||
// @Tags 后台-动漫标签
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediatagser.WebListReq false "请求参数"
|
||||
// @Success 200 object mediatagser.WebListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media_tag/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &mediatagser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// AllList doc
|
||||
// @Summary 获取所有动漫标签列表
|
||||
// @Description 获取所有动漫标签列表
|
||||
// @Tags 后台-动漫标签
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediatagser.WebAllListReq false "请求参数"
|
||||
// @Success 200 object mediatagser.WebAllListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media_tag/all [get]
|
||||
func AllList(ctx *gin.Context) {
|
||||
var req = &mediatagser.WebAllListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetALLList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Create doc
|
||||
// @Summary 新增动漫标签
|
||||
// @Description 新增动漫标签
|
||||
// @Tags 后台-动漫标签
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediatagser.WebCreateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media_tag/create [post]
|
||||
func Create(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &mediatagser.WebCreateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 创建
|
||||
err = p.Create(manager)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "动漫标签管理", "创建", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新动漫标签
|
||||
// @Description 更新动漫标签
|
||||
// @Tags 后台-动漫标签
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediatagser.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media_tag/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &mediatagser.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update(manager)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "动漫标签管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除动漫标签
|
||||
// @Description 删除动漫标签
|
||||
// @Tags 后台-动漫标签
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediatagser.WebDeleteReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media_tag/delete [post]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &mediatagser.WebDeleteReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 删除
|
||||
err = p.Delete()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "动漫标签管理", "删除", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
package mediatagdimensionctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/mediatagdimensionser"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取媒体纬度列表列表
|
||||
// @Description 获取媒体纬度列表列表
|
||||
// @Tags 后台-媒体纬度列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediatagdimensionser.WebListReq false "请求参数"
|
||||
// @Success 200 object mediatagdimensionser.WebListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media_tag_dimension/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &mediatagdimensionser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// AllList doc
|
||||
// @Summary 获取所有媒体纬度列表配置
|
||||
// @Description 获取所有媒体纬度列表配置
|
||||
// @Tags 后台-媒体纬度列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediatagdimensionser.WebAllListReq false "请求参数"
|
||||
// @Success 200 object mediatagdimensionser.WebAllListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media_tag_dimension/all [get]
|
||||
func AllList(ctx *gin.Context) {
|
||||
var req = &mediatagdimensionser.WebAllListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetAllList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Create doc
|
||||
// @Summary 新增媒体纬度列表
|
||||
// @Description 新增媒体纬度列表
|
||||
// @Tags 后台-媒体纬度列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediatagdimensionser.WebCreateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media_tag_dimension/create [post]
|
||||
func Create(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &mediatagdimensionser.WebCreateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 创建
|
||||
err = p.Create(manager)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "媒体纬度列表管理", "创建", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新媒体纬度列表
|
||||
// @Description 更新媒体纬度列表
|
||||
// @Tags 后台-媒体纬度列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediatagdimensionser.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media_tag_dimension/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &mediatagdimensionser.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update(manager)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "媒体纬度列表管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除媒体纬度列表
|
||||
// @Description 删除媒体纬度列表
|
||||
// @Tags 后台-媒体纬度列表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query mediatagdimensionser.WebDeleteReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/media_tag_dimension/delete [post]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &mediatagdimensionser.WebDeleteReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 删除
|
||||
err = p.Delete()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "媒体纬度列表管理", "删除", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,437 @@
|
||||
package modulectrl
|
||||
|
||||
import (
|
||||
"91porn-server/common/log"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/constant/redisconst"
|
||||
"91porn-server/common/redis"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/s/sectionstatmod"
|
||||
"91porn-server/models/v/marqueemod"
|
||||
"91porn-server/models/v/moduleconfmod"
|
||||
"91porn-server/models/v/modulesectionmod"
|
||||
"91porn-server/web/service/moduleser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// Add doc
|
||||
// @Summary 新增模块
|
||||
// @Description 新增模块
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param moduleName body string true "模块名称"
|
||||
// @Param subModuleName body string true "亚模块名称"
|
||||
// @Param sectionLimit body integer true "亚模块下专题数量限制,0-不限制"
|
||||
// @Param status body integer true "状态,1-启用,0-不启用"
|
||||
// @Param type body integer true "模块类型,1-首页,2-社区"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/conf/add [post]
|
||||
func Add(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
moduleConf := moduleconfmod.ModuleConf{}
|
||||
if err := ctx.ShouldBind(&moduleConf); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = moduleser.AddModule(moduleConf); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
clearAppModuleCache()
|
||||
log, _ := json.Marshal(moduleConf)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Loufeng, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// AddSection doc
|
||||
// @Summary 新增专题
|
||||
// @Description 新增专题
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param sectionName body string true "专题名称"
|
||||
// @Param subModuleID body string true "专题所属亚模块id"
|
||||
// @Param originalUserID body integer false "原创博主用户ID"
|
||||
// @Param status body integer true "状态,1-启用,0-不启用"
|
||||
// @Param sort body integer true "排序"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/section/add [post]
|
||||
func AddSection(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
section := modulesectionmod.Section{}
|
||||
if err = ctx.ShouldBind(§ion); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = moduleser.AddSection(section); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(section)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Loufeng, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// EditSection doc
|
||||
// @Summary 修改专题
|
||||
// @Description 修改专题
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id body string true "专题id"
|
||||
// @Param subModuleID body string false "亚模块id"
|
||||
// @Param sectionName body string false "专题名称"
|
||||
// @Param originalUserID body integer false "原创播主用户ID"
|
||||
// @Param status body integer false "状态,1-启用,0-不启用"
|
||||
// @Param sort body integer false "排序"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/section/edit [post]
|
||||
func EditSection(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
p := modulesectionmod.EditSelector{}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = moduleser.UpdateSection(p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Loufeng, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// DeleteSection doc
|
||||
// @Summary 删除专题
|
||||
// @Description 删除专题
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id body string true "专题id"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/section/delete [post]
|
||||
func DeleteSection(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var p struct {
|
||||
ID primitive.ObjectID `json:"id" binding:"required"`
|
||||
}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = moduleser.DeleteSection(p.ID); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Section, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Edit doc
|
||||
// @Summary 修改
|
||||
// @Description 修改
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id body string true "模块id"
|
||||
// @Param moduleName body string true "模块名称"
|
||||
// @Param subModuleName body string true "亚模块名称"
|
||||
// @Param sectionLimit body integer true "专题数量限制,0-不限制"
|
||||
// @Param status body integer false "状态,1-启用,0-不启用"
|
||||
// @Param sort body integer false "排序"
|
||||
// @Param excludeSearch body boolean false "亚模块内容不进入搜索列表"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/conf/edit [post]
|
||||
func Edit(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
p := moduleconfmod.EditSelector{}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = moduleser.UpdateModule(p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
clearAppModuleCache()
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Loufeng, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除
|
||||
// @Description 删除
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id body string true "模块id"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/conf/delete [post]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var p struct {
|
||||
ID primitive.ObjectID `json:"id" binding:"required"`
|
||||
}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = moduleconfmod.DeleteOne(p.ID); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, "")
|
||||
return
|
||||
}
|
||||
clearAppModuleCache()
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Loufeng, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
func clearAppModuleCache() {
|
||||
if redis.Handler != nil {
|
||||
_, _ = redis.Handler.Del(redisconst.ModulesCache, redisconst.ContentUpdateMarkersCache)
|
||||
}
|
||||
}
|
||||
|
||||
// Search doc
|
||||
// @Summary 获取模块配置列表
|
||||
// @Description 根据条件匹配获取配置列表,模块名称和专题名称进行模糊匹配
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id body string false "专题id"
|
||||
// @Param moduleName body string false "模块名称"
|
||||
// @Param subModuleName body string false "亚模块名称"
|
||||
// @Param status body integer false "状态,1-启用,0-不启用"
|
||||
// @Param pageNumber body integer true "当前页码"
|
||||
// @Param pageSize body integer true "一页数据容量"
|
||||
// @Success 200 {object} moduleconfmod.ListResp
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/conf/list [post]
|
||||
func Search(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var p struct {
|
||||
moduleconfmod.QuerySelector
|
||||
commod.Page
|
||||
}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := moduleconfmod.Search(p.QuerySelector, p.Page)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Loufeng, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
// SearchSection doc
|
||||
// @Summary 检索专题列表
|
||||
// @Description 根据条件匹配获取专题列表,专题名称进行模糊匹配
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id body string true "专题id"
|
||||
// @Param subModuleID body string true "亚模块id"
|
||||
// @Param sectionName body string true "专题名称"
|
||||
// @Param status body integer true "状态,1-启用,0-不启用"
|
||||
// @Param pageNumber body integer true "当前页码"
|
||||
// @Param pageSize body integer true "一页数据容量"
|
||||
// @Success 200 {object} modulesectionmod.ListResp
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/section/list [post]
|
||||
func SearchSection(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var p struct {
|
||||
modulesectionmod.QuerySelector
|
||||
commod.Page
|
||||
}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := moduleser.SectionSearch(p.QuerySelector, p.Page)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Loufeng, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
// AllSections doc
|
||||
// @Summary 所有专题
|
||||
// @Description 返回所有有效专题
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {array} modulesectionmod.ModuleSection
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/section/all [post]
|
||||
func AllSections(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := moduleser.AllSections()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Loufeng, constant.Modify, "", ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
// ClicksList doc
|
||||
// @Summary 获取专题点击量
|
||||
// @Description 分页搜索专题每日点击量
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param sectionID body string true "专题ID"
|
||||
// @Param pageNumber body integer true "页码"
|
||||
// @Param pageSize body integer true "页容量"
|
||||
// @Success 200 {object} sectionstatmod.ListResponse "Success"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/section/clicks [post]
|
||||
func ClicksList(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req sectionstatmod.ListRequest
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := sectionstatmod.ListSectionHits(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Loufeng, constant.Modify, "", ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
// ChangeModuleMarquee doc
|
||||
// @Summary 修改模块跑马灯
|
||||
// @Description 修改模块跑马灯
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param marquee body string true "跑马灯"
|
||||
// @Success 200 {string} string "Success"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/conf/marquee [post]
|
||||
func ChangeModuleMarquee(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var p struct {
|
||||
Marquee string `json:"marquee" binding:"required"`
|
||||
}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = marqueemod.Set(p.Marquee); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Loufeng, constant.Modify, "", ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// GetModuleMarquee doc
|
||||
// @Summary 获取模块跑马灯
|
||||
// @Description 获取模块跑马灯
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {object} marqueemod.Marquee "Success"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/conf/marquee [get]
|
||||
func GetModuleMarquee(ctx *gin.Context) {
|
||||
c, err := marqueemod.Get()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, c)
|
||||
}
|
||||
|
||||
// AllCartoonList doc
|
||||
// @Summary 获取动漫所有模块配置列表
|
||||
// @Description 获取动漫所有模块配置列表
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {object} modulesectionmod.AllSectionConf
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/conf/cartoon/all [get]
|
||||
func AllCartoonList(ctx *gin.Context) {
|
||||
resp, err := moduleser.QueryAllCartoonList()
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Query all module err:%v\n,%d", resp, err))
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
package modulevideoctrl
|
||||
|
||||
import (
|
||||
"91porn-server/app/service/modulevideoser"
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/modulevidmod"
|
||||
"91porn-server/web/service/moduleser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// AddVideo doc
|
||||
// @Summary 新增视频
|
||||
// @Description 在专题下新增视频
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param sectionID body string true "专题id"
|
||||
// @Param videoID body string true "视频id"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/video/add [post]
|
||||
func AddVideo(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
p := modulevidmod.SectionVideo{}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
code := modulevideoser.AddVideo(&p)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Loufeng, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// AddVideoBatch doc
|
||||
// @Summary 批量新增视频
|
||||
// @Description 在专题下批量新增视频
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param sectionID body string true "专题id"
|
||||
// @Param videoIDs body string true "视频id列表,以','分隔"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/video/add/batch [post]
|
||||
func AddVideoBatch(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
p := moduleser.AddVideoBatchReq{}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err := moduleser.AddVideoBatch(p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertManyError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Loufeng, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// UpdateVideo doc
|
||||
// @Summary 修改视频
|
||||
// @Description 设置视频在专题下的排序码
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id body string false "id primary key"
|
||||
// @Param sectionID body string false "section id"
|
||||
// @Param videoID body string false "video id"
|
||||
// @Param sortCode body integer false "视频排序"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/video/edit [post]
|
||||
func UpdateVideo(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
p := modulevidmod.EditSelector{}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
code := modulevideoser.UpdateVideo(&p)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Loufeng, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// DeleteVideo doc
|
||||
// @Summary 删除视频
|
||||
// @Description 删除视频
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id body string true "id"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/video/delete [post]
|
||||
func DeleteVideo(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var p struct {
|
||||
ID primitive.ObjectID `json:"id"`
|
||||
}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = modulevidmod.DeleteOne(p.ID); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Loufeng, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// BatchDeleteVideo doc
|
||||
// @Summary 批量删除视频
|
||||
// @Description 批量删除专题下视频
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param sectionID body string true "专题ID"
|
||||
// @Param request body modulevidmod.BatchDeleteVideoRequest true "request"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/video/delete/batch [post]
|
||||
func BatchDeleteVideo(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var p modulevidmod.BatchDeleteVideoRequest
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if p.SectionID.IsZero() || len(p.VideoIDs) == 0 {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "invalid params")
|
||||
return
|
||||
}
|
||||
if err = modulevidmod.BatchDeleteVideo(ctx, p.SectionID, p.VideoIDs); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Loufeng, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// List doc
|
||||
// @Summary 获取视频列表
|
||||
// @Description 获取视频列表
|
||||
// @Tags 模块配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param sectionid query string true "专题id"
|
||||
// @Param videoid query string true "视频id"
|
||||
// @Param pageNumber query integer true "当前页码"
|
||||
// @Param pageSize query integer true "一页数据量"
|
||||
// @Success 200 {object} moduleser.ModuleVideoList
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /module/video/list [post]
|
||||
func List(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var q struct {
|
||||
modulevidmod.QuerySelector
|
||||
commod.Page
|
||||
}
|
||||
if err = ctx.ShouldBind(&q); err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := moduleser.GetModuleList(q.QuerySelector, q.Page)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(q)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.Loufeng, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
Executable
+141
@@ -0,0 +1,141 @@
|
||||
package nakedchatctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/nakedchatser"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取裸聊列表
|
||||
// @Description 获取裸聊列表
|
||||
// @Tags 后台-裸聊
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query nakedchatser.WebListReq false "请求参数"
|
||||
// @Success 200 object nakedchatser.WebListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/nakedchat/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &nakedchatser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Create doc
|
||||
// @Summary 新增裸聊
|
||||
// @Description 新增裸聊
|
||||
// @Tags 后台-裸聊
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body nakedchatser.WebCreateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/nakedchat/create [post]
|
||||
func Create(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &nakedchatser.WebCreateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 创建
|
||||
err = p.Create()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "裸聊管理", "创建", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新裸聊
|
||||
// @Description 更新裸聊
|
||||
// @Tags 后台-裸聊
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body nakedchatser.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/nakedchat/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &nakedchatser.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "裸聊管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// BatchUpdate doc
|
||||
// @Summary 批量更新裸聊
|
||||
// @Description 批量更新裸聊
|
||||
// @Tags 后台-裸聊
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body nakedchatser.WebBatchUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/nakedchat/batch/update [post]
|
||||
func BatchUpdate(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &nakedchatser.WebBatchUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "裸聊管理", "批量更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
Executable
+71
@@ -0,0 +1,71 @@
|
||||
package nakedchatorderctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/nakedchatorderser"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取裸聊订单列表
|
||||
// @Description 获取裸聊订单列表
|
||||
// @Tags 后台-裸聊订单
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query nakedchatorderser.WebListReq false "请求参数"
|
||||
// @Success 200 object nakedchatorderser.WebListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/nakedchatorder/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &nakedchatorderser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新裸聊订单
|
||||
// @Description 更新裸聊订单
|
||||
// @Tags 后台-裸聊订单
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body nakedchatorderser.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/nakedchatorder/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &nakedchatorderser.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "裸聊订单管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
package newactivityctrl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/newactivity"
|
||||
"91porn-server/models/v/usermod"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tealeg/xlsx"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
// @Tags 特制H5活动
|
||||
// @Summary 导入所有嫩模
|
||||
// @Description 导入所有嫩模
|
||||
// @Security ApiKeyAuth
|
||||
// @Tags web-H5嫩模活动
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param file formData file false "选择的文件"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/newactivity/importModels [post]
|
||||
func ImportModels(ctx *gin.Context) {
|
||||
token := ctx.PostForm("token")
|
||||
if token != "q7ydjHVIVBYiTqQ&" {
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, nil)
|
||||
return
|
||||
}
|
||||
form, err := ctx.MultipartForm()
|
||||
if err != nil {
|
||||
log.Warn("request multipart wrong ", log.E(err))
|
||||
common.ServeJSON(ctx, stderr.ErrUploadError, err.Error())
|
||||
return
|
||||
}
|
||||
fs := form.File["file"]
|
||||
if len(fs) == 0 {
|
||||
common.ServeJSON(ctx, stderr.ErrUploadError, err.Error())
|
||||
return
|
||||
}
|
||||
file, err := fs[0].Open()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrUploadError, err.Error())
|
||||
return
|
||||
}
|
||||
buffer := bytes.Buffer{}
|
||||
buffer.Reset()
|
||||
_, err = buffer.ReadFrom(file)
|
||||
file.Close()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrUploadError, err.Error())
|
||||
return
|
||||
}
|
||||
excelFile, err := xlsx.OpenBinary(buffer.Bytes())
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrUploadError, err.Error())
|
||||
return
|
||||
}
|
||||
id := uint32(130)
|
||||
insertSqls := make([]mongo.WriteModel, 0, 50)
|
||||
stockInsertSqls := make([]mongo.WriteModel, 0, 500)
|
||||
for _, row := range excelFile.Sheets[0].Rows[1:51] {
|
||||
excelModel := &struct {
|
||||
Name string `xlsx:"4"` //姓名
|
||||
Location string `xlsx:"5"` //地区
|
||||
BgImg string `xlsx:"6"` //图片
|
||||
Video string `xlsx:"7"` //视频
|
||||
}{}
|
||||
if err = row.ReadStruct(excelModel); err != nil {
|
||||
continue
|
||||
}
|
||||
model := newactivity.Model{
|
||||
Id: id,
|
||||
Name: strings.TrimSpace(excelModel.Name),
|
||||
BgImg: strings.Split(excelModel.BgImg, ","),
|
||||
Location: strings.TrimSpace(excelModel.Location),
|
||||
Video: excelModel.Video,
|
||||
}
|
||||
insert := mongo.NewInsertOneModel()
|
||||
insert.SetDocument(&model)
|
||||
insertSqls = append(insertSqls, insert)
|
||||
date := time.Date(2020, 6, 20, 0, 0, 0, 0, time.Local)
|
||||
for i := 0; i < 11; i++ {
|
||||
stockModel := newactivity.GiftStock{
|
||||
ModelId: id,
|
||||
Date: date.Add(time.Duration(i) * 24 * time.Hour),
|
||||
GiftLeft: 300,
|
||||
SoldOut: false,
|
||||
}
|
||||
stockInsert := mongo.NewInsertOneModel()
|
||||
stockInsert.SetDocument(&stockModel)
|
||||
stockInsertSqls = append(stockInsertSqls, stockInsert)
|
||||
}
|
||||
id++
|
||||
}
|
||||
if err = newactivity.BulkStocks(stockInsertSqls); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrUploadError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = newactivity.BulkAddModels(insertSqls); err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// @Tags 特制H5活动
|
||||
// @Summary 写入参数活动人数
|
||||
// @Description 写入参数活动人数
|
||||
// @Security ApiKeyAuth
|
||||
// @Tags web-H5嫩模活动
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param num formData integer false "人数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/newactivity/updateJoinNum [post]
|
||||
func UpdateJoinNum(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req struct {
|
||||
Num int64 `json:"num"`
|
||||
}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"data": err.Error(), "code": stderr.ErrParamError, "msg": stderr.ErrParamError.Msg()})
|
||||
return
|
||||
}
|
||||
if err = newactivity.UpdateJoinNum(req.Num); err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, nil)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.NewsModel, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// @Tags 特制H5活动
|
||||
// @Summary 获取参加活动人数
|
||||
// @Description 获取参加活动人数
|
||||
// @Security ApiKeyAuth
|
||||
// @Tags web-H5嫩模活动
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/newactivity/joinNum [get]
|
||||
func GetJoinNum(ctx *gin.Context) {
|
||||
num, err := newactivity.GetJoinNum()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"num": num})
|
||||
}
|
||||
|
||||
// @Tags 特制H5活动
|
||||
// @Summary 购买列表
|
||||
// @Description 购买列表
|
||||
// @Security ApiKeyAuth
|
||||
// @Tags web-H5嫩模活动
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page formData integer false "页码"
|
||||
// @Param pageSize formData integer false "条数"
|
||||
// @Param userId formData integer false "用户id"
|
||||
// @Param userName formData string false "用户昵称"
|
||||
// @Param modelId formData integer false "模特id"
|
||||
// @Param date formData string false "期号"
|
||||
// @Param start formData string false "开始时间"
|
||||
// @Param end formData string false "结束时间"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/newactivity/buyPage [post]
|
||||
func BuyPage(ctx *gin.Context) {
|
||||
var req newactivity.BuyPageReq
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"data": err.Error(), "code": stderr.ErrParamError, "msg": stderr.ErrParamError.Msg()})
|
||||
return
|
||||
}
|
||||
rs, err := newactivity.BuyPage(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, nil)
|
||||
return
|
||||
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, rs)
|
||||
}
|
||||
|
||||
// @Tags 特制H5活动
|
||||
// @Summary 添加获奖记录
|
||||
// @Description 添加获奖记录
|
||||
// @Security ApiKeyAuth
|
||||
// @Tags web-H5嫩模活动
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param date formData string false "日期"
|
||||
// @Param userId formData uint32 false "用户id"
|
||||
// @Param userName formData string false "用户昵称"
|
||||
// @Param userLogo formData string false "用户头像"
|
||||
// @Param winNum formData uint32 false "中奖号码"
|
||||
// @Param modelId formData uint32 false "模特Id"
|
||||
// @Param createdAt formData string false "创建时间"
|
||||
// @Param updatedAt formData string false "更新时间"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/newactivity/addWinRecord [post]
|
||||
func AddWinRecord(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req struct {
|
||||
Quantity uint32 `json:"quantity" bson:"quantity"` //购买份数
|
||||
newactivity.WinRecords
|
||||
}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
exists, err := newactivity.ExistsOrder(req.Quantity, req.WinRecords)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if !exists {
|
||||
common.ServeJSON(ctx, stderr.Failure, "中奖信息有误")
|
||||
return
|
||||
}
|
||||
userInfo, err := usermod.FindUserByUID(uint64(req.UserId))
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err)
|
||||
return
|
||||
}
|
||||
req.UserName = userInfo.Name
|
||||
req.UserLogo = userInfo.Portrait
|
||||
req.WinNum = req.Quantity
|
||||
if err = newactivity.AddWinRecord(req.WinRecords); err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.RewardList, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// @Tags 特制H5活动
|
||||
// @Summary 获奖记录列表
|
||||
// @Description 获奖记录列表
|
||||
// @Security ApiKeyAuth
|
||||
// @Tags web-H5嫩模活动
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page formData int64 false "页码"
|
||||
// @Param pageSize formData int64 false "条数"
|
||||
// @Param userId formData uint32 false "用户id"
|
||||
// @Param userName formData string false "用户昵称"
|
||||
// @Param modelId formData uint32 false "模特id"
|
||||
// @Param date formData string false "期号"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/newactivity/winRecordPage [post]
|
||||
func WinRecordPage(ctx *gin.Context) {
|
||||
var req newactivity.WinRcdPageReq
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
rs, err := newactivity.WinRecordPage(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, nil)
|
||||
return
|
||||
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, rs)
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package officialWebsitectrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
officialwebsiteser "91porn-server/web/service/officialWebsiteser"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ListAlbum(ctx *gin.Context) {
|
||||
req := &officialwebsiteser.AlbumListReq{}
|
||||
if err := ctx.ShouldBindQuery(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
total, data, err := officialwebsiteser.ListAlbum(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"total": total, "list": data})
|
||||
}
|
||||
|
||||
func CreateAlbum(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyAlbumReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.CreateAlbum(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func UpdateAlbum(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyAlbumReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.UpdateAlbum(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func DeleteAlbum(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.DeleteAlbumReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.DeleteAlbum(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package officialWebsitectrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/officialWebsiteser"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetBasicData(ctx *gin.Context) {
|
||||
data, err := officialwebsiteser.GetBasicData()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func CreateBasicData(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyBasicDataReq{}
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.CreateBasicData(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func UpdateBasicData(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyBasicDataReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.UpdateBasicData(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func DeleteBasicData(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.DeleteBasicDataReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.DeleteBasicData(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package officialWebsitectrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
officialwebsiteser "91porn-server/web/service/officialWebsiteser"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ListBusiness(ctx *gin.Context) {
|
||||
req := &officialwebsiteser.BusinessListReq{}
|
||||
if err := ctx.ShouldBindQuery(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
total, data, err := officialwebsiteser.ListBusiness(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"total": total, "list": data})
|
||||
}
|
||||
|
||||
func CreateBusiness(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyBusinessReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.CreateBusiness(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func UpdateBusiness(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyBusinessReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.UpdateBusiness(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func DeleteBusiness(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.DeleteBusinessReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.DeleteBusiness(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package officialWebsitectrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
officialwebsiteser "91porn-server/web/service/officialWebsiteser"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ListHero(ctx *gin.Context) {
|
||||
req := &officialwebsiteser.HeroListReq{}
|
||||
if err := ctx.ShouldBindQuery(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
total, data, err := officialwebsiteser.ListHero(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"total": total, "list": data})
|
||||
}
|
||||
|
||||
func CreateHero(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyHeroReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.CreateHero(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func UpdateHero(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyHeroReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.UpdateHero(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func DeleteHero(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.DeleteHeroReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.DeleteHero(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package officialWebsitectrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
officialwebsiteser "91porn-server/web/service/officialWebsiteser"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ListJobList(ctx *gin.Context) {
|
||||
req := &officialwebsiteser.JobListReq{}
|
||||
if err := ctx.ShouldBindQuery(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
total, data, err := officialwebsiteser.ListJobList(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"total": total, "list": data})
|
||||
}
|
||||
|
||||
func CreateJobList(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyJobReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.CreateJobList(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func UpdateJobList(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyJobReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.UpdateJobList(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func DeleteJobList(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.DeleteJobReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.DeleteJobList(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package officialWebsitectrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
officialwebsiteser "91porn-server/web/service/officialWebsiteser"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ListNews(ctx *gin.Context) {
|
||||
req := &officialwebsiteser.NewsListReq{}
|
||||
if err := ctx.ShouldBindQuery(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
total, data, err := officialwebsiteser.ListNews(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"total": total, "list": data})
|
||||
}
|
||||
|
||||
func CreateNews(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyNewsReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.CreateNews(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func UpdateNews(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyNewsReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.UpdateNews(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func DeleteNews(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.DeleteNewsReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.DeleteNews(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package officialWebsitectrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
officialwebsiteser "91porn-server/web/service/officialWebsiteser"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ListPartner(ctx *gin.Context) {
|
||||
req := &officialwebsiteser.PartnerListReq{}
|
||||
if err := ctx.ShouldBindQuery(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
total, data, err := officialwebsiteser.ListPartner(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"total": total, "list": data})
|
||||
}
|
||||
|
||||
func CreatePartner(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyPartnerReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.CreatePartner(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func UpdatePartner(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyPartnerReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.UpdatePartner(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func DeletePartner(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.DeletePartnerReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.DeletePartner(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package officialWebsitectrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
officialwebsiteser "91porn-server/web/service/officialWebsiteser"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ListPhotograph(ctx *gin.Context) {
|
||||
req := &officialwebsiteser.ListPhotographReq{}
|
||||
if err := ctx.ShouldBindQuery(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
total, data, err := officialwebsiteser.ListPhotograph(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"total": total, "list": data})
|
||||
}
|
||||
|
||||
func CreatePhotograph(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyPhotographReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.CreatePhotograph(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func UpdatePhotograph(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyPhotographReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.UpdatePhotograph(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func DeletePhotograph(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.DeletePhotographReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.DeletePhotograph(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func BatchUpdatePhotograph(ctx *gin.Context) {
|
||||
req := &officialwebsiteser.BatchUpdatePhotographOwnerReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.BatchUpdatePhotographOwner(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package officialWebsitectrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
officialwebsiteser "91porn-server/web/service/officialWebsiteser"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ListRecruitForm(ctx *gin.Context) {
|
||||
req := &officialwebsiteser.RecruitFormListReq{}
|
||||
if err := ctx.ShouldBindQuery(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
total, data, err := officialwebsiteser.ListRecruitForm(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"total": total, "list": data})
|
||||
}
|
||||
|
||||
func CreateRecruitForm(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyRecruitFormReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.CreateRecruitForm(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func UpdateRecruitForm(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyRecruitFormReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.UpdateRecruitForm(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func DeleteRecruitForm(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.DeleteRecruitFormReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.DeleteRecruitForm(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package officialWebsitectrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
officialwebsiteser "91porn-server/web/service/officialWebsiteser"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ListTag(ctx *gin.Context) {
|
||||
req := &officialwebsiteser.TagListReq{}
|
||||
if err := ctx.ShouldBindQuery(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
total, data, err := officialwebsiteser.ListTag(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"total": total, "list": data})
|
||||
}
|
||||
|
||||
func CreateTag(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyTagReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.CreateTag(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func UpdateTag(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyTagReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.UpdateTag(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func DeleteTag(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.DeleteTagReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.DeleteTag(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package officialWebsitectrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
officialwebsiteser "91porn-server/web/service/officialWebsiteser"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ListVideo(ctx *gin.Context) {
|
||||
req := &officialwebsiteser.VideoListReq{}
|
||||
if err := ctx.ShouldBindQuery(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
total, data, err := officialwebsiteser.ListVideo(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"total": total, "list": data})
|
||||
}
|
||||
|
||||
func CreateVideo(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyVideoReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.CreateVideo(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func UpdateVideo(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.ModifyVideoReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.UpdateVideo(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func DeleteVideo(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.DeleteVideoReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.DeleteVideo(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func BatchUpdateVideos(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.BatchUpdateVideoOwnerReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.BatchUpdateVideoOwner(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
func BatchImportVideos(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := &officialwebsiteser.BatchImportVideoReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := officialwebsiteser.BatchImportVideo(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.OfficialWebsiteImportVideoFailed, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialWebsiteConfig, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package officialWebsitectrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/tagmod"
|
||||
"91porn-server/models/v/vidmod"
|
||||
officialwebsiteser "91porn-server/web/service/officialWebsiteser"
|
||||
"91porn-server/web/service/vidser"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type VideoListFromVidResp struct {
|
||||
VInfos []*VideoResp `json:"vInfos"` // 帖子列表
|
||||
Total int64 `json:"total"` // 帖子总量
|
||||
}
|
||||
|
||||
type VideoResp struct {
|
||||
*vidmod.WebVideo
|
||||
AddedInfoOfficialWebsite bool `json:"added_info_official_website"`
|
||||
}
|
||||
|
||||
func ListVideoFromVid(ctx *gin.Context) {
|
||||
req := vidmod.ListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
m, sort, err := assembleConditions(req)
|
||||
if err != stderr.Success {
|
||||
common.ServeJSON(ctx, err, err)
|
||||
return
|
||||
}
|
||||
code, data := vidser.GetVidList(m, sort, req.PageNumber, req.PageSize, req.IsPush)
|
||||
|
||||
videoList := make([]*VideoResp, 0)
|
||||
var ids []primitive.ObjectID
|
||||
for _, v := range data.VInfos {
|
||||
ids = append(ids, v.ID)
|
||||
videoList = append(videoList, &VideoResp{
|
||||
WebVideo: v,
|
||||
AddedInfoOfficialWebsite: false,
|
||||
})
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
common.ServeJSON(ctx, code, videoList)
|
||||
return
|
||||
}
|
||||
|
||||
checkData, checkErr := officialwebsiteser.CheckVideoExistByVid(ids)
|
||||
if checkErr != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, nil)
|
||||
return
|
||||
}
|
||||
for i := range videoList {
|
||||
for j := range checkData {
|
||||
if videoList[i].WebVideo.ID == checkData[j].ID {
|
||||
videoList[i].AddedInfoOfficialWebsite = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
common.ServeJSON(ctx, code, &VideoListFromVidResp{
|
||||
VInfos: videoList,
|
||||
Total: data.Total,
|
||||
})
|
||||
}
|
||||
|
||||
func assembleConditions(req vidmod.ListReq) (m map[string]interface{}, sort vidser.SortModeList, err stderr.Code) {
|
||||
sort = vidser.SortModeList{{Field: "createdAt", Value: -1}}
|
||||
m = make(map[string]interface{})
|
||||
if req.ShowType != nil {
|
||||
m["showType"] = *req.ShowType
|
||||
}
|
||||
if req.Status != 4 {
|
||||
if req.Status == 7 {
|
||||
m["status"] = map[string]int{"$gt": 0}
|
||||
} else {
|
||||
m["status"] = req.Status
|
||||
}
|
||||
}
|
||||
if req.IsFree == 0 {
|
||||
m["coins"] = map[string]int{"$gt": 0}
|
||||
}
|
||||
if req.IsFree == 1 {
|
||||
m["coins"] = map[string]int{"$eq": 0}
|
||||
}
|
||||
if req.IsUserUp == 2 {
|
||||
m["publisherID"] = map[string]int{"$lt": 115000}
|
||||
}
|
||||
if req.IsUserUp == 1 {
|
||||
m["publisherID"] = map[string]int{"$gt": 115000}
|
||||
}
|
||||
if len(req.Title) != 0 {
|
||||
m["title"] = map[string]string{"$regex": req.Title, "$options": "i"}
|
||||
}
|
||||
if req.UID > 0 {
|
||||
m["publisherID"] = req.UID
|
||||
}
|
||||
if req.Chosen == 1 {
|
||||
m["chosen"] = true
|
||||
}
|
||||
if req.Chosen == 2 {
|
||||
m["chosen"] = false
|
||||
}
|
||||
if req.FreeArea == 1 {
|
||||
m["freeArea"] = true
|
||||
}
|
||||
if req.FreeArea == 2 {
|
||||
m["freeArea"] = false
|
||||
}
|
||||
if !req.End.IsZero() {
|
||||
m["createdAt"] = map[string]time.Time{"$gte": req.Start, "$lt": req.End}
|
||||
}
|
||||
if req.ReviewAccount != "" {
|
||||
m["reviewAccount"] = req.ReviewAccount
|
||||
}
|
||||
if len(req.Tag) != 0 {
|
||||
id, err := tagmod.GetTagIDByName(req.Tag)
|
||||
if err != nil {
|
||||
return m, sort, stderr.ErrDbQueryError
|
||||
}
|
||||
m["tags"] = id
|
||||
//sort = vidser.SortModeList{{Field: "tagSort." + id.Hex(), Value: -1}, {Field: "createdAt", Value: -1}}
|
||||
}
|
||||
if len(req.ID) != 0 {
|
||||
oid, err := primitive.ObjectIDFromHex(req.ID)
|
||||
if err != nil {
|
||||
return m, sort, stderr.ErrParamError
|
||||
}
|
||||
m["_id"] = oid
|
||||
}
|
||||
//通过初始价格判断是否是马甲账号
|
||||
if req.IsPretendAcc == 1 {
|
||||
m["coins"] = vidmod.PretendAccInitCoins
|
||||
}
|
||||
if req.IsPretendAcc == 2 {
|
||||
//i := make(map[string]int64)
|
||||
//i["$ne"] = vidmod.PretendAccInitCoins
|
||||
m["coins"] = map[string]int64{"$ne": vidmod.PretendAccInitCoins}
|
||||
}
|
||||
m["deleteAt"] = bson.M{"$exists": false}
|
||||
if req.NewsType != "" {
|
||||
m["newsType"] = req.NewsType
|
||||
}
|
||||
|
||||
if req.LiaoBaTop != nil {
|
||||
if *req.LiaoBaTop {
|
||||
sort = vidser.LiaoBaTopSortModeList()
|
||||
m["liaoBaTopSort"] = bson.M{"$gt": 0}
|
||||
} else {
|
||||
m["liaoBaTopSort"] = 0
|
||||
}
|
||||
}
|
||||
if req.SectionID != "" {
|
||||
m["sectionID"] = req.SectionID
|
||||
}
|
||||
m["isSortedUnderModule"] = req.IsSortedUnderModule
|
||||
if req.IsSortedUnderModule {
|
||||
sort = nil
|
||||
}
|
||||
if req.IsRecommended != nil {
|
||||
if *req.IsRecommended {
|
||||
m["recoWeight"] = bson.M{"$gte": 0}
|
||||
} else {
|
||||
m["recoWeight"] = bson.M{"$lt": 0}
|
||||
}
|
||||
}
|
||||
if req.Key == "likeRate" || req.Key == "purchaseRate" {
|
||||
m[req.Key] = req.Value
|
||||
}
|
||||
if req.IsHappinessPlazaTop != nil && *req.IsHappinessPlazaTop {
|
||||
if *req.IsHappinessPlazaTop {
|
||||
m["happinessPlazaTop"] = bson.M{"$gt": 0}
|
||||
} else {
|
||||
m["happinessPlazaTop"] = bson.M{"$lte": 0}
|
||||
}
|
||||
}
|
||||
return m, sort, stderr.Success
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package officialctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/officialmod"
|
||||
"91porn-server/web/service/officialser"
|
||||
"encoding/json"
|
||||
"github.com/gin-gonic/gin"
|
||||
"time"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 查询官方配置列表
|
||||
// @Description 查询官方配置列表
|
||||
// @Tags 官方配置管理
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param isActive query bool false "状态"
|
||||
// @Param pageNumber query integer true "页码"
|
||||
// @Param pageSize query integer true "每页条数"。
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/official/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var in *officialmod.QueryAllCond
|
||||
if err := ctx.ShouldBind(&in); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
data, code := officialser.QueryAll(in)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 编辑官方配置
|
||||
// @Description 编辑官方配置
|
||||
// @Tags 官方配置管理
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData string true "id"
|
||||
// @Param officialName formData string true "官方配置名字"
|
||||
// @Param officialImg formData string true "官方配置图片"
|
||||
// @Param officialUrl formData string true "官方配置链接"
|
||||
// @Param isActive formData bool true "官方配置开关"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/official/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
param := officialmod.WebTagUpdateReqInfo{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
doc := officialmod.OfficiaUpdateDoc{
|
||||
OfficialName: ¶m.OfficialName,
|
||||
OfficialDesc: ¶m.OfficialDesc,
|
||||
OfficialImg: ¶m.OfficialImg,
|
||||
OfficialUrl: ¶m.OfficialUrl,
|
||||
UpdatedAt: time.Now(),
|
||||
IsActive: ¶m.IsActive,
|
||||
Sort: ¶m.Sort,
|
||||
Position: ¶m.Position,
|
||||
IsHomepageAds: ¶m.IsHomepageAds,
|
||||
}
|
||||
if err := officialser.UpdateOfficial(param.ID, doc); err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(param)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 批量删除官方配置
|
||||
// @Description 批量删除官方配置
|
||||
// @Tags 官方配置管理
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData array true "标签id"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/official/delete [delete]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
param := officialmod.WebOfficialDeleteReqInfo{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err := officialser.DelOfficial(param); err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(param)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialConfig, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// Add doc
|
||||
// @Summary 新增官方配置
|
||||
// @Description 新增官方配置
|
||||
// @Tags 官方配置管理
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param officialName formData string true "官方配置名字"
|
||||
// @Param officialImg formData string true "官方配置图片"
|
||||
// @Param officialUrl formData string true "官方配置链接"
|
||||
// @Param isActive formData bool false "官方配置开关"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /web/official/add [post]
|
||||
func Add(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
param := officialmod.WebOfficialAddReqInfo{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
now := time.Now()
|
||||
official := officialmod.OfficialConfig{
|
||||
OfficialName: param.OfficialName,
|
||||
OfficialDesc: param.OfficialDesc,
|
||||
OfficialImg: param.OfficialImg,
|
||||
OfficialUrl: param.OfficialUrl,
|
||||
OfficialType: param.OfficialType,
|
||||
IsHomepageAds: param.IsHomepageAds,
|
||||
Sort: param.Sort,
|
||||
Position: param.Position,
|
||||
IsActive: false,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
if _, err := officialser.AddOfficial(official); err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(param)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.OfficialConfig, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package operationlogctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/web/service/operationlogser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 帖子、用户操作日志
|
||||
// @Summary 查询帖子、用户操作日志列表
|
||||
// @Description 查询帖子、用户操作日志列表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} operationlogser.GetOperationLogListResp
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /web/operationlog/List [GET]
|
||||
func OperationLogList(c *gin.Context) {
|
||||
var req operationlogser.GetOperationLogListReq
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, serr := operationlogser.GetOperationLogList(req)
|
||||
if serr != stderr.Success {
|
||||
common.ServeJSON(c, serr, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package paymentguidectrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/paymentguidemod"
|
||||
"91porn-server/web/service/paymentguideser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
func List(ctx *gin.Context) {
|
||||
req := paymentguideser.ListReq{}
|
||||
if err := ctx.ShouldBindQuery(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := req.List()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
func Add(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := paymentguideser.AddReq{}
|
||||
if err = ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if req.IsBatch() {
|
||||
if req.Config == nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "config is required")
|
||||
return
|
||||
}
|
||||
configs, batchErr := (paymentguideser.BatchAddReq{Scenes: req.Scenes, Config: *req.Config}).Configs()
|
||||
if batchErr != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, batchErr.Error())
|
||||
return
|
||||
}
|
||||
resp, batchErr := paymentguideser.BatchAdd(ctx.Request.Context(), configs)
|
||||
if batchErr != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertManyError, batchErr.Error())
|
||||
return
|
||||
}
|
||||
body, _ := json.Marshal(configs)
|
||||
_ = operatorlgmod.RecordOperation(manager, "付费引导配置", "批量创建", string(body), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
return
|
||||
}
|
||||
config := req.PaymentGuide
|
||||
if err = paymentguideser.Add(&config); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
body, _ := json.Marshal(config)
|
||||
_ = operatorlgmod.RecordOperation(manager, "付费引导配置", "创建", string(body), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, config.ID)
|
||||
}
|
||||
|
||||
func Edit(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
config := paymentguidemod.PaymentGuide{}
|
||||
if err = ctx.ShouldBindJSON(&config); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = paymentguideser.Edit(&config); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
body, _ := json.Marshal(config)
|
||||
_ = operatorlgmod.RecordOperation(manager, "付费引导配置", "修改", string(body), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
id, err := primitive.ObjectIDFromHex(ctx.Query("id"))
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, "invalid id")
|
||||
return
|
||||
}
|
||||
if err = paymentguideser.Delete(id); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
_ = operatorlgmod.RecordOperation(manager, "付费引导配置", "删除", id.Hex(), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package productBenefitctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/productbenefitmod"
|
||||
"91porn-server/web/service/productBenefitser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetProductBenefitList doc
|
||||
// @Summary 获取会员卡权益配置列表
|
||||
// @Description 获取会员卡权益配置列表
|
||||
// @Tags VIP权益
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param pageNumber formData integer true "查询页码"
|
||||
// @Param pageSize formData integer true "页码大小"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/productBenefit/list [get]
|
||||
func GetProductBenefitList(ctx *gin.Context) {
|
||||
req := productbenefitmod.ProductBenefitReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code, data := productBenefitser.GetProductBenefitList(req)
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// GetAllProductBenefitList doc
|
||||
// @Summary 获取全部会员卡权益配置列表
|
||||
// @Description 获取全部会员卡权益配置列表
|
||||
// @Tags VIP权益
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param pageNumber formData integer true "查询页码"
|
||||
// @Param pageSize formData integer true "页码大小"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/productBenefit/all/list [get]
|
||||
func GetAllProductBenefitList(ctx *gin.Context) {
|
||||
code, data := productBenefitser.GetAllProductBenefitList()
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// UpdateProductBenefit doc
|
||||
// @Summary 更新会员卡权益配置列表
|
||||
// @Description 更新会员卡权益配置列表
|
||||
// @Tags VIP权益
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData integer true "id"
|
||||
// @Param content formData string true "内容"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/productBenefit/update [post]
|
||||
func UpdateProductBenefit(ctx *gin.Context) {
|
||||
req := &productbenefitmod.ProductBenefitSelector{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code := productBenefitser.UpdateProductBenefit(req)
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
}
|
||||
|
||||
// DeleteProductBenefit doc
|
||||
// @Summary 删除会员卡权益配置列表
|
||||
// @Description 删除会员卡权益配置列表
|
||||
// @Tags VIP权益
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param vids formData []string true "跑马灯id数组"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/productBenefit/del [delete]
|
||||
func DeleteProductBenefit(ctx *gin.Context) {
|
||||
req := productbenefitmod.ProductBenefitDel{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code := productBenefitser.DeleteProductBenefit(req.ID)
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
}
|
||||
|
||||
// AddProductBenefit doc
|
||||
// @Summary 增加会员卡权益配置
|
||||
// @Description 增加会员卡权益配置
|
||||
// @Tags VIP权益
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/productBenefit/add [post]
|
||||
func AddProductBenefit(ctx *gin.Context) {
|
||||
req := productbenefitmod.ProductBenefit{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code := productBenefitser.AddProductBenefit(req)
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package productctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/export_task_mod"
|
||||
"91porn-server/models/v/prdcthsomod"
|
||||
"91porn-server/web/service/productser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// ProductLog doc
|
||||
// @Summary 会员卡购买记录
|
||||
// @Description 会员卡购买记录
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param q query prdcthsomod.ProductHistoryQueryReq false "请求参数"
|
||||
// @Success 200 object prdcthsomod.ProductHistoryQueryResp "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/business/product/order [get]
|
||||
func ProductLog(ctx *gin.Context) {
|
||||
arg := &prdcthsomod.ProductHistoryQueryReq{}
|
||||
if err := ctx.ShouldBind(arg); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := productser.GetBuyHistoryList(arg)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, resp)
|
||||
}
|
||||
|
||||
// ProductLogExport doc
|
||||
// @Summary 会员卡购买记录导出
|
||||
// @Description 会员卡购买记录
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param q query prdcthsomod.ProductHistoryQueryReq false "请求参数"
|
||||
// @Success 200 {string} string "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/business/product/order/export [post]
|
||||
func ProductLogExport(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
arg := &prdcthsomod.ProductHistoryQueryReq{}
|
||||
if err := ctx.ShouldBind(arg); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
err = export_task_mod.CreateTask(export_task_mod.ExportProductHistoryTask, manager, arg)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrExportFileFail, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, "success")
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package productctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/productposimod"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// Get doc
|
||||
// @Summary
|
||||
// @Description 查询
|
||||
// @Tags productposition
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /productposition/list [post]
|
||||
func GetPosition(ctx *gin.Context) {
|
||||
data, err := productposimod.FindAll()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{
|
||||
"list": data,
|
||||
})
|
||||
}
|
||||
|
||||
// Get doc
|
||||
// @Summary
|
||||
// @Description 查询位置名字列表
|
||||
// @Tags productposition
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /productposition/names [post]
|
||||
func GetPositionNames(ctx *gin.Context) {
|
||||
data, err := productposimod.FindNames()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{
|
||||
"list": data,
|
||||
})
|
||||
}
|
||||
|
||||
// Insert doc
|
||||
// @Summary 新增
|
||||
// @Description 新增
|
||||
// @Tags productposition
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /productposition/add [post]
|
||||
func InsertPosition(ctx *gin.Context) {
|
||||
v := productposimod.ProductPosition{}
|
||||
if err := ctx.ShouldBind(&v); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err := productposimod.Insert(&v); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 修改
|
||||
// @Description 修改
|
||||
// @Tags productposition
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /productposition/edit [post]
|
||||
func UpdatePosition(ctx *gin.Context) {
|
||||
p := productposimod.ProductPositionSelector{}
|
||||
if err := ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err := productposimod.Update(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除
|
||||
// @Description 删除
|
||||
// @Tags productposition
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData int true "productposition等级""
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /productposition/del [delete]
|
||||
func DeletePosition(ctx *gin.Context) {
|
||||
var p struct {
|
||||
ID string `json:"id" form:"id"`
|
||||
}
|
||||
if err := ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if err := productposimod.Remove(p.ID); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
package productctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/constant/redisconst"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/productbenefitmod"
|
||||
"91porn-server/models/v/productmod"
|
||||
"91porn-server/models/v/productposimod"
|
||||
"91porn-server/web/webg"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// FindVipList doc
|
||||
// @Summary product种类
|
||||
// @Description 所有可购买的product种类
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /product/productTypeList [get]
|
||||
func FindVipList(ctx *gin.Context) {
|
||||
req := productmod.ProductListWeb{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := productmod.FindStd(req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
positionM, _, _, err := productposimod.FindNamesWithStatusTrue()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
for i := range data {
|
||||
data[i].Position = positionM[data[i].Position]
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
// Insert doc
|
||||
// @Summary 新增
|
||||
// @Description 新增
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param q body productmod.Product false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /product/productType [post]
|
||||
func Insert(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
v := productmod.Product{}
|
||||
if err = ctx.ShouldBind(&v); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
//默认为vip商品
|
||||
if v.ProductType == 0 {
|
||||
v.ProductType = productmod.VIP
|
||||
}
|
||||
m, _, _, err := productposimod.FindNamesWithStatusTrue()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
for k := range m {
|
||||
if m[k] == v.Position {
|
||||
v.Position = k
|
||||
break
|
||||
}
|
||||
}
|
||||
//组装商品权益信息
|
||||
if len(v.Privilege) > 0 {
|
||||
//查询商品权益配置
|
||||
data, err := productbenefitmod.FindProductBenefitByPrivilege(&v.Privilege)
|
||||
if err != nil {
|
||||
log.Fatal("Insert productBenefitmod.FindProductBenefitByPrivilege err", log.E(err), log.Any("privilege", v.Privilege))
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
if dataLen := len(data); dataLen > 0 {
|
||||
v.NewPrivilege = make([]productmod.PrivilegeInfo, dataLen)
|
||||
for i, vv := range data {
|
||||
v.NewPrivilege[i] = productmod.PrivilegeInfo{
|
||||
Image: vv.Img,
|
||||
Name: vv.PrivilegeName,
|
||||
Desc: vv.PrivilegeDesc,
|
||||
IsCore: vv.IsCore,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err = productmod.InsertProduct(&v); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
redisKey := redisconst.DataCachKey(productmod.RedisSetKey, "FindProductByType")
|
||||
_, _ = webg.Redis.Del(redisKey)
|
||||
log, _ := json.Marshal(v)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ProductManageVIP, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 修改producttype
|
||||
// @Description 修改producttype
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData string true "id"
|
||||
// @Param q body productmod.ProductSelector false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /product/productType [put]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var p struct {
|
||||
ID string `json:"id" form:"id" bson:"id"`
|
||||
productmod.ProductSelector
|
||||
}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if p.Position != nil {
|
||||
m, _, _, err := productposimod.FindNamesWithStatusTrue()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
v := *p.Position
|
||||
for k := range m {
|
||||
if m[k] == v {
|
||||
kv := k
|
||||
p.Position = &kv
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
//组装商品权益信息
|
||||
if p.ProductSelector.Privilege != nil {
|
||||
//查询商品权益配置
|
||||
data, err := productbenefitmod.FindProductBenefitByPrivilege(p.ProductSelector.Privilege)
|
||||
if err != nil {
|
||||
log.Fatal("productBenefitmod.FindProductBenefitByPrivilege err", log.E(err), log.Any("privilege", p.ProductSelector.Privilege))
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
//清空NewPrivilege里面的数据
|
||||
if err = productmod.UpdateProductRights(p.ID); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, "")
|
||||
return
|
||||
}
|
||||
if dataLen := len(data); dataLen > 0 {
|
||||
p.ProductSelector.NewPrivilege = make([]*productmod.PrivilegeInfo, dataLen)
|
||||
for i, v := range data {
|
||||
p.ProductSelector.NewPrivilege[i] = &productmod.PrivilegeInfo{
|
||||
Image: v.Img,
|
||||
Name: v.PrivilegeName,
|
||||
Desc: v.PrivilegeDesc,
|
||||
IsCore: v.IsCore,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err = productmod.UpdateProduct(p.ID, &p.ProductSelector); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, "")
|
||||
return
|
||||
}
|
||||
redisKey := redisconst.DataCachKey(productmod.RedisSetKey, "FindProductByType")
|
||||
_, _ = webg.Redis.Del(redisKey)
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ProductManageVIP, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除
|
||||
// @Description 删除
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData int true "product等级""
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /product/productType [Delete]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var p struct {
|
||||
ID string `json:"id" form:"id"`
|
||||
}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if err = productmod.RemoveProduct(p.ID); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, "")
|
||||
return
|
||||
}
|
||||
redisKey := redisconst.DataCachKey(productmod.RedisSetKey, "FindProductByType")
|
||||
_, _ = webg.Redis.Del(redisKey)
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ProductManageVIP, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
func CheckboxList(c *gin.Context) {
|
||||
var (
|
||||
in productmod.CheckboxListCond
|
||||
data = map[string]interface{}{
|
||||
"data": []interface{}{},
|
||||
}
|
||||
)
|
||||
if err := c.ShouldBindQuery(&in); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
list, err := productmod.CheckboxByType(in.ProductType)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbQueryError, err)
|
||||
return
|
||||
}
|
||||
data["data"] = list
|
||||
common.ServeJSON(c, stderr.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package productctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/vipconfigmod"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetConfig doc
|
||||
// @Summary
|
||||
// @Description 查询VIP配置
|
||||
// @Tags loufeng
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /business/getConfig [get]
|
||||
func GetConfig(ctx *gin.Context) {
|
||||
data, err := vipconfigmod.FindOne()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
// SetConfig doc
|
||||
// @Summary 修改配置
|
||||
// @Description 修改配置
|
||||
// @Tags loufeng
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /business/setConfig [post]
|
||||
func SetConfig(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
s := vipconfigmod.EditSelector{}
|
||||
if err = ctx.ShouldBind(&s); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = vipconfigmod.Update(s); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(s)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VIPConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package promoteurlctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/constant/redisconst"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/sourcemod"
|
||||
"91porn-server/web/webg"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// promoteURL doc
|
||||
// @Summary promoteURL 列表查询
|
||||
// @Description
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param status formData integer false "状态"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /promoteUrl/list [get]
|
||||
func FindMany(ctx *gin.Context) {
|
||||
data := sourcemod.GetPromoteURLList()
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
// promoteURL doc
|
||||
// @Summary 新增
|
||||
// @Description 新增
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /promoteUrl/insert [post]
|
||||
func Insert(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
s := sourcemod.Source{}
|
||||
if err = ctx.ShouldBind(&s); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
s.Type = sourcemod.PromoteURL
|
||||
s.IsActive = true
|
||||
if err = sourcemod.Insert(&s); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
//落地页域名加入到redis中
|
||||
common.Go(func() {
|
||||
purls := sourcemod.GetPromoteURLArray()
|
||||
_, _ = webg.Redis.Del(redisconst.LandDomainCacheKey)
|
||||
_, _ = webg.Redis.SAdd(redisconst.LandDomainCacheKey, purls)
|
||||
_, _ = webg.Redis.ExpireKey(redisconst.LandDomainCacheKey, redisconst.LandDomainCacheExpire)
|
||||
})
|
||||
log, _ := json.Marshal(s)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ProductManagePage, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// promoteURL doc
|
||||
// @Summary 修改
|
||||
// @Description 修改
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /promoteUrl/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var p struct {
|
||||
ID primitive.ObjectID `json:"id" form:"id" bson:"id"`
|
||||
sourcemod.SourceEdit
|
||||
}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
p.SourceEdit.IsActive = true
|
||||
if err = sourcemod.Update(p.ID, sourcemod.PromoteURL, &p.SourceEdit); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, "")
|
||||
return
|
||||
}
|
||||
common.Go(func() {
|
||||
_, _ = webg.Redis.Del(redisconst.LandDomainCacheKey)
|
||||
})
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ProductManagePage, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// promoteURL doc
|
||||
// @Summary 删除
|
||||
// @Description 删除
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData int true "product等级"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /promoteUrl/delete [Delete]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var p struct {
|
||||
IDs []primitive.ObjectID `json:"ids" form:"ids"`
|
||||
}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if err = sourcemod.Remove(p.IDs); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, "")
|
||||
return
|
||||
}
|
||||
common.Go(func() {
|
||||
_, _ = webg.Redis.Del(redisconst.LandDomainCacheKey)
|
||||
})
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ProductManagePage, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package proxyctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/proxyincomemod"
|
||||
"91porn-server/models/v/proxymod"
|
||||
"91porn-server/web/service/proxyser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// ProxyLog doc
|
||||
// @Summary 用户推广日志
|
||||
// @Description 用户推广日志
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /proxy/log [get]
|
||||
func ProxyLog(ctx *gin.Context) {
|
||||
var arg struct {
|
||||
common.StandQuery
|
||||
proxymod.InvitationQueryReq
|
||||
}
|
||||
if err := ctx.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
total, data, err := proxymod.FindMany(common.StandQueryMap(arg.StandQuery, arg.InvitationQueryReq))
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, map[string]interface{}{
|
||||
"total": total,
|
||||
"history": data,
|
||||
})
|
||||
}
|
||||
|
||||
// AllIncome doc
|
||||
// @Summary 代理列表
|
||||
// @Description 代理列表
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /proxy/allIncome [get]
|
||||
func AllIncome(ctx *gin.Context) {
|
||||
var arg struct {
|
||||
UID uint64 `json:"uid" form:"uid"`
|
||||
}
|
||||
if err := ctx.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := proxyser.FindTotalIncome(arg.UID)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
// IncomeDetails doc
|
||||
// @Summary 代理列表
|
||||
// @Description 查询收益详情
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /proxy/i/income/details [get]
|
||||
func IncomeDetails(ctx *gin.Context) {
|
||||
var arg struct {
|
||||
proxyincomemod.StandReq
|
||||
common.StandQuery
|
||||
}
|
||||
if err := ctx.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
total, data, err := proxyincomemod.FindList(common.StandQueryMap(arg.StandQuery, arg.StandReq))
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
//获取条件下总收益
|
||||
totalIncome, err := proxyincomemod.GetTotalIncome(arg.UID, arg.StartTime, arg.EndTime)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{
|
||||
"total": total,
|
||||
"data": data,
|
||||
"totalIncome": totalIncome,
|
||||
})
|
||||
}
|
||||
|
||||
// PromotionQuery doc
|
||||
// @Summary 推广查询
|
||||
// @Description 推广查询
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /proxy/promotion [get]
|
||||
func PromotionQuery(ctx *gin.Context) {
|
||||
var arg struct {
|
||||
UID uint64 `json:"uid" form:"uid"`
|
||||
Type string `json:"type" form:"type"`
|
||||
}
|
||||
err := ctx.ShouldBind(&arg)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
var data interface{}
|
||||
if arg.Type == "up" { //获取上级代理
|
||||
data, err = proxyser.GetInvrDetails(arg.UID)
|
||||
} else { //获取下级代理
|
||||
data, err = proxyser.GetInveUsers(arg.UID)
|
||||
}
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
Executable
+147
@@ -0,0 +1,147 @@
|
||||
package quicksearchctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/web/service/quicksearchser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary 获取快捷搜索表列表
|
||||
// @Description 获取快捷搜索表列表
|
||||
// @Tags 后台-快捷搜索表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query quicksearchser.WebListReq false "请求参数"
|
||||
// @Success 200 object quicksearchser.WebListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Security BasicAuth
|
||||
// @Router /api/web/admin/quickSearch/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req = &quicksearchser.WebListReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := req.GetList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, res)
|
||||
}
|
||||
|
||||
// Create doc
|
||||
// @Summary 新增快捷搜索表
|
||||
// @Description 新增快捷搜索表
|
||||
// @Tags 后台-快捷搜索表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body quicksearchser.WebCreateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Security BasicAuth
|
||||
// @Router /api/web/admin/quickSearch/create [post]
|
||||
func Create(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &quicksearchser.WebCreateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 创建
|
||||
err = p.Create()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "快捷搜索表管理", "创建", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 更新快捷搜索表
|
||||
// @Description 更新快捷搜索表
|
||||
// @Tags 后台-快捷搜索表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body quicksearchser.WebUpdateReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Security BasicAuth
|
||||
// @Router /api/web/admin/quickSearch/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &quicksearchser.WebUpdateReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
// 更新
|
||||
err = p.Update()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "快捷搜索表管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
|
||||
// Delete doc
|
||||
// @Summary 删除快捷搜索表
|
||||
// @Description 删除快捷搜索表
|
||||
// @Tags 后台-快捷搜索表
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body quicksearchser.WebDeleteReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Security BasicAuth
|
||||
// @Router /api/web/admin/quickSearch/delete [post]
|
||||
func Delete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := &quicksearchser.WebDeleteReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 删除
|
||||
err = p.Delete()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, "快捷搜索表管理", "删除", string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package rechargectrl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/rchgutil"
|
||||
"91porn-server/web/service/rechargeser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// DaBaiShaCallBack 金鱼结构回调函数
|
||||
func DaBaiShaCallBack(ctx *gin.Context) {
|
||||
if err := func() error {
|
||||
rchg := rchgutil.DaBaiShaRes{}
|
||||
g := rchgutil.DaBaiSha{}
|
||||
if err := ctx.ShouldBindJSON(&rchg); err != nil {
|
||||
log.Error(fmt.Sprintf("DaBaiSha callback parameter bind fail error:%+v:", err))
|
||||
return err
|
||||
}
|
||||
bs, _ := json.Marshal(rchg)
|
||||
log.Info(fmt.Sprintf("DaBaiSha callback parameter data:%+v:", string(bs)))
|
||||
buf := bytes.Buffer{}
|
||||
buf.WriteString(strconv.Itoa(rchg.Code))
|
||||
buf.WriteString(rchg.MercID)
|
||||
buf.WriteString(rchg.OID)
|
||||
buf.WriteString(rchg.PayMoney)
|
||||
buf.WriteString(rchg.TradeNo)
|
||||
buf.WriteString(g.GetAppSecret())
|
||||
if !rchgutil.VerifySign(rchg.Sign, buf.String()) {
|
||||
log.Error("DaBaiSha callback sign verify fail")
|
||||
return errors.New("check sign fail")
|
||||
}
|
||||
payMoneyf, err := strconv.ParseFloat(rchg.PayMoney, 64)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("DaBaiSha callback ParseFloat fail error:%+v:", err))
|
||||
return fmt.Errorf("invalid payMoney %s", rchg.PayMoney)
|
||||
}
|
||||
payMoneyf = payMoneyf * 100
|
||||
payMoney := int64(payMoneyf)
|
||||
g.TradeNo = rchg.TradeNo
|
||||
msg, err := g.QueryOrder()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if msg.PayTime == "" {
|
||||
return errors.New("querry order err,no payTime")
|
||||
}
|
||||
loc, _ := time.LoadLocation("Local")
|
||||
paymentAt, err := time.ParseInLocation("2006-01-02T15:04:05Z07:00", msg.PayTime, loc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = rechargeser.RechargeCallBack(ctx, rchg.OID, payMoney, rchg.TradeNo, rchg.Code, paymentAt); err != nil {
|
||||
log.Error(fmt.Sprintf("DaBaiSha RechargeCallBack fail error:%+v:", err))
|
||||
}
|
||||
return err
|
||||
}(); err != nil {
|
||||
ctx.String(http.StatusBadRequest, "fail")
|
||||
return
|
||||
}
|
||||
ctx.String(http.StatusOK, "success")
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package rechargectrl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/rchgutil"
|
||||
"91porn-server/web/service/rechargeser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// DXZhiFuCallBack 金鱼结构回调函数
|
||||
func DXZhiFuCallBack(ctx *gin.Context) {
|
||||
if err := func() error {
|
||||
rchg := rchgutil.DXZhiFuRes{}
|
||||
err := ctx.ShouldBind(&rchg)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("DXZhiFu callback parameter bind fail error:%+v:", err))
|
||||
return err
|
||||
}
|
||||
log.Info(fmt.Sprintf("DXZhiFu callback parameter data:%+v:", rchg))
|
||||
if rchg.Sign != rchg.ToSign() {
|
||||
log.Error(fmt.Sprintf("DXZhiFu callback sign verify fail error:%+v:", err))
|
||||
return errors.New("check sign fail")
|
||||
}
|
||||
payMoneyf, err := strconv.ParseFloat(rchg.PayMoney, 64)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("DXZhiFu callback ParseFloat fail error:%+v:", err))
|
||||
return fmt.Errorf("invalid payMoney %s", rchg.PayMoney)
|
||||
}
|
||||
payMoneyf = payMoneyf * 100
|
||||
payMoney := int64(payMoneyf)
|
||||
var status int = 200
|
||||
if rchg.Code != "00" {
|
||||
return nil
|
||||
}
|
||||
loc, _ := time.LoadLocation("Local")
|
||||
paymentAt, _ := time.ParseInLocation("20060102150405", rchg.DateTime, loc)
|
||||
if err = rechargeser.RechargeCallBack(ctx, rchg.OID, payMoney, rchg.TradeNo, status, paymentAt); err != nil {
|
||||
log.Error(fmt.Sprintf("DXZhiFu RechargeCallBack fail error:%+v:", err))
|
||||
}
|
||||
return err
|
||||
}(); err != nil {
|
||||
ctx.String(http.StatusBadRequest, "fail")
|
||||
return
|
||||
}
|
||||
ctx.String(http.StatusOK, "OK")
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user