123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package service
- import (
- "log"
- "app.yhyue.com/moapp/jybase/mongodb"
- "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
- cm "bp.jydev.jianyu360.cn/CRM/application/api/common"
- "github.com/gogf/gf/v2/os/gctx"
- "github.com/gogf/gf/v2/util/gconv"
- )
- type User struct {
- BaseUserIds []int64
- }
- func (this *User) GetUserId(entId int64) map[string]int64 {
- m := map[string]int64{}
- data, ok := cm.Mgo.Find("user", map[string]interface{}{
- "base_user_id": map[string]interface{}{
- "$in": this.BaseUserIds,
- },
- }, nil, `{"_id":1,"base_user_id":1}`, false, -1, -1)
- if ok && data != nil && len(*data) > 0 {
- for _, v := range *data {
- mdata := cm.BaseMysql.SelectBySql(`SELECT id FROM base_position WHERE user_id =? AND ent_id =? LIMIT 1`, gconv.Int64(v["base_user_id"]), entId)
- if mdata != nil && len(*mdata) > 0 {
- m[mongodb.BsonIdToSId(v["_id"])] = gconv.Int64((*mdata)[0]["id"])
- }
- }
- }
- return m
- }
- func (this *User) IdentityByPositionId(positionId int64) *pb.Identity {
- resp, err := cm.UserCenterRpc.IdentityByPositionId(gctx.New(), &pb.IdentityReq{
- Id: positionId,
- })
- if err != nil {
- log.Println("获取用户职位id信息出错", positionId, "的信息出错", err)
- return nil
- } else if resp == nil {
- log.Println("positionId用户", positionId, "没有找到职位信息")
- return nil
- }
- return resp
- }
|