@@ -0,0 +1,236 @@
|
||||
package vidctrl
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/discount_area_mod"
|
||||
"91porn-server/web/service/discount_area_ser"
|
||||
"encoding/json"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// DiscountAreaList doc
|
||||
// @Summary 获取折扣专区列表
|
||||
// @Description 获取折扣专区列表
|
||||
// @Tags discountArea
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {object} discount_area_mod.WebDiscountAreaListResp "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} string "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/discount_area/list [get]
|
||||
func DiscountAreaList(ctx *gin.Context) {
|
||||
list, err := discount_area_mod.GetAllNoDeleteDiscountArea()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, &discount_area_mod.WebDiscountAreaListResp{
|
||||
List: list,
|
||||
})
|
||||
}
|
||||
|
||||
// DiscountAreaAdd doc
|
||||
// @Summary 新增折扣专区
|
||||
// @Description 新增折扣专区
|
||||
// @Tags discountArea
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param title formData string true "标题"
|
||||
// @Param desc formData string true "描述"
|
||||
// @Param discount formData integer true "折扣,1折 10,1.5折 15"
|
||||
// @Param status formData integer true "0-未开启 1-开启"
|
||||
// @Param sortCode formData integer true "排序字段"
|
||||
// @Param recommendNum formData integer true "推荐展示视频个数"
|
||||
// @Success 200 {object} string "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} string "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/discount_area/add [post]
|
||||
func DiscountAreaAdd(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := discount_area_mod.WebDiscountAreaAddReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if req.Discount < 0 || req.Discount > 100 {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
err = discount_area_ser.AddDiscountArea(&req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoDiscountArea, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// DiscountAreaUpdate doc
|
||||
// @Summary 修改折扣专区
|
||||
// @Description 修改折扣专区
|
||||
// @Tags discountArea
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData string true "id"
|
||||
// @Param title formData string false "标题"
|
||||
// @Param desc formData string false "描述"
|
||||
// @Param discount formData integer false "折扣,1折 10,1.5折 15"
|
||||
// @Param status formData integer false "0-未开启 1-开启"
|
||||
// @Param sortCode formData integer false "排序字段"
|
||||
// @Param recommendNum formData integer true "推荐展示视频个数"
|
||||
// @Success 200 {object} string "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} string "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/discount_area/update [post]
|
||||
func DiscountAreaUpdate(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := discount_area_mod.WebDiscountAreaUpdateReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if req.Discount != nil && (*req.Discount < 0 || *req.Discount > 100) {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
err = discount_area_ser.UpdateDiscountArea(&req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoDiscountArea, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// DiscountAreaDelete doc
|
||||
// @Summary 删除折扣专区
|
||||
// @Description 删除折扣专区
|
||||
// @Tags discountArea
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData integer true "id"
|
||||
// @Success 200 {object} string "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} string "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/discount_area/delete [post]
|
||||
func DiscountAreaDelete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := discount_area_mod.WebDiscountAreaDeleteReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
err = discount_area_ser.DeleteDiscountArea(req.ID)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, nil)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoDiscountArea, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// DiscountAreaVids doc
|
||||
// @Summary 折扣专区视频列表
|
||||
// @Description 折扣专区视频列表
|
||||
// @Tags discountArea
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param pageNumber formData integer true "页码数"
|
||||
// @Param pageSize formData integer true "页码数"
|
||||
// @Param discountAreaId formData string true "折扣专区id"
|
||||
// @Param vid formData string true "帖子id"
|
||||
// @Success 200 {object} discount_area_mod.WebDiscountAreaVidsResp "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} string "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/discount_area/vid/list [get]
|
||||
func DiscountAreaVids(ctx *gin.Context) {
|
||||
req := discount_area_mod.WebDiscountAreaVidsReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
list, total, err := discount_area_ser.GetDiscountAreaVids(&req)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, &discount_area_mod.WebDiscountAreaVidsResp{
|
||||
List: list,
|
||||
Total: total,
|
||||
})
|
||||
}
|
||||
|
||||
// DiscountAreaAddVid doc
|
||||
// @Summary 折扣专区新增视频
|
||||
// @Description 折扣专区新增视频
|
||||
// @Tags discountArea
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param discountAreaId formData string true "折扣专区id"
|
||||
// @Param vids formData []string true "帖子id"
|
||||
// @Success 200 {object} string "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} string "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/discount_area/vid/add [post]
|
||||
func DiscountAreaAddVid(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := discount_area_mod.WebDiscountAreaAddVidReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code := discount_area_ser.DiscountAreaAddVid(&req)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoDiscountAreaVideo, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
}
|
||||
|
||||
// DiscountAreaDeleteVid doc
|
||||
// @Summary 折扣专区删除视频
|
||||
// @Description 折扣专区删除视频
|
||||
// @Tags discountArea
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param vids formData []string true "视频id"
|
||||
// @Success 200 {object} string "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} string "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/discount_area/vid/delete [post]
|
||||
func DiscountAreaDeleteVid(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := discount_area_mod.WebDiscountAreaDeleteVidReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
code := discount_area_ser.DiscountAreaDeleteVid(req.Ids)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.VideoDiscountAreaVideo, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
}
|
||||
Reference in New Issue
Block a user