Эх сурвалжийг харах

Merge remote-tracking branch 'origin/master'

WH01243 2 жил өмнө
parent
commit
283a80f1b7

+ 25 - 0
common/src/qfw/util/jy/userCenter.go

@@ -0,0 +1,25 @@
+package jy
+
+import (
+	"app.yhyue.com/moapp/jybase/mongodb"
+	"app.yhyue.com/moapp/jypkg/middleground"
+	"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
+)
+
+//获取base-user相关参数
+func AddUser(mgo mongodb.MongodbSim, userid string, req pb.UserAddReq, middleground middleground.Middleground) bool {
+	if resp := middleground.UserCenter.UserAdd(req); resp != nil {
+		//获取到baseid
+		baseId := resp.Data.Id
+		if baseId > 0 {
+			//user表记录映射关系
+			ok := mgo.UpdateById("user", userid, map[string]interface{}{
+				"$set": map[string]interface{}{
+					"base_user_id": baseId,
+				},
+			})
+			return resp.Data.Status == 1 && ok
+		}
+	}
+	return false
+}

+ 41 - 6
compatible/compatible.go

@@ -8,6 +8,7 @@ import (
 	. "app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/mysql"
 	. "app.yhyue.com/moapp/jypkg/middleground"
+	"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
 )
 
 type Compatible struct {
@@ -29,8 +30,26 @@ func NewCompatible(mgo *MongodbSim, baseService, mainMysql *mysql.Mysql, middleg
 	}
 }
 
-//查询
-func (c *Compatible) Select(id string, fd interface{}) *map[string]interface{} {
+//根据mgo库user表_id,或者企业身份的职位id查询
+func (c *Compatible) Select(id string, field interface{}) *map[string]interface{} {
+	var identity *pb.Identity
+	if !IsObjectIdHex(id) {
+		identity = c.Middleground.UserCenter.IdentityByPositionId(util.Int64All(id))
+	}
+	return c.selectDo(id, identity, field)
+}
+
+//根据mgo库user表_id,或者企业身份的企业员工id查询
+func (c *Compatible) SelectByEntUserId(id string, field interface{}) *map[string]interface{} {
+	var identity *pb.Identity
+	if !IsObjectIdHex(id) {
+		identity = c.Middleground.UserCenter.IdentityByEntUserId(util.Int64All(id))
+	}
+	return c.selectDo(id, identity, field)
+}
+
+//
+func (c *Compatible) selectDo(id string, identity *pb.Identity, fd interface{}) *map[string]interface{} {
 	field := ObjToOth(fd)
 	user := map[string]interface{}{}
 	if field == nil || len(*field) == 0 {
@@ -43,13 +62,12 @@ func (c *Compatible) Select(id string, fd interface{}) *map[string]interface{} {
 			user = *temp
 		}
 	} else {
-		identity := c.Middleground.UserCenter.IdentityByPositionId(util.Int64All(id))
 		if identity == nil {
 			return &user
 		}
 		if identity.UserId > 0 {
 			ufd := map[string]interface{}{}
-			for _, k := range []string{"s_m_openid", "s_phone", "s_m_phone", "s_unionid", "s_headimage", "s_headimageurl", "s_nickname", "l_registedate", "s_appversion", "i_ispush", "s_jyname"} {
+			for _, k := range []string{"s_m_openid", "s_phone", "s_m_phone", "s_unionid", "s_headimage", "s_headimageurl", "s_nickname", "l_registedate", "s_appversion", "i_ispush", "s_jyname", "s_jpushid", "s_opushid", "s_appponetype", "i_applystatus"} {
 				if v, ok := (*field)[k]; ok {
 					ufd[k] = v
 				}
@@ -110,12 +128,29 @@ func (c *Compatible) Select(id string, fd interface{}) *map[string]interface{} {
 	return &user
 }
 
-//更新
+//根据mgo库user表_id,或者企业身份的职位id更新
 func (c *Compatible) Update(id string, update map[string]interface{}) bool {
+	var identity *pb.Identity
+	if !IsObjectIdHex(id) {
+		identity = c.Middleground.UserCenter.IdentityByPositionId(util.Int64All(id))
+	}
+	return c.updateDo(id, identity, update)
+}
+
+//根据mgo库user表_id,或者企业身份的企业员工id更新
+func (c *Compatible) UpdateByEntUserId(id string, update map[string]interface{}) bool {
+	var identity *pb.Identity
+	if !IsObjectIdHex(id) {
+		identity = c.Middleground.UserCenter.IdentityByEntUserId(util.Int64All(id))
+	}
+	return c.updateDo(id, identity, update)
+}
+
+//
+func (c *Compatible) updateDo(id string, identity *pb.Identity, update map[string]interface{}) bool {
 	if IsObjectIdHex(id) {
 		return c.Mgo.UpdateById("user", id, update)
 	} else {
-		identity := c.Middleground.UserCenter.IdentityByPositionId(util.Int64All(id))
 		if identity == nil {
 			return false
 		}