Переглянути джерело

wip:P387用户身份及搜索模式优化-分权限弹框提示

wangkaiyue 1 рік тому
батько
коміт
b13ac3bb24
1 змінених файлів з 18 додано та 3 видалено
  1. 18 3
      service/service.go

+ 18 - 3
service/service.go

@@ -55,8 +55,12 @@ func AddUsePerson(this *entmanageapplication.AddUsePersonReq) *entmanageapplicat
 					continue
 				}
 				//
-				entUserId, _ := strconv.Atoi(v)
-				isYyszsyy := common.ObjToString((*sourceData)["product_type"]) == YYSZSYY
+				var (
+					entUserId, _ = strconv.Atoi(v)
+					product_type = common.ObjToString((*sourceData)["product_type"])
+					isYyszsyy    = product_type == YYSZSYY
+				)
+
 				if !isYyszsyy {
 					datas := JyMysql.SelectBySql(`select a.end_time from `+EntnicheWaitEmpower+` a inner join `+EntnichePower+` b on (a.product_type<>? and b.ent_user_id=? and b.status=1 and a.id=b.wait_empower_id)`, YYSZSYY, entUserId)
 					if datas != nil && len(*datas) > 0 {
@@ -83,6 +87,18 @@ func AddUsePerson(this *entmanageapplication.AddUsePersonReq) *entmanageapplicat
 						ResourcePowerHandle(identity, 1, common.ObjToString((*sourceData)["start_time"]), common.ObjToString((*sourceData)["end_time"]))
 					}
 					addPower(this.WaitEmpowerId, identity)
+
+					if identity.UserId != 0 {
+						if dbRes, _ := entity.Mgo.FindOneByField("user", map[string]interface{}{"base_user_id": identity.UserId}, `{"_id":1}`); dbRes != nil && len(*dbRes) > 0 {
+							if mgoUserId := mongodb.BsonIdToSId((*dbRes)["_id"]); mgoUserId != "" {
+								redis.Put(NewOther, fmt.Sprintf("jy_identitySwitch_%s", mgoUserId), map[string]interface{}{
+									"entId":       identity.EntId,
+									"entName":     identity.Name,
+									"productType": product_type,
+								}, -1)
+							}
+						}
+					}
 				}
 			}
 		}
@@ -582,7 +598,6 @@ func delRedisByPowerCheck(positionId string) bool {
 	return true
 }
 
-//
 func ResourcePowerHandle(identity *usercenter.Identity, t int64, startTime, endTime string) {
 	if t == 1 {
 		resp, err := entity.ResourceRpc.Empower(context.Background(), &pb.EmpowerReq{