service/app/mix/controller/realname_authentication_op.go

61 lines
1.7 KiB
Go

package controller
import (
"service/api/consts"
"service/api/errcode"
realname_authenticationproto "service/api/proto/realname_authentication/proto"
"service/app/mix/service"
"service/bizcommon/util"
"service/library/logger"
"service/library/mediafiller"
"github.com/gin-gonic/gin"
)
func OpGetRealNameAuthenticationList(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*realname_authenticationproto.OpListReq)
//设置默认页长
if req.Limit == 0 {
req.Limit = consts.DefaultPageSize
}
list, ec := service.DefaultService.OpGetRealNameAuthenticationList(ctx, req)
if ec != errcode.ErrCodeRealNameAuthenticationSrvOk {
logger.Error("OpGetRealNameAuthenticationList fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
//填充媒体切片
objectMediaNum := 2 // 单个主播服务总共2个媒体类
mediaFillableList := make([]mediafiller.MediaFillable, len(list)*objectMediaNum)
for i, vo := range list {
mediaFillableList[objectMediaNum*i+0] = vo.IDCardPhotos
mediaFillableList[objectMediaNum*i+1] = vo.FullFacePhotoWithIDCardInHand
}
mediafiller.FillList(ctx, mediaFillableList)
data := &realname_authenticationproto.OpListData{
List: list,
Offset: req.Offset + len(list),
}
if len(list) >= req.Limit {
data.More = 1
}
ReplyOk(ctx, data)
}
func OpApproveRealNameAuthentication(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*realname_authenticationproto.OpApproveReq)
ec := service.DefaultService.OpApproveRealNameAuthentication(ctx, req)
if ec != errcode.ErrCodeRealNameAuthenticationSrvOk {
logger.Error("OpApproveRealNameAuthentication fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, nil)
}