service/app/mix/controller/accountpunishment_op.go

96 lines
2.7 KiB
Go

package controller
import (
"service/api/consts"
"service/api/errcode"
accountpunishmentproto "service/api/proto/accountpunishment/proto"
"service/app/mix/service"
"service/bizcommon/util"
"service/library/logger"
"service/library/mediafiller"
"github.com/gin-gonic/gin"
)
func OpCreateAccountPunishment(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*accountpunishmentproto.OpCreateReq)
ec := service.DefaultService.OpCreateAccountPunishment(ctx, req)
if ec != errcode.ErrCodeAccountPunishmentSrvOk {
logger.Error("OpCreateAccountPunishment fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, nil)
}
func OpGetAccountPunishmentList(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*accountpunishmentproto.OpListReq)
//设置默认页长
if req.Limit == 0 {
req.Limit = consts.DefaultPageSize
}
list, ec := service.DefaultService.OpGetAccountPunishmentList(ctx, req)
if ec != errcode.ErrCodeAccountPunishmentSrvOk {
logger.Error("OpGetAccountPunishmentList fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
//填充媒体切片
objectMediaNum := 1 // 单个账号封禁服务总共1个媒体类
mediafillables := make([]mediafiller.MediaFillable, len(list)*objectMediaNum)
for i, vo := range list {
mediafillables[objectMediaNum*i+0] = vo.Account.Avatar
}
mediafiller.FillList(ctx, mediafillables)
data := &accountpunishmentproto.OpListData{
List: list,
}
ReplyOk(ctx, data)
}
func OpUnblockAccountPunishment(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*accountpunishmentproto.OpUnblockReq)
ec := service.DefaultService.OpUnblockAccountPunishment(ctx, req)
if ec != errcode.ErrCodeAccountPunishmentSrvOk {
logger.Error("OpUnblockAccountPunishment fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, nil)
}
func OpGetTerminatedAccountPunishmentList(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*accountpunishmentproto.OpListTerminatedReq)
//设置默认页长
if req.Limit == 0 {
req.Limit = consts.DefaultPageSize
}
list, ec := service.DefaultService.OpGetTerminatedAccountPunishmentList(ctx, req)
if ec != errcode.ErrCodeAccountPunishmentSrvOk {
logger.Error("OpGetTerminatedAccountPunishmentList fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
//填充媒体切片
objectMediaNum := 1 // 单个账号封禁服务总共1个媒体类
mediafillables := make([]mediafiller.MediaFillable, len(list)*objectMediaNum)
for i, vo := range list {
mediafillables[objectMediaNum*i+0] = vo.Account.Avatar
}
mediafiller.FillList(ctx, mediafillables)
data := &accountpunishmentproto.OpListData{
List: list,
}
ReplyOk(ctx, data)
}