Merge pull request 'by Robin at 20240422' (#306) from dev-feat-IRONFANS-70-Robin into feat-IRONFANS-70
Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/306
This commit is contained in:
commit
a5837da513
|
@ -57,9 +57,10 @@ type ApiListReq struct {
|
|||
}
|
||||
|
||||
type ApiListData struct {
|
||||
List []*ZoneCollaboratorApiVO `json:"list"`
|
||||
Offset int `json:"offset"`
|
||||
More int `json:"more"`
|
||||
List []*ZoneCollaboratorApiVO `json:"list"`
|
||||
ZoneThirdPartner *dbstruct.ZoneThirdPartner `json:"zone_third_partner"`
|
||||
Offset int `json:"offset"`
|
||||
More int `json:"more"`
|
||||
}
|
||||
|
||||
type ApiListResp struct {
|
||||
|
|
|
@ -56,7 +56,7 @@ func ApiGetZoneCollaboratorList(ctx *gin.Context) {
|
|||
req.Limit = consts.DefaultPageSize
|
||||
}
|
||||
|
||||
list, ec := service.DefaultService.ApiGetZoneCollaboratorList(ctx, req)
|
||||
list, zoneThirdPartner, ec := service.DefaultService.ApiGetZoneCollaboratorList(ctx, req)
|
||||
if ec != errcode.ErrCodeZoneCollaboratorSrvOk {
|
||||
logger.Error("ApiGetZoneCollaboratorList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
|
@ -71,8 +71,9 @@ func ApiGetZoneCollaboratorList(ctx *gin.Context) {
|
|||
mediafiller.FillList(ctx, mediaFillableList)
|
||||
|
||||
data := &zone_collaborator_proto.ApiListData{
|
||||
List: list,
|
||||
Offset: req.Offset + len(list),
|
||||
List: list,
|
||||
ZoneThirdPartner: zoneThirdPartner,
|
||||
Offset: req.Offset + len(list),
|
||||
}
|
||||
if len(list) >= req.Limit {
|
||||
data.More = 1
|
||||
|
|
|
@ -3033,6 +3033,11 @@ func (s *Service) ApiGetZoneThirdPartnerList(ctx *gin.Context, req *zone_third_p
|
|||
// ZoneCollaborator
|
||||
func (s *Service) ApiCreateZoneCollaborator(ctx *gin.Context, req *zone_collaborator_proto.ApiCreateReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneCollaboratorSrvOk
|
||||
|
||||
if ec = s.ApiCreateZoneCollaboratorBusinessValidate(ctx, req); ec != errcode.ErrCodeZoneCollaboratorSrvOk {
|
||||
return
|
||||
}
|
||||
|
||||
err := _DefaultZoneCollaborator.OpCreate(ctx, &zone_collaborator_proto.OpCreateReq{
|
||||
BaseRequest: req.BaseRequest,
|
||||
ZoneCollaborator: req.ZoneCollaborator,
|
||||
|
@ -3081,8 +3086,10 @@ func (s *Service) ApiDeleteZoneCollaborator(ctx *gin.Context, id int64) (ec errc
|
|||
return
|
||||
}
|
||||
|
||||
func (s *Service) ApiGetZoneCollaboratorList(ctx *gin.Context, req *zone_collaborator_proto.ApiListReq) (volist []*zone_collaborator_proto.ZoneCollaboratorApiVO, ec errcode.ErrCode) {
|
||||
func (s *Service) ApiGetZoneCollaboratorList(ctx *gin.Context, req *zone_collaborator_proto.ApiListReq) (volist []*zone_collaborator_proto.ZoneCollaboratorApiVO, zoneThirdPartner *dbstruct.ZoneThirdPartner, ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneCollaboratorSrvOk
|
||||
|
||||
// 查询协作者表
|
||||
list, err := _DefaultZoneCollaborator.OpList(ctx, &zone_collaborator_proto.OpListReq{
|
||||
BaseRequest: req.BaseRequest,
|
||||
Zid: req.Zid,
|
||||
|
@ -3093,35 +3100,44 @@ func (s *Service) ApiGetZoneCollaboratorList(ctx *gin.Context, req *zone_collabo
|
|||
ec = errcode.ErrCodeZoneCollaboratorSrvFail
|
||||
return
|
||||
}
|
||||
if len(list) == 0 {
|
||||
return make([]*zone_collaborator_proto.ZoneCollaboratorApiVO, 0), errcode.ErrCodeZoneCollaboratorNotExist
|
||||
}
|
||||
|
||||
midSet := make(map[int64]*dbstruct.Moment)
|
||||
mids := make([]int64, 0)
|
||||
for _, zone_collaborator := range list {
|
||||
mid := zone_collaborator.GetCollaboratorMid()
|
||||
if midSet[mid] == nil {
|
||||
midSet[mid] = &dbstruct.Moment{}
|
||||
mids = append(mids, mid)
|
||||
// 填充协作者VO
|
||||
volist = make([]*zone_collaborator_proto.ZoneCollaboratorApiVO, 0)
|
||||
if len(list) > 0 {
|
||||
midSet := make(map[int64]*dbstruct.Moment)
|
||||
mids := make([]int64, 0)
|
||||
for _, zone_collaborator := range list {
|
||||
mid := zone_collaborator.GetCollaboratorMid()
|
||||
if midSet[mid] == nil {
|
||||
midSet[mid] = &dbstruct.Moment{}
|
||||
mids = append(mids, mid)
|
||||
}
|
||||
}
|
||||
|
||||
acctMp, err := _DefaultAccount.GetAccountMapByMids(ctx, mids)
|
||||
if err != nil {
|
||||
logger.Error("_DefaultAccount GetAccountMapByMids fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeAccountSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
for _, zone_collaborator := range list {
|
||||
mid := zone_collaborator.GetCollaboratorMid()
|
||||
vo := &zone_collaborator_proto.ZoneCollaboratorApiVO{
|
||||
ZoneCollaborator: zone_collaborator,
|
||||
Account: acctMp[mid],
|
||||
}
|
||||
volist = append(volist, vo)
|
||||
}
|
||||
}
|
||||
|
||||
acctMp, err := _DefaultAccount.GetAccountMapByMids(ctx, mids)
|
||||
// 查询代运营信息
|
||||
zoneThirdPartner, err = _DefaultZoneThirdPartner.GetZoneThirdPartnerByZid(ctx, util.DerefInt64(req.Zid))
|
||||
if err != nil {
|
||||
logger.Error("_DefaultAccount GetAccountMapByMids fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeAccountSrvFail
|
||||
logger.Error("_DefaultZoneThirdPartner GetZoneThirdPartnerByZid fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeZoneThirdPartnerSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
for _, zone_collaborator := range list {
|
||||
mid := zone_collaborator.GetCollaboratorMid()
|
||||
vo := &zone_collaborator_proto.ZoneCollaboratorApiVO{
|
||||
ZoneCollaborator: zone_collaborator,
|
||||
Account: acctMp[mid],
|
||||
}
|
||||
volist = append(volist, vo)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
streamerproto "service/api/proto/streamer/proto"
|
||||
streamerauthapprovalproto "service/api/proto/streamerauthapproval/proto"
|
||||
vericodeproto "service/api/proto/vericode/proto"
|
||||
zone_collaborator_proto "service/api/proto/zone_collaborator/proto"
|
||||
zone_third_partner_proto "service/api/proto/zone_third_partner/proto"
|
||||
zonemomentproto "service/api/proto/zonemoment/proto"
|
||||
businessvalidator "service/app/mix/service/business_validator"
|
||||
|
@ -581,7 +582,7 @@ func (s *Service) ApiCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zon
|
|||
func (s *Service) ApiCreateZoneThirdPartnerBusinessValidate(ctx *gin.Context, req *zone_third_partner_proto.ApiCreateReq) (vericode *dbstruct.VeriCode, ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeLoginSrvOk
|
||||
|
||||
// 1.业务校验
|
||||
// 1.登录业务校验
|
||||
req.CalcPhoneHash() //计算手机号哈希
|
||||
resultList := businessvalidator.NewLoginBusinessValidator(ctx, req).
|
||||
QueryVeriCode(_DefaultVeriCode.OpListByPhoneHash).
|
||||
|
@ -598,5 +599,45 @@ func (s *Service) ApiCreateZoneThirdPartnerBusinessValidate(ctx *gin.Context, re
|
|||
logger.Error("ApiCreateZoneThirdPartner business validation failed!")
|
||||
return
|
||||
}
|
||||
|
||||
// 3.鉴权校验
|
||||
resultList = businessvalidator.NewAuthBusinessValidator(ctx, req).
|
||||
EnsureIsNotOperatingHisOwn(util.DerefInt64(req.ThirdPartnerMid)).
|
||||
Validate().
|
||||
Collect()
|
||||
ec, _ = resultList[0].(errcode.ErrCode)
|
||||
// 4.错误信息
|
||||
if ec == errcode.ErrCodeOperationToSelfIsNotPermitted {
|
||||
ec = errcode.ErrCodeZoneThirdPartnerWrongThirdPartner
|
||||
}
|
||||
if ec != errcode.ErrCodeOk {
|
||||
logger.Error("ApiCreateZoneThirdPartner business validation failed!")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Service) ApiCreateZoneCollaboratorBusinessValidate(ctx *gin.Context, req *zone_collaborator_proto.ApiCreateReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneCollaboratorSrvOk
|
||||
|
||||
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
||||
QueryZoneThirdPartnerByZid(_DefaultZoneThirdPartner.GetZoneThirdPartnerByZid, util.DerefInt64(req.Zid)).
|
||||
EnsureZoneThirdPartnerExist().
|
||||
EnsureZoneCollaboratorCreaterIsZoneThirdPartner(req.GetBaseRequest().Mid).
|
||||
EnsureIsNotOperatingHisOwn(util.DerefInt64(req.CollaboratorMid)).
|
||||
QueryAccountForUid(_DefaultAccount.OpListByMid, util.DerefInt64(req.CollaboratorMid)).
|
||||
EnsureIsNotThisRole(consts.Streamer).
|
||||
Validate().
|
||||
Collect()
|
||||
ec = result[0].(errcode.ErrCode)
|
||||
if ec == errcode.ErrCodeOperationToSelfIsNotPermitted || ec == errcode.ErrCodeRolePrivilegesNotEnough {
|
||||
ec = errcode.ErrCodeZoneCollaboratorWrongCollaborator
|
||||
}
|
||||
if ec != errcode.ErrCodeOk {
|
||||
logger.Error("ApiGetAccountRelationCount business validation failed")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue