116 lines
3.9 KiB
Go
116 lines
3.9 KiB
Go
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)
|
|
}
|