Răsfoiți Sursa

增加方法

wangchuanjin 2 ani în urmă
părinte
comite
ff5f4701ad
1 a modificat fișierele cu 23 adăugiri și 7 ștergeri
  1. 23 7
      compatible/compatible.go

+ 23 - 7
compatible/compatible.go

@@ -31,22 +31,21 @@ func NewCompatible(mgo *MongodbSim, baseService, mainMysql *mysql.Mysql, middleg
 }
 
 //根据mgo库user表_id,或者企业身份的职位id查询
-//根据mgo库user表_id,或者企业身份的职位id查询
-func (c *Compatible) Select(id string, fd interface{}) *map[string]interface{} {
+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, fd)
+	return c.selectDo(id, identity, field)
 }
 
-//根据mgo库user表_id,或者企业身份的职位id查询
-func (c *Compatible) SelectByEntUserId(id string, fd interface{}) *map[string]interface{} {
+//根据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, fd)
+	return c.selectDo(id, identity, field)
 }
 
 //
@@ -131,10 +130,27 @@ func (c *Compatible) selectDo(id string, identity *pb.Identity, fd interface{})
 
 //根据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
 		}