diff --git a/api/proto/streamerauthapproval/proto/streamerauthapproval_api.go b/api/proto/streamerauthapproval/proto/streamerauthapproval_api.go index 5ba85823..d75e2cc8 100644 --- a/api/proto/streamerauthapproval/proto/streamerauthapproval_api.go +++ b/api/proto/streamerauthapproval/proto/streamerauthapproval_api.go @@ -40,7 +40,7 @@ type ApiListReq struct { } type ApiListData struct { - StreamerAuthApproval *dbstruct.StreamerAuthApproval `json:"streamer_auth_approval"` + StreamerAuthApproval *StreamerAuthApprovalApiVO `json:"streamer_auth_approval"` } type ApiListResp struct { diff --git a/api/proto/streamerauthapproval/proto/streamerauthapproval_api_vo.go b/api/proto/streamerauthapproval/proto/streamerauthapproval_api_vo.go new file mode 100644 index 00000000..0fd4039d --- /dev/null +++ b/api/proto/streamerauthapproval/proto/streamerauthapproval_api_vo.go @@ -0,0 +1,18 @@ +package proto + +import "service/dbstruct" + +type StreamerAuthApprovalApiVO struct { + *dbstruct.StreamerAuthApproval + UserId *int64 `json:"user_id"` +} + +func (vo *StreamerAuthApprovalApiVO) CopyStreamerAuthApproval(streamerauthapproval *dbstruct.StreamerAuthApproval) *StreamerAuthApprovalApiVO { + vo.StreamerAuthApproval = streamerauthapproval + return vo +} + +func (vo *StreamerAuthApprovalApiVO) CopyAccount(account *dbstruct.Account) *StreamerAuthApprovalApiVO { + vo.UserId = account.UserId + return vo +} diff --git a/api/proto/streamerauthapproval/proto/streamerauthapproval_op.go b/api/proto/streamerauthapproval/proto/streamerauthapproval_op.go index 0cf3d872..0a7b84ca 100644 --- a/api/proto/streamerauthapproval/proto/streamerauthapproval_op.go +++ b/api/proto/streamerauthapproval/proto/streamerauthapproval_op.go @@ -56,9 +56,9 @@ type OpListReq struct { } type OpListData struct { - List []*dbstruct.StreamerAuthApproval `json:"list"` - Offset int `json:"offset"` - More int `json:"more"` + List []*StreamerAuthApprovalOpVO `json:"list"` + Offset int `json:"offset"` + More int `json:"more"` } type OpListResp struct { @@ -75,9 +75,9 @@ type OpListByMidReq struct { } type OpListByMidData struct { - StreamerAuthApproval *dbstruct.StreamerAuthApproval `json:"streamer_auth_approval"` - Offset int `json:"offset"` - More int `json:"more"` + StreamerAuthApproval *StreamerAuthApprovalOpVO `json:"streamer_auth_approval"` + Offset int `json:"offset"` + More int `json:"more"` } type OpListByMidResp struct { diff --git a/api/proto/streamerauthapproval/proto/streamerauthapproval_op_vo.go b/api/proto/streamerauthapproval/proto/streamerauthapproval_op_vo.go new file mode 100644 index 00000000..8db359b3 --- /dev/null +++ b/api/proto/streamerauthapproval/proto/streamerauthapproval_op_vo.go @@ -0,0 +1,18 @@ +package proto + +import "service/dbstruct" + +type StreamerAuthApprovalOpVO struct { + *dbstruct.StreamerAuthApproval + UserId *int64 `json:"user_id"` +} + +func (vo *StreamerAuthApprovalOpVO) CopyStreamerAuthApproval(streamerauthapproval *dbstruct.StreamerAuthApproval) *StreamerAuthApprovalOpVO { + vo.StreamerAuthApproval = streamerauthapproval + return vo +} + +func (vo *StreamerAuthApprovalOpVO) CopyAccount(account *dbstruct.Account) *StreamerAuthApprovalOpVO { + vo.UserId = account.UserId + return vo +} diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 8561da23..e71ee1b8 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -834,7 +834,7 @@ func (s *Service) ApiDeleteStreamerAuthApproval(ctx *gin.Context, req *streamera return } -func (s *Service) ApiGetStreamerAuthApprovalList(ctx *gin.Context, req *streamerauthapprovalproto.ApiListReq) (streamerauthapproval *dbstruct.StreamerAuthApproval, ec errcode.ErrCode) { +func (s *Service) ApiGetStreamerAuthApprovalList(ctx *gin.Context, req *streamerauthapprovalproto.ApiListReq) (vo *streamerauthapprovalproto.StreamerAuthApprovalApiVO, ec errcode.ErrCode) { ec = errcode.ErrCodeStreamerAuthApprovalSrvOk if ec = s.ApiGetStreamerAuthApprovalListBusinessValidate(ctx, req); ec != errcode.ErrCodeStreamerAuthApprovalSrvOk { @@ -849,6 +849,20 @@ func (s *Service) ApiGetStreamerAuthApprovalList(ctx *gin.Context, req *streamer ec = errcode.ErrCodeStreamerAuthApprovalSrvFail return } + + account, err := _DefaultAccount.OpListByMid(ctx, &accountproto.OpListByMidReq{ + Mid: streamerauthapproval.Mid, + }) + if err != nil { + logger.Error("OpListByMid fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeAccountSrvFail + return + } + + vo = &streamerauthapprovalproto.StreamerAuthApprovalApiVO{} + vo.CopyStreamerAuthApproval(streamerauthapproval) + vo.CopyAccount(account) + return } diff --git a/app/mix/service/service.go b/app/mix/service/service.go index 38fdb9ff..1369403b 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -1232,52 +1232,7 @@ func (s *Service) OpGetAccountRelationBySentence(ctx *gin.Context, req *accountr return } -// StreamerAuthApproval -// func (s *Service) OpCreateStreamerAuthApproval(ctx *gin.Context, req *streamerauthapprovalproto.OpCreateReq) (ec errcode.ErrCode) { -// ec = errcode.ErrCodeStreamerAuthApprovalSrvOk -// err := _DefaultStreamerAuthApproval.OpCreate(ctx, req) - -// if mongo.IsDuplicateKeyError(err) { -// logger.Error("OpCreate duplicate key found, req: %v, err: %v", util.ToJson(req), err) -// ec = errcode.ErrCodeStreamerAuthApprovalDuplicateKey -// return -// } -// if err != nil { -// logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err) -// ec = errcode.ErrCodeStreamerAuthApprovalSrvFail -// return -// } -// return -// } - -// func (s *Service) OpUpdateStreamerAuthApproval(ctx *gin.Context, req *streamerauthapprovalproto.OpUpdateReq) (ec errcode.ErrCode) { -// ec = errcode.ErrCodeStreamerAuthApprovalSrvOk -// err := _DefaultStreamerAuthApproval.OpUpdate(ctx, req) -// if err == qmgo.ErrNoSuchDocuments { -// ec = errcode.ErrCodeStreamerAuthApprovalNotExist -// err = nil -// return -// } -// if err != nil { -// logger.Error("OpUpdate fail, req: %v, err: %v", util.ToJson(req), err) -// ec = errcode.ErrCodeStreamerAuthApprovalSrvFail -// return -// } -// return -// } - -// func (s *Service) OpDeleteBatchStreamerAuthApproval(ctx *gin.Context, ids []int64) (ec errcode.ErrCode) { -// ec = errcode.ErrCodeStreamerAuthApprovalSrvOk -// err := _DefaultStreamerAuthApproval.OpDeleteBatch(ctx, ids) -// if err != nil { -// logger.Error("OpDeleteBatch fail, ids: %v, err: %v", ids, err) -// ec = errcode.ErrCodeStreamerAuthApprovalSrvFail -// return -// } -// return -// } - -func (s *Service) OpGetStreamerAuthApprovalList(ctx *gin.Context, req *streamerauthapprovalproto.OpListReq) (list []*dbstruct.StreamerAuthApproval, ec errcode.ErrCode) { +func (s *Service) OpGetStreamerAuthApprovalList(ctx *gin.Context, req *streamerauthapprovalproto.OpListReq) (volist []*streamerauthapprovalproto.StreamerAuthApprovalOpVO, ec errcode.ErrCode) { ec = errcode.ErrCodeStreamerAuthApprovalSrvOk if ec = s.OpGetStreamerAuthApprovalListBusinessValidate(ctx, req); ec != errcode.ErrCodeStreamerAuthApprovalSrvOk { @@ -1290,6 +1245,26 @@ func (s *Service) OpGetStreamerAuthApprovalList(ctx *gin.Context, req *streamera ec = errcode.ErrCodeStreamerAuthApprovalSrvFail return } + + //查询获得userId + midList := make([]int64, len(list)) + for i, v := range list { + midList[i] = util.DerefInt64(v.Mid) + } + _map, err := _DefaultAccount.GetAccountMapByMids(ctx, midList) + if err != nil { + logger.Error("GetAccountMapByMids fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeAccountSrvFail + return + } + + volist = make([]*streamerauthapprovalproto.StreamerAuthApprovalOpVO, len(list)) + for i, streamerauthapproval := range list { + volist[i] = &streamerauthapprovalproto.StreamerAuthApprovalOpVO{} + volist[i].CopyStreamerAuthApproval(streamerauthapproval) + volist[i].CopyAccount(_map[util.DerefInt64(volist[i].Mid)]) + } + return }