diff --git a/api/proto/account/proto/account_api.go b/api/proto/account/proto/account_api.go index 5c42bba4..22d742ff 100644 --- a/api/proto/account/proto/account_api.go +++ b/api/proto/account/proto/account_api.go @@ -97,48 +97,6 @@ type ApiListByUserIdResp struct { Data *ApiListByUserIdData `json:"data"` } -// 根据UserId模糊查询(和姓名取交集) -type ApiListFuzzilyByUserIdReq struct { - base.BaseRequest - UserId *int64 `json:"user_id"` //user_id模糊匹配 - Role *int64 `json:"role"` //角色 - Offset int `json:"offset"` - Limit int `json:"limit"` - Sort []string -} - -type ApiListFuzzilyByUserIdData struct { - List []*ApiListVO `json:"list"` - Offset int `json:"offset"` - More int `json:"more"` -} - -type ApiListFuzzilyByUserIdResp struct { - base.BaseResponse - Data *ApiListFuzzilyByUserIdData `json:"data"` -} - -// 根据Name模糊查询 -type ApiListFuzzilyByNameReq struct { - base.BaseRequest - Name string `json:"name"` //name模糊匹配 - Role *int64 `json:"role"` //角色 - Offset int `json:"offset"` - Limit int `json:"limit"` - Sort []string -} - -type ApiListFuzzilyByNameData struct { - List []*ApiListVO `json:"list"` - Offset int `json:"offset"` - More int `json:"more"` -} - -type ApiListFuzzilyByNameResp struct { - base.BaseResponse - Data *ApiListFuzzilyByNameData `json:"data"` -} - // api 列表-查询他人 type ApiListOthersByMidReq struct { base.BaseRequest diff --git a/api/proto/account/proto/not_null_def_api.go b/api/proto/account/proto/not_null_def_api.go index a94a7403..05d113a6 100644 --- a/api/proto/account/proto/not_null_def_api.go +++ b/api/proto/account/proto/not_null_def_api.go @@ -23,18 +23,6 @@ func (p *ApiListByUserIdReq) ProvideNotNullValue() (params []*validator.JsonPara return params } -func (p *ApiListFuzzilyByUserIdReq) ProvideNotNullValue() (params []*validator.JsonParam) { - params = make([]*validator.JsonParam, 1) - params[0] = validator.NewInt64PtrParam("查询UserId不可为空!", p.UserId) - return params -} - -func (p *ApiListFuzzilyByNameReq) ProvideNotNullValue() (params []*validator.JsonParam) { - params = make([]*validator.JsonParam, 1) - params[0] = validator.NewStringParam("查询UserId不可为空!", p.Name) - return params -} - func (p *ApiListOthersByMidReq) ProvideNotNullValue() (params []*validator.JsonParam) { params = make([]*validator.JsonParam, 1) params[0] = validator.NewInt64PtrParam("查询Mid不可为空!", p.Mid) diff --git a/app/mix/controller/account_api.go b/app/mix/controller/account_api.go index 64605dcd..328442e2 100644 --- a/app/mix/controller/account_api.go +++ b/app/mix/controller/account_api.go @@ -98,74 +98,6 @@ func ApiGetAccountListByUserId(ctx *gin.Context) { ReplyOk(ctx, data) } -func ApiGetAccountListFuzzilyByUserId(ctx *gin.Context) { - req := ctx.MustGet("client_req").(*accountproto.ApiListFuzzilyByUserIdReq) - - //设置默认页长 - if req.Limit == 0 { - req.Limit = consts.DefaultPageSize - } - - list, ec := service.DefaultService.ApiGetAccountListFuzzilyByUserId(ctx, req) - if ec != errcode.ErrCodeAccountSrvOk { - logger.Error("ApiGetAccountListFuzzilyByUserId fail, req: %v, ec: %v", util.ToJson(req), ec) - ReplyErrCodeMsg(ctx, ec) - return - } - - //填充媒体切片 - objectMediaNum := 1 // 单个用户服务总共1个媒体类 - mediaFillableListFuzzily := make([]mediafiller.MediaFillable, len(list)*objectMediaNum) - for i, account := range list { - mediaFillableListFuzzily[objectMediaNum*i+0] = account.Avatar - } - mediafiller.FillList(ctx, mediaFillableListFuzzily) - - data := &accountproto.ApiListFuzzilyByUserIdData{ - List: list, - Offset: req.Offset + len(list), - } - if len(list) >= req.Limit { - data.More = 1 - } - - ReplyOk(ctx, data) -} - -func ApiGetAccountListFuzzilyByName(ctx *gin.Context) { - req := ctx.MustGet("client_req").(*accountproto.ApiListFuzzilyByNameReq) - - //设置默认页长 - if req.Limit == 0 { - req.Limit = consts.DefaultPageSize - } - - list, ec := service.DefaultService.ApiGetAccountListFuzzilyByName(ctx, req) - if ec != errcode.ErrCodeAccountSrvOk { - logger.Error("ApiGetAccountListFuzzilyByName fail, req: %v, ec: %v", util.ToJson(req), ec) - ReplyErrCodeMsg(ctx, ec) - return - } - - //填充媒体切片 - objectMediaNum := 1 // 单个用户服务总共1个媒体类 - mediaFillableListFuzzily := make([]mediafiller.MediaFillable, len(list)*objectMediaNum) - for i, account := range list { - mediaFillableListFuzzily[objectMediaNum*i+0] = account.Avatar - } - mediafiller.FillList(ctx, mediaFillableListFuzzily) - - data := &accountproto.ApiListFuzzilyByNameData{ - List: list, - Offset: req.Offset + len(list), - } - if len(list) >= req.Limit { - data.More = 1 - } - - ReplyOk(ctx, data) -} - func ApiGetAccountListForOthersByMid(ctx *gin.Context) { req := ctx.MustGet("client_req").(*accountproto.ApiListOthersByMidReq) diff --git a/app/mix/controller/account_op.go b/app/mix/controller/account_op.go index 1f512ddb..41afca35 100644 --- a/app/mix/controller/account_op.go +++ b/app/mix/controller/account_op.go @@ -115,74 +115,6 @@ func OpGetMobilePhoneByUserId(ctx *gin.Context) { ReplyOk(ctx, data) } -func OpGetAccountListFuzzilyByUserId(ctx *gin.Context) { - req := ctx.MustGet("client_req").(*accountproto.OpListFuzzilyByUserIdReq) - - //设置默认页长 - if req.Limit == 0 { - req.Limit = consts.DefaultPageSize - } - - list, ec := service.DefaultService.OpGetAccountListFuzzilyByUserId(ctx, req) - if ec != errcode.ErrCodeAccountSrvOk { - logger.Error("OpGetAccountListFuzzilyByUserId fail, req: %v, ec: %v", util.ToJson(req), ec) - ReplyErrCodeMsg(ctx, ec) - return - } - - //填充媒体切片 - objectMediaNum := 1 // 单个用户服务总共1个媒体类 - mediaFillableListFuzzily := make([]mediafiller.MediaFillable, len(list)*objectMediaNum) - for i, account := range list { - mediaFillableListFuzzily[objectMediaNum*i+0] = account.Avatar - } - mediafiller.FillList(ctx, mediaFillableListFuzzily) - - data := &accountproto.OpListFuzzilyByUserIdData{ - List: list, - Offset: req.Offset + len(list), - } - if len(list) >= req.Limit { - data.More = 1 - } - - ReplyOk(ctx, data) -} - -func OpGetAccountListFuzzilyByName(ctx *gin.Context) { - req := ctx.MustGet("client_req").(*accountproto.OpListFuzzilyByNameReq) - - //设置默认页长 - if req.Limit == 0 { - req.Limit = consts.DefaultPageSize - } - - list, ec := service.DefaultService.OpGetAccountListFuzzilyByName(ctx, req) - if ec != errcode.ErrCodeAccountSrvOk { - logger.Error("OpGetAccountListFuzzilyByName fail, req: %v, ec: %v", util.ToJson(req), ec) - ReplyErrCodeMsg(ctx, ec) - return - } - - //填充媒体切片 - objectMediaNum := 1 // 单个用户服务总共1个媒体类 - mediaFillableListFuzzily := make([]mediafiller.MediaFillable, len(list)*objectMediaNum) - for i, account := range list { - mediaFillableListFuzzily[objectMediaNum*i+0] = account.Avatar - } - mediafiller.FillList(ctx, mediaFillableListFuzzily) - - data := &accountproto.OpListFuzzilyByNameData{ - List: list, - Offset: req.Offset + len(list), - } - if len(list) >= req.Limit { - data.More = 1 - } - - ReplyOk(ctx, data) -} - func OpGetAccountListForOthersByMid(ctx *gin.Context) { req := ctx.MustGet("client_req").(*accountproto.OpListOthersByMidReq) diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go index d8e69e82..280caffa 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -323,8 +323,6 @@ func Init(r *gin.Engine) { //opAccountGroup.POST("list_by_mids", middleware.JSONParamValidator(accountproto.OpListByMidsReq{}), middleware.JwtAuthenticator(), OpGetAccountListByMids) opAccountGroup.POST("list_by_user_id", middleware.JSONParamValidator(accountproto.OpListByUserIdReq{}), middleware.JwtAuthenticator(), OpGetAccountListByUserId) opAccountGroup.POST("get_mobile_phone_by_user_id", middleware.JSONParamValidator(accountproto.OpGetMobilePhoneByUserIdReq{}), middleware.JwtAuthenticator(), OpGetMobilePhoneByUserId) - opAccountGroup.POST("list_fuzzily_by_user_id", middleware.JSONParamValidator(accountproto.OpListFuzzilyByUserIdReq{}), middleware.JwtAuthenticator(), OpGetAccountListFuzzilyByUserId) - opAccountGroup.POST("list_fuzzily_by_name", middleware.JSONParamValidator(accountproto.OpListFuzzilyByNameReq{}), middleware.JwtAuthenticator(), OpGetAccountListFuzzilyByName) opAccountGroup.POST("list_others_by_mid", middleware.JSONParamValidator(accountproto.OpListOthersByMidReq{}), middleware.JwtAuthenticator(), OpGetAccountListForOthersByMid) opAccountGroup.POST("list_others_by_mids", middleware.JSONParamValidator(accountproto.OpListOthersByMidsReq{}), middleware.JwtAuthenticator(), OpGetAccountListForOthersByMids) opAccountGroup.POST("count", middleware.JSONParamValidator(accountproto.OpCountReq{}), middleware.JwtAuthenticator(), OpGetAccountCount) diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index bd034840..3fc578f3 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -101,9 +101,10 @@ const ( DBToken = "token" COLToken = "token" - DBAccount = "account" - COLAccount = "account" - COLAccountHis = "account_his" + DBAccount = "account" + COLAccount = "account" + COLAccountHis = "account_his" + COLStreamerAcct = "streamer_acct" DBVeriCode = "vericode" COLVeriCode = "vericode" @@ -303,6 +304,11 @@ func (m *Mongo) getColAccountHis() *qmgo.Collection { return m.clientMix.Database(DBAccount).Collection(COLAccountHis) } +// Streamer_Acct表 +func (m *Mongo) getColStreamerAcct() *qmgo.Collection { + return m.clientMix.Database(DBAccount).Collection(COLStreamerAcct) +} + // VeriCode表 func (m *Mongo) getColVeriCode() *qmgo.Collection { return m.clientMix.Database(DBVeriCode).Collection(COLVeriCode) @@ -1240,18 +1246,15 @@ func (m *Mongo) GetAccountListByPhoneHash(ctx *gin.Context, phonehash string) ([ return list, err } -func (m *Mongo) GetAccountListFuzzilyByName(ctx *gin.Context, req *accountproto.OpListFuzzilyByNameReq) ([]*dbstruct.Account, error) { - list := make([]*dbstruct.Account, 0) - col := m.getColAccount() +func (m *Mongo) GetStreamerAcctListFuzzilyByName(ctx *gin.Context, req *accountproto.OpListFuzzilyByNameReq) ([]*dbstruct.StreamerAcct, error) { + list := make([]*dbstruct.StreamerAcct, 0) + col := m.getColStreamerAcct() query := qmgo.M{ "del_flag": 0, "name": bson.M{ "$regex": req.Name, }, } - if req.Role != nil { - query["role"] = util.DerefInt64(req.Role) - } if len(req.Sort) == 0 { req.Sort = append(req.Sort, "-ct") } @@ -1264,9 +1267,9 @@ func (m *Mongo) GetAccountListFuzzilyByName(ctx *gin.Context, req *accountproto. return list, err } -func (m *Mongo) GetAccountListFuzzilyByUserId(ctx *gin.Context, req *accountproto.OpListFuzzilyByUserIdReq) ([]*dbstruct.Account, error) { - list := make([]*dbstruct.Account, 0) - col := m.getColAccount() +func (m *Mongo) GetStreamerAcctListFuzzilyByUserId(ctx *gin.Context, req *accountproto.OpListFuzzilyByUserIdReq) ([]*dbstruct.StreamerAcct, error) { + list := make([]*dbstruct.StreamerAcct, 0) + col := m.getColStreamerAcct() query := qmgo.M{ "del_flag": 0, "$or": []bson.M{ @@ -1282,9 +1285,6 @@ func (m *Mongo) GetAccountListFuzzilyByUserId(ctx *gin.Context, req *accountprot }, }, } - if req.Role != nil { - query["role"] = util.DerefInt64(req.Role) - } if len(req.Sort) == 0 { req.Sort = append(req.Sort, "-ct") } @@ -1446,6 +1446,13 @@ func (m *Mongo) CreateAccountHis(ctx *gin.Context, accounts []*dbstruct.Account) return err } +// account相关 +func (m *Mongo) CreateStreamerAcct(ctx *gin.Context, accounts []*dbstruct.StreamerAcct) error { + col := m.getColStreamerAcct() + _, err := col.InsertMany(ctx, accounts) + return err +} + // vericode相关 func (m *Mongo) CreateVeriCode(ctx *gin.Context, vericode *dbstruct.VeriCode) error { col := m.getColVeriCode() diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index b7279b25..773a5f23 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -435,51 +435,51 @@ func (s *Service) ApiGetAccountListByUserId(ctx *gin.Context, req *accountproto. return } -func (s *Service) ApiGetAccountListFuzzilyByUserId(ctx *gin.Context, req *accountproto.ApiListFuzzilyByUserIdReq) (volist []*accountproto.ApiListVO, ec errcode.ErrCode) { - ec = errcode.ErrCodeAccountSrvOk - list, err := _DefaultAccount.OpListFuzzilyByUserId(ctx, &accountproto.OpListFuzzilyByUserIdReq{ - UserId: req.UserId, - Role: req.Role, - Offset: req.Offset, - Limit: req.Limit, - Sort: req.Sort, - }) - if err != nil { - logger.Error("OpListFuzzilyByUserId fail, err: %v", err) - ec = errcode.ErrCodeAccountSrvFail - return - } +// func (s *Service) ApiGetAccountListFuzzilyByUserId(ctx *gin.Context, req *accountproto.ApiListFuzzilyByUserIdReq) (volist []*accountproto.ApiListVO, ec errcode.ErrCode) { +// ec = errcode.ErrCodeAccountSrvOk +// list, err := _DefaultAccount.OpListFuzzilyByUserId(ctx, &accountproto.OpListFuzzilyByUserIdReq{ +// UserId: req.UserId, +// Role: req.Role, +// Offset: req.Offset, +// Limit: req.Limit, +// Sort: req.Sort, +// }) +// if err != nil { +// logger.Error("OpListFuzzilyByUserId fail, err: %v", err) +// ec = errcode.ErrCodeAccountSrvFail +// return +// } - volist = make([]*accountproto.ApiListVO, len(list)) - for i, account := range list { - volist[i] = &accountproto.ApiListVO{} - volist[i].CopyAccount(account) - } - return -} +// volist = make([]*accountproto.ApiListVO, len(list)) +// for i, account := range list { +// volist[i] = &accountproto.ApiListVO{} +// volist[i].CopyAccount(account) +// } +// return +// } -func (s *Service) ApiGetAccountListFuzzilyByName(ctx *gin.Context, req *accountproto.ApiListFuzzilyByNameReq) (volist []*accountproto.ApiListVO, ec errcode.ErrCode) { - ec = errcode.ErrCodeAccountSrvOk - list, err := _DefaultAccount.OpListFuzzilyByName(ctx, &accountproto.OpListFuzzilyByNameReq{ - Name: req.Name, - Role: req.Role, - Offset: req.Offset, - Limit: req.Limit, - Sort: req.Sort, - }) - if err != nil { - logger.Error("OpListFuzzilyByName fail, err: %v", err) - ec = errcode.ErrCodeAccountSrvFail - return - } +// func (s *Service) ApiGetAccountListFuzzilyByName(ctx *gin.Context, req *accountproto.ApiListFuzzilyByNameReq) (volist []*accountproto.ApiListVO, ec errcode.ErrCode) { +// ec = errcode.ErrCodeAccountSrvOk +// list, err := _DefaultAccount.OpListFuzzilyByName(ctx, &accountproto.OpListFuzzilyByNameReq{ +// Name: req.Name, +// Role: req.Role, +// Offset: req.Offset, +// Limit: req.Limit, +// Sort: req.Sort, +// }) +// if err != nil { +// logger.Error("OpListFuzzilyByName fail, err: %v", err) +// ec = errcode.ErrCodeAccountSrvFail +// return +// } - volist = make([]*accountproto.ApiListVO, len(list)) - for i, account := range list { - volist[i] = &accountproto.ApiListVO{} - volist[i].CopyAccount(account) - } - return -} +// volist = make([]*accountproto.ApiListVO, len(list)) +// for i, account := range list { +// volist[i] = &accountproto.ApiListVO{} +// volist[i].CopyAccount(account) +// } +// return +// } func (s *Service) ApiGetAccountListForOthersByMid(ctx *gin.Context, req *accountproto.ApiListOthersByMidReq) (vo *accountproto.ApiListOthersVO, ec errcode.ErrCode) { ec = errcode.ErrCodeAccountSrvOk @@ -1268,8 +1268,8 @@ func (s *Service) ApiGetStreamerExtListFuzzilyByUserId(ctx *gin.Context, req *st ec = errcode.ErrCodeStreamerSrvOk - //1.从用户表中模糊匹配所有主播信息的用户侧数据,按mid正序排序 - accountList, err := _DefaultAccount.OpListFuzzilyByUserId(ctx, &accountproto.OpListFuzzilyByUserIdReq{ + //1.从主播用户表中模糊匹配所有主播信息的用户侧数据,按mid正序排序 + accountList, err := _DefaultAccount.OpListStreamerAcctFuzzilyByUserId(ctx, &accountproto.OpListFuzzilyByUserIdReq{ UserId: req.UserId, Role: goproto.Int64(consts.Streamer), Offset: req.Offset, @@ -1283,19 +1283,13 @@ func (s *Service) ApiGetStreamerExtListFuzzilyByUserId(ctx *gin.Context, req *st } //2.获取mids - acctmp := make(map[int64]*dbstruct.Account) mids := make([]int64, 0) for _, v := range accountList { mid := util.DerefInt64(v.Mid) mids = append(mids, mid) - if mid > 0 { - acctmp[mid] = v - } } - ignoreMap := make(map[string]bool) - ignoreMap["account"] = true - mp, err := s.utilGetStreamerExtMapByMids(ctx, mids, consts.InterfaceType_Api, ignoreMap) + mp, err := s.utilGetStreamerExtMapByMids(ctx, mids, consts.InterfaceType_Api) if err != nil { logger.Error("utilGetStreamerExtMapByMids fail, err: %v", err) return @@ -1303,7 +1297,6 @@ func (s *Service) ApiGetStreamerExtListFuzzilyByUserId(ctx *gin.Context, req *st list = make([]*streamerproto.ApiListExtVO, 0) for _, mid := range mids { vo, _ := mp[mid].(*streamerproto.ApiListExtVO) - vo.CopyAccount(acctmp[mid]) list = append(list, vo) } @@ -1314,8 +1307,8 @@ func (s *Service) ApiGetStreamerExtListFuzzilyByName(ctx *gin.Context, req *stre ec = errcode.ErrCodeStreamerSrvOk - //1.从用户表中模糊匹配所有主播信息的用户侧数据,按mid正序排序 - accountList, err := _DefaultAccount.OpListFuzzilyByName(ctx, &accountproto.OpListFuzzilyByNameReq{ + //1.从主播用户表中模糊匹配所有主播信息的用户侧数据,按mid正序排序 + accountList, err := _DefaultAccount.OpListStreamerAcctFuzzilyByName(ctx, &accountproto.OpListFuzzilyByNameReq{ Name: req.Name, Role: goproto.Int64(consts.Streamer), Offset: req.Offset, @@ -1329,19 +1322,13 @@ func (s *Service) ApiGetStreamerExtListFuzzilyByName(ctx *gin.Context, req *stre } //2.获取mids - acctmp := make(map[int64]*dbstruct.Account) mids := make([]int64, 0) for _, v := range accountList { mid := util.DerefInt64(v.Mid) mids = append(mids, mid) - if mid > 0 { - acctmp[mid] = v - } } - ignoreMap := make(map[string]bool) - ignoreMap["account"] = true - mp, err := s.utilGetStreamerExtMapByMids(ctx, mids, consts.InterfaceType_Api, ignoreMap) + mp, err := s.utilGetStreamerExtMapByMids(ctx, mids, consts.InterfaceType_Api) if err != nil { logger.Error("utilGetStreamerExtMapByMids fail, err: %v", err) return @@ -1349,7 +1336,6 @@ func (s *Service) ApiGetStreamerExtListFuzzilyByName(ctx *gin.Context, req *stre list = make([]*streamerproto.ApiListExtVO, 0) for _, mid := range mids { vo, _ := mp[mid].(*streamerproto.ApiListExtVO) - vo.CopyAccount(acctmp[mid]) list = append(list, vo) } diff --git a/app/mix/service/logic/account.go b/app/mix/service/logic/account.go index 8fa6ec81..3694893a 100644 --- a/app/mix/service/logic/account.go +++ b/app/mix/service/logic/account.go @@ -152,19 +152,19 @@ func (p *Account) OpListByUserId(ctx *gin.Context, req *accountproto.OpListByUse return list, nil } -func (p *Account) OpListFuzzilyByUserId(ctx *gin.Context, req *accountproto.OpListFuzzilyByUserIdReq) ([]*dbstruct.Account, error) { - list, err := p.store.GetAccountListFuzzilyByUserId(ctx, req) +func (p *Account) OpListStreamerAcctFuzzilyByUserId(ctx *gin.Context, req *accountproto.OpListFuzzilyByUserIdReq) ([]*dbstruct.StreamerAcct, error) { + list, err := p.store.GetStreamerAcctListFuzzilyByUserId(ctx, req) if err != nil { - logger.Error("GetAccountListFuzzilyByUserId fail, err: %v", err) + logger.Error("GetStreamerAcctListFuzzilyByUserId fail, err: %v", err) return nil, err } return list, nil } -func (p *Account) OpListFuzzilyByName(ctx *gin.Context, req *accountproto.OpListFuzzilyByNameReq) ([]*dbstruct.Account, error) { - list, err := p.store.GetAccountListFuzzilyByName(ctx, req) +func (p *Account) OpListStreamerAcctFuzzilyByName(ctx *gin.Context, req *accountproto.OpListFuzzilyByNameReq) ([]*dbstruct.StreamerAcct, error) { + list, err := p.store.GetStreamerAcctListFuzzilyByName(ctx, req) if err != nil { - logger.Error("GetAccountListFuzzilyByName fail, err: %v", err) + logger.Error("GetStreamerAcctListFuzzilyByName fail, err: %v", err) return nil, err } return list, nil @@ -282,3 +282,13 @@ func (p *Account) OpListByPhoneHash(ctx *gin.Context, phonehash string) ([]*dbst } return list, nil } + +func (p *Account) OpCreateStreamerAcct(ctx *gin.Context, accounts []*dbstruct.StreamerAcct) error { + + err := p.store.CreateStreamerAcct(ctx, accounts) + if err != nil { + logger.Error("CreateAccount fail, err: %v", err) + return err + } + return nil +} diff --git a/app/mix/service/service.go b/app/mix/service/service.go index e49115a0..c8cfb879 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -895,52 +895,6 @@ func (s *Service) OpGetMobilePhoneByUserId(ctx *gin.Context, req *accountproto.O return } -func (s *Service) OpGetAccountListFuzzilyByUserId(ctx *gin.Context, req *accountproto.OpListFuzzilyByUserIdReq) (volist []*accountproto.OpListVO, ec errcode.ErrCode) { - ec = errcode.ErrCodeAccountSrvOk - - // 业务鉴权 - if ec = s.OpGetAccountListFuzzilyByUserIdBusinessValidate(ctx, req); ec != errcode.ErrCodeAccountSrvOk { - return - } - - list, err := _DefaultAccount.OpListFuzzilyByUserId(ctx, req) - if err != nil { - logger.Error("OpListFuzzilyByUserId fail, err: %v", err) - ec = errcode.ErrCodeAccountSrvFail - return - } - - volist = make([]*accountproto.OpListVO, len(list)) - for i, account := range list { - volist[i] = &accountproto.OpListVO{} - volist[i].CopyAccount(account) - } - return -} - -func (s *Service) OpGetAccountListFuzzilyByName(ctx *gin.Context, req *accountproto.OpListFuzzilyByNameReq) (volist []*accountproto.OpListVO, ec errcode.ErrCode) { - ec = errcode.ErrCodeAccountSrvOk - - // 业务鉴权 - if ec = s.OpGetAccountListFuzzilyByNameBusinessValidate(ctx, req); ec != errcode.ErrCodeAccountSrvOk { - return - } - - list, err := _DefaultAccount.OpListFuzzilyByName(ctx, req) - if err != nil { - logger.Error("OpListFuzzilyByName fail, err: %v", err) - ec = errcode.ErrCodeAccountSrvFail - return - } - - volist = make([]*accountproto.OpListVO, len(list)) - for i, account := range list { - volist[i] = &accountproto.OpListVO{} - volist[i].CopyAccount(account) - } - return -} - func (s *Service) OpGetAccountListForOthersByMid(ctx *gin.Context, req *accountproto.OpListOthersByMidReq) (vo *accountproto.OpListOthersVO, ec errcode.ErrCode) { ec = errcode.ErrCodeAccountSrvOk @@ -1794,6 +1748,33 @@ func (s *Service) OpApproveStreamerAuthApproval(ctx *gin.Context, req *streamera ec = errcode.ErrCodeAccountSrvFail return } + + // 主播账户表新增数据 + accountList, err := _DefaultAccount.OpListByMids(ctx, &accountproto.OpListByMidsReq{ + Mids: midList, + }) + if err != nil { + logger.Error("_DefaultAccount OpListByMids fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeAccountSrvFail + return + } + streamerAccts := make([]*dbstruct.StreamerAcct, 0) + for _, acct := range accountList { + streamerAccts = append(streamerAccts, &dbstruct.StreamerAcct{ + Mid: acct.Mid, + Name: acct.Name, + UserIdString: acct.UserIdString, + Ct: acct.Ct, + Ut: acct.Ut, + DelFlag: acct.DelFlag, + }) + } + err = _DefaultAccount.OpCreateStreamerAcct(ctx, streamerAccts) + if err != nil { + logger.Error("_DefaultAccount OpCreateStreamerAcct fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeAccountSrvFail + return + } } return @@ -1994,8 +1975,8 @@ func (s *Service) OpGetStreamerExtListFuzzilyByUserId(ctx *gin.Context, req *str return } - //1.从用户表中模糊匹配所有主播信息的用户侧数据,按mid正序排序 - accountList, err := _DefaultAccount.OpListFuzzilyByUserId(ctx, &accountproto.OpListFuzzilyByUserIdReq{ + //1.从主播用户表中模糊匹配所有主播信息的用户侧数据,按mid正序排序 + accountList, err := _DefaultAccount.OpListStreamerAcctFuzzilyByUserId(ctx, &accountproto.OpListFuzzilyByUserIdReq{ UserId: req.UserId, Role: goproto.Int64(consts.Streamer), Offset: req.Offset, @@ -2008,19 +1989,13 @@ func (s *Service) OpGetStreamerExtListFuzzilyByUserId(ctx *gin.Context, req *str } //2.获取mids - acctmp := make(map[int64]*dbstruct.Account) mids := make([]int64, 0) for _, v := range accountList { mid := util.DerefInt64(v.Mid) mids = append(mids, mid) - if mid > 0 { - acctmp[mid] = v - } } - ignoreMap := make(map[string]bool) - ignoreMap["account"] = true - mp, err := s.utilGetStreamerExtMapByMids(ctx, mids, consts.InterfaceType_Op, ignoreMap) + mp, err := s.utilGetStreamerExtMapByMids(ctx, mids, consts.InterfaceType_Op) if err != nil { logger.Error("utilGetStreamerExtMapByMids fail, err: %v", err) return @@ -2028,7 +2003,6 @@ func (s *Service) OpGetStreamerExtListFuzzilyByUserId(ctx *gin.Context, req *str list = make([]*streamerproto.OpListExtVO, 0) for _, mid := range mids { vo, _ := mp[mid].(*streamerproto.OpListExtVO) - vo.CopyAccount(acctmp[mid]) list = append(list, vo) } @@ -2043,8 +2017,8 @@ func (s *Service) OpGetStreamerExtListFuzzilyByName(ctx *gin.Context, req *strea return } - //1.从用户表中模糊匹配所有主播信息的用户侧数据,按mid正序排序 - accountList, err := _DefaultAccount.OpListFuzzilyByName(ctx, &accountproto.OpListFuzzilyByNameReq{ + //1.从主播用户表中模糊匹配所有主播信息的用户侧数据,按mid正序排序 + accountList, err := _DefaultAccount.OpListStreamerAcctFuzzilyByName(ctx, &accountproto.OpListFuzzilyByNameReq{ Name: req.Name, Role: goproto.Int64(consts.Streamer), Offset: req.Offset, @@ -2057,19 +2031,13 @@ func (s *Service) OpGetStreamerExtListFuzzilyByName(ctx *gin.Context, req *strea } //2.获取mids - acctmp := make(map[int64]*dbstruct.Account) mids := make([]int64, 0) for _, v := range accountList { mid := util.DerefInt64(v.Mid) mids = append(mids, mid) - if mid > 0 { - acctmp[mid] = v - } } - ignoreMap := make(map[string]bool) - ignoreMap["account"] = true - mp, err := s.utilGetStreamerExtMapByMids(ctx, mids, consts.InterfaceType_Op, ignoreMap) + mp, err := s.utilGetStreamerExtMapByMids(ctx, mids, consts.InterfaceType_Op) if err != nil { logger.Error("utilGetStreamerExtMapByMids fail, err: %v", err) return @@ -2077,7 +2045,6 @@ func (s *Service) OpGetStreamerExtListFuzzilyByName(ctx *gin.Context, req *strea list = make([]*streamerproto.OpListExtVO, 0) for _, mid := range mids { vo, _ := mp[mid].(*streamerproto.OpListExtVO) - vo.CopyAccount(acctmp[mid]) list = append(list, vo) } return diff --git a/dbstruct/account.go b/dbstruct/account.go index e2962070..500003d1 100644 --- a/dbstruct/account.go +++ b/dbstruct/account.go @@ -38,3 +38,13 @@ func (p *Account) GetRole() int64 { } return *p.Role } + +// StreamerAcct 用户结构 +type StreamerAcct struct { + Mid *int64 `json:"mid" bson:"_id"` // 用户表Id + Name *string `json:"name" bson:"name"` // 用户名 + UserIdString *string `json:"user_id_string" bson:"user_id_string"` // string型user_id,为模糊匹配设置 + Ct *int64 `json:"ct" bson:"ct"` // 创建时间 + Ut *int64 `json:"ut" bson:"ut"` // 更新时间 + DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记,0-否,1-是 +}