wangchuanjin 2 жил өмнө
parent
commit
85b805a6ca

+ 2 - 1
src/config.yaml

@@ -3,4 +3,5 @@ etcd:
   - 127.0.0.1:2379
 userCenterKey: "usercenter.rpc" #用户中台rpc
 powerCheckCenterKey: "powercheck.rpc" #权益校验中台
-resourceCenterKey: "resource.rpc" #资源中台
+resourceCenterKey: "resource.rpc" #资源中台
+entManageApplication: "entmanageapplication.rpc" #企业管理中台

+ 2 - 1
src/go.mod

@@ -4,7 +4,7 @@ go 1.18
 
 require (
 	app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a
-	app.yhyue.com/moapp/jypkg v0.0.0-20230207082022-e4d33621d394
+	app.yhyue.com/moapp/jypkg v0.0.0-20230209055147-4cf703ace114
 	bp.jydev.jianyu360.cn/BaseService/userCenter v0.0.0-20230129060002-f69424aa14ba
 	github.com/SKatiyar/qr v0.0.0-20151201054752-25b6bdf44e67
 	github.com/dchest/captcha v1.0.0
@@ -17,6 +17,7 @@ require (
 require (
 	app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d // indirect
 	app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae // indirect
+	bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230209051900-1e7dcb8f83b7 // indirect
 	bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230207054315-b05f3dd4c4d3 // indirect
 	bp.jydev.jianyu360.cn/BaseService/resourceCenter v0.0.4 // indirect
 	github.com/BurntSushi/toml v1.1.0 // indirect

+ 4 - 2
src/go.sum

@@ -13,11 +13,13 @@ app.yhyue.com/moapp/jybase v0.0.0-20220802080941-07f401baab8b/go.mod h1:HelrO6tc
 app.yhyue.com/moapp/jybase v0.0.0-20230109015757-aa3d5e19b196/go.mod h1:zB47XTeJvpcbtBRYgkQuxOICWNexiZfbUO+7aUf6mNs=
 app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a h1:wD4aWPSYdiX1cIP4lzzPD2s7fYhKa3muIf97l9tonJE=
 app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a/go.mod h1:zB47XTeJvpcbtBRYgkQuxOICWNexiZfbUO+7aUf6mNs=
-app.yhyue.com/moapp/jypkg v0.0.0-20230207082022-e4d33621d394 h1:vhCsUAxF1ZIUPucSXhDZYNBWHDX2+usz+pU/T2Xu184=
-app.yhyue.com/moapp/jypkg v0.0.0-20230207082022-e4d33621d394/go.mod h1:0DqPlGxaufZlKaLoRndTWG4j3qUQqJ6MNZCmoPcMqSg=
+app.yhyue.com/moapp/jypkg v0.0.0-20230209055147-4cf703ace114 h1:89J5Zq4bfnocIpEWBn19PnfaT+8Dh+Rv4X8QoTwxCpg=
+app.yhyue.com/moapp/jypkg v0.0.0-20230209055147-4cf703ace114/go.mod h1:sa5YRPqTQLOVBmpltjT21EkQ7DfJbUZFARUb4ZJ7U+k=
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae h1:6rDDaz6yxvE8viTSzEBwKYOFWq14TMfuBivSazUZMz4=
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae/go.mod h1:b0zZHev3gmJao1Fo+2Z2KPVjsuLOJVvVxf+kCnu9WkA=
 bp.jydev.jianyu360.cn/BP/jynsq v0.0.0-20220222052708-ebc43af90698/go.mod h1:ojo/AUH9Yr1wzarEjOaNMkj1Cet/9r8IgLyba64Z52E=
+bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230209051900-1e7dcb8f83b7 h1:cw/PdRypNFcYOk4iWAfHjIFoMzIlXUfl9XAmWujBOPY=
+bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230209051900-1e7dcb8f83b7/go.mod h1:7Xhygw0KBuL4h0G76FnFg4otQcA9bmOO0c8M0FCjAyQ=
 bp.jydev.jianyu360.cn/BaseService/gateway v0.0.0-20220419090715-88ddb32961be/go.mod h1:Yj4oabIGItuMoF0BXYLz2XAnF581kxgXBrvlUtIJrkI=
 bp.jydev.jianyu360.cn/BaseService/gateway v1.3.4/go.mod h1:BMLd/5wb3BIEGhnEgF9y1sJN9P5/Dw9kYsoiE9V8I9g=
 bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230207054315-b05f3dd4c4d3 h1:jeItQ6RM1T6yPWc/5i4R6h3kViD+Rm2VnIEsc1gCFJA=

+ 1 - 1
src/jfw/active/active_future.go

@@ -39,7 +39,7 @@ func (a *Active) FutureIndex(share_openid string) error {
 				if code != "" {
 					openid = jyutil.Getopenid(code)
 					if openid != "" {
-						FindUserAndCreateSess(openid, a.Session(), "wx", false)
+						FindUserAndCreateSess(openid, a.Session(), "wx", false, true)
 					}
 				}
 			} else {

+ 1 - 1
src/jfw/active/active_seal.go

@@ -255,7 +255,7 @@ func (a *Active) Index() error {
 				if code != "" {
 					openid := jyutil.Getopenid(code)
 					if openid != "" {
-						FindUserAndCreateSess(openid, a.Session(), "wx", false)
+						FindUserAndCreateSess(openid, a.Session(), "wx", false, true)
 					}
 				}
 			} else {

+ 1 - 1
src/jfw/active/live.go

@@ -127,7 +127,7 @@ func (this *Active) LivePage() error {
 						checkIsSubscribeFlag = CheckUserIsSubscribe(openid)
 						if checkIsSubscribeFlag {
 							//关注用户 建session
-							go FindUserAndCreateSess(openid, this.Session(), "wx", false)
+							go FindUserAndCreateSess(openid, this.Session(), "wx", false, true)
 						}
 					}
 				}

+ 5 - 1
src/jfw/config/config.go

@@ -51,5 +51,9 @@ func init() {
 	//PC端商机管理配置
 	util.ReadConfig("./entnichePc.json", &EntnichePcConf)
 	var ctx = gctx.New()
-	Middleground = middleground.NewMiddleground(g.Cfg().MustGet(ctx, "etcd.hosts").Strings()).RegUserCenter(g.Cfg().MustGet(ctx, "userCenterKey").String()).RegPowerCheckCenter(g.Cfg().MustGet(ctx, "powerCheckCenterKey").String()).RegResourceCenter(g.Cfg().MustGet(ctx, "resourceCenterKey").String())
+	Middleground = middleground.NewMiddleground(g.Cfg().MustGet(ctx, "etcd.hosts").Strings()).
+		RegUserCenter(g.Cfg().MustGet(ctx, "userCenterKey").String()).
+		RegPowerCheckCenter(g.Cfg().MustGet(ctx, "powerCheckCenterKey").String()).
+		RegResourceCenter(g.Cfg().MustGet(ctx, "resourceCenterKey").String()).
+		RegPowerCheckCenter(g.Cfg().MustGet(ctx, "entManageApplication").String())
 }

+ 2 - 10
src/jfw/filter/filter.go

@@ -10,6 +10,7 @@ import (
 	util "app.yhyue.com/moapp/jybase/common"
 	fs "app.yhyue.com/moapp/jybase/fsnotify"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jypkg/identity"
 )
 
 var RouteConf struct {
@@ -42,16 +43,7 @@ func (f *Filter) Do(w http.ResponseWriter, r *http.Request) bool {
 		session.Set("mgoUserId", getSession["userId"])
 	}
 	if getSession["base_user_id"] != nil && getSession["positionId"] == nil {
-		identity := Middleground.UserCenter.IdentityByUserId(util.Int64All(getSession["base_user_id"]))
-		if identity != nil {
-			session.SetMultiple(map[string]interface{}{
-				"personId":     identity.PersonId,
-				"userName":     identity.UserName,
-				"accountId":    identity.AccountId,
-				"positionId":   identity.PositionId,
-				"positionType": identity.PositionType,
-			})
-		}
+		identity.SwitchToBest(util.Int64All(getSession["base_user_id"]), session, Middleground)
 	}
 	if !(&logFilter{w, r, session, getSession, make(map[string]interface{})}).Do() {
 		return false

+ 1 - 1
src/jfw/front/applysub.go

@@ -204,7 +204,7 @@ func (a *Applysub) Index() error {
 			if code != "" {
 				openid = jyutil.Getopenid(code)
 				if openid != "" {
-					FindUserAndCreateSess(openid, a.Session(), "wx", false)
+					FindUserAndCreateSess(openid, a.Session(), "wx", false, true)
 				}
 			}
 		} else {

+ 1 - 1
src/jfw/front/commonPayWx.go

@@ -103,7 +103,7 @@ func (w *WxPayCommon) ToMyWxOrder() error {
 				openid := jyutil.Getopenid(code)
 				if openid != "" {
 					if CheckUserIsSubscribe(openid) {
-						FindUserAndCreateSess(openid, w.Session(), "wx", false)
+						FindUserAndCreateSess(openid, w.Session(), "wx", false, true)
 					}
 				}
 			}

+ 4 - 4
src/jfw/front/distribution.go

@@ -46,7 +46,7 @@ func (this *Distrib) LinkShare(discored string) error {
 					checkIsSubscribeFlag = CheckUserIsSubscribe(openid)
 					if checkIsSubscribeFlag {
 						//关注用户 建session
-						FindUserAndCreateSess(openid, this.Session(), "wx", false)
+						FindUserAndCreateSess(openid, this.Session(), "wx", false, true)
 					}
 				}
 			}
@@ -94,7 +94,7 @@ func (this *Distrib) LinkShareX(discored string) error {
 					checkIsSubscribeFlag = CheckUserIsSubscribe(openid)
 					if checkIsSubscribeFlag {
 						//关注用户 建session
-						FindUserAndCreateSess(openid, this.Session(), "wx", false)
+						FindUserAndCreateSess(openid, this.Session(), "wx", false, true)
 					}
 				}
 			}
@@ -141,7 +141,7 @@ func (this *Distrib) LinkShareG(discored string) error {
 					checkIsSubscribeFlag = CheckUserIsSubscribe(openid)
 					if checkIsSubscribeFlag {
 						//关注用户 建session
-						FindUserAndCreateSess(openid, this.Session(), "wx", false)
+						FindUserAndCreateSess(openid, this.Session(), "wx", false, true)
 					}
 				}
 			}
@@ -189,7 +189,7 @@ func (this *Distrib) LinkShareE(discored string) error {
 					checkIsSubscribeFlag = CheckUserIsSubscribe(openid)
 					if checkIsSubscribeFlag {
 						//关注用户 建session
-						FindUserAndCreateSess(openid, this.Session(), "wx", false)
+						FindUserAndCreateSess(openid, this.Session(), "wx", false, true)
 					}
 				}
 			}

+ 1 - 1
src/jfw/front/follow.go

@@ -1578,7 +1578,7 @@ func (this *Follow) FollowGift(shareid string) error {
 						openid = jyutil.Getopenid(code)
 						if openid != "" {
 							if CheckUserIsSubscribe(openid) {
-								FindUserAndCreateSess(openid, this.Session(), "wx", false)
+								FindUserAndCreateSess(openid, this.Session(), "wx", false, true)
 							}
 						}
 					}

+ 60 - 28
src/jfw/front/front.go

@@ -16,21 +16,19 @@ import (
 	"sync"
 	"time"
 
-	"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
-
 	util "app.yhyue.com/moapp/jybase/common"
 	. "app.yhyue.com/moapp/jybase/date"
 	"app.yhyue.com/moapp/jybase/encrypt"
-	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
-	"app.yhyue.com/moapp/jypkg/public"
-
 	elastic "app.yhyue.com/moapp/jybase/esv1"
-	"app.yhyue.com/moapp/jybase/redis"
-
 	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
 	mgdb "app.yhyue.com/moapp/jybase/mongodb"
+	"app.yhyue.com/moapp/jybase/redis"
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+	"app.yhyue.com/moapp/jypkg/identity"
 	. "app.yhyue.com/moapp/jypkg/identity"
+	"app.yhyue.com/moapp/jypkg/public"
+	"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
 	"github.com/SKatiyar/qr"
 	"go.mongodb.org/mongo-driver/bson"
 	"go.mongodb.org/mongo-driver/bson/primitive"
@@ -597,7 +595,7 @@ func (f *Front) Login(key string) error {
 	shareid := se.DecodeString(key)
 	openid := redis.GetStr("sso", "p_usershare_"+shareid)
 	if openid != "" {
-		ok, user, userInfo := FindUserAndCreateSess(openid, f.Session(), "pc", true)
+		ok, user, userInfo := FindUserAndCreateSess(openid, f.Session(), "pc", true, true)
 		if ok {
 			(*user)["shareid"] = shareid
 			f.SetSession("user", *user)
@@ -771,29 +769,27 @@ func (m *Front) Wxerr() error {
 }
 
 //查找用户并创建session
-func FindUserAndCreateSess(openid string, sess *httpsession.Session, typ string, flag bool) (bool, *map[string]interface{}, map[string]interface{}) {
+func FindUserAndCreateSess(openid string, sess *httpsession.Session, typ string, flag, isSwitchToBestIdentity bool) (bool, *map[string]interface{}, map[string]interface{}) {
 	return CreateSession(map[string]interface{}{
 		"s_m_openid": openid,
 		"s_unionid":  map[string]interface{}{"$ne": openid}, //处理排除未关注用户点击菜单创建的用户
 		"i_ispush":   1,
-	}, sess, typ, flag)
+	}, sess, typ, flag, isSwitchToBestIdentity)
 }
-func FindUserAndCreateSessByBaseUserId(userId int64, sess *httpsession.Session, flag bool) (bool, *map[string]interface{}, map[string]interface{}) {
-
+func FindUserAndCreateSessByBaseUserId(userId int64, sess *httpsession.Session, flag, isSwitchToBestIdentity bool) (bool, *map[string]interface{}, map[string]interface{}) {
 	return CreateSession(map[string]interface{}{
-
 		"base_user_id": userId,
-	}, sess, "pc", flag)
+	}, sess, "pc", flag, isSwitchToBestIdentity)
 
 }
 
-func FindUserAndCreateSessById(userId primitive.ObjectID, sess *httpsession.Session, flag bool) (bool, *map[string]interface{}, map[string]interface{}) {
+func FindUserAndCreateSessById(userId primitive.ObjectID, sess *httpsession.Session, flag, isSwitchToBestIdentity bool) (bool, *map[string]interface{}, map[string]interface{}) {
 	return CreateSession(map[string]interface{}{
 		"_id": userId,
-	}, sess, "pc", flag)
+	}, sess, "pc", flag, isSwitchToBestIdentity)
 }
 
-func CreateSession(q map[string]interface{}, sess *httpsession.Session, typ string, flag bool) (bool, *map[string]interface{}, map[string]interface{}) {
+func CreateSession(q map[string]interface{}, sess *httpsession.Session, typ string, flag, isSwitchToBestIdentity bool) (bool, *map[string]interface{}, map[string]interface{}) {
 	if q == nil || len(q) == 0 {
 		return false, nil, nil
 	}
@@ -808,9 +804,11 @@ func CreateSession(q map[string]interface{}, sess *httpsession.Session, typ stri
 			redis.Put("other", jyutil.LoginRedisKey(userid), sess.Id(), 3600*util.IntAllDef(config.Sysconfig["pcSessionTimeout"], 168))
 		}
 	}
-
 	sessionVal["platform"] = typ
 	sess.SetMultiple(sessionVal)
+	if isSwitchToBestIdentity {
+		identity.SwitchToBest(util.Int64All(sessionVal["base_user_id"]), sess, config.Middleground)
+	}
 	s_nickname := util.If(sessionVal["s_nickname"] != nil, sessionVal["s_nickname"], sessionVal["phone"])
 	if util.ObjToString(s_nickname) == "" {
 		s_nickname = sessionVal["s_jyname"]
@@ -845,27 +843,59 @@ func (m *Front) Sess(ostr string) error {
 	if len(str) == 4 {
 		userFlag := str[0]
 		ok := false
-		var identity *pb.Identity
 		if str[1] == "userId" || str[1] == "entUserId" || str[1] == "positionId" {
+			var identity *pb.Identity
+			sessVal := m.Session().GetMultiple()
 			if str[1] == "userId" {
-				identity = config.Middleground.UserCenter.IdentityByUserId(util.Int64All(userFlag))
+				if sessVal["positionType"] == nil || util.IntAll(sessVal["positionType"]) != 0 {
+					identity = config.Middleground.UserCenter.IdentityByUserId(util.Int64All(userFlag))
+					if identity == nil {
+						log.Println("获取用户身份失败", str)
+					}
+				}
 			} else if str[1] == "entUserId" {
-				identity = config.Middleground.UserCenter.IdentityByEntUserId(util.Int64All(userFlag))
+				if sessVal["positionType"] == nil || sessVal["entUserId"] == nil || util.Int64All(sessVal["positionType"]) != 1 || util.Int64All(sessVal["entUserId"]) != util.Int64All(userFlag) {
+					identity = config.Middleground.UserCenter.IdentityByEntUserId(util.Int64All(userFlag))
+					if identity == nil {
+						log.Println("获取用户身份失败", str)
+					}
+				}
 			} else if str[1] == "positionId" {
-				identity = config.Middleground.UserCenter.IdentityByPositionId(util.Int64All(userFlag))
+				if sessVal["positionId"] == nil || util.Int64All(sessVal["positionId"]) != util.Int64All(userFlag) {
+					identity = config.Middleground.UserCenter.IdentityByPositionId(util.Int64All(userFlag))
+					if identity == nil {
+						log.Println("获取用户身份失败", str)
+					}
+				}
+			} else {
+				return m.Render("_error.html")
+			}
+			if sessVal["userId"] == nil {
+				if identity != nil {
+					ok, _, _ = FindUserAndCreateSessByBaseUserId(identity.UserId, m.Session(), false, false)
+					if !ok {
+						log.Println("创建session失败", str)
+					}
+				}
+			} else {
+				ok = true
 			}
 			if identity != nil {
-				ok, _, _ = FindUserAndCreateSessByBaseUserId(identity.UserId, m.Session(), false)
+				ok = ok && NewIdentityInfo(identity).Switch(m.Session())
 			}
 		} else {
 			if str[1] == "_id" {
-				ok, _, _ = FindUserAndCreateSessById(mgdb.StringTOBsonId(userFlag), m.Session(), false)
+				ok, _, _ = FindUserAndCreateSessById(mgdb.StringTOBsonId(userFlag), m.Session(), false, true)
+				if !ok {
+					log.Println("创建session失败", str)
+				}
 			} else {
-				ok, _, _ = FindUserAndCreateSess(userFlag, m.Session(), "wx", false)
+				ok, _, _ = FindUserAndCreateSess(userFlag, m.Session(), "wx", false, true)
+				if !ok {
+					log.Println("创建session失败", str)
+				}
 			}
-			identity = config.Middleground.UserCenter.IdentityByUserId(util.Int64All(m.GetSession("base_user_id")))
 		}
-		ok = ok && NewIdentityInfo(identity).Switch(m.Session())
 		if ok {
 			actionurl := ""
 			if str[3] == "" {
@@ -884,6 +914,8 @@ func (m *Front) Sess(ostr string) error {
 					}
 					if identity := config.Middleground.UserCenter.IdentityByEntUserId(entUserId); identity != nil {
 						NewIdentityInfo(identity).Switch(m.Session())
+					} else {
+						log.Println("获取用户身份失败", str)
 					}
 				}
 			} else {
@@ -915,7 +947,7 @@ func (m *Front) Sess(ostr string) error {
 					//action走的nginx配置,需要单独在sess中判断
 					for k, v := range config.PhoneFilterConfig["sessUrl"].(map[string]interface{}) {
 						if strings.Contains(actionurl, k) {
-							uid, _ := m.GetSession("userId").(string)
+							uid, _ := m.GetSession("mgoUserId").(string)
 							if NeedBind(uid) {
 								if mobileReg.MatchString(m.UserAgent()) {
 									redirectTo := actionurl

+ 1 - 1
src/jfw/front/frontRouter.go

@@ -82,7 +82,7 @@ func (this *CommonRouter) WxCommonPage(folder, loginSign, htmlPage string) error
 				return this.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(this.Site()+this.Url()), "wx"), 302)
 			}
 			openid = jyutil.Getopenid(this.GetString("code"))
-			if ok, _, _ := FindUserAndCreateSess(openid, this.Session(), "wx", false); !ok {
+			if ok, _, _ := FindUserAndCreateSess(openid, this.Session(), "wx", false, true); !ok {
 				return this.Redirect("/swordfish/about")
 			}
 		}

+ 2 - 2
src/jfw/front/login.go

@@ -17,9 +17,9 @@ import (
 
 	. "app.yhyue.com/moapp/jybase/mongodb"
 
-	"github.com/dchest/captcha"
 	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"github.com/dchest/captcha"
 	"go.mongodb.org/mongo-driver/bson/primitive"
 )
 
@@ -340,7 +340,7 @@ func afterLogin(phone string, session *httpsession.Session) (bool, *map[string]i
 	if user == nil || len(user) == 0 {
 		return false, nil, nil
 	}
-	return FindUserAndCreateSessById(user["_id"].(primitive.ObjectID), session, true)
+	return FindUserAndCreateSessById(user["_id"].(primitive.ObjectID), session, true, true)
 }
 
 func GetModule(source string) string {

+ 2 - 2
src/jfw/front/org_structure.go

@@ -94,7 +94,7 @@ func (this *OrgStructure) InvitationPage() error {
 			isSubscribe = CheckUserIsSubscribe(openId)
 			if isSubscribe {
 				registered = "1"
-				FindUserAndCreateSess(openId, this.Session(), "wx", false)
+				FindUserAndCreateSess(openId, this.Session(), "wx", false, true)
 				phone = util.If(this.GetSession("phone") != nil, this.GetSession("phone"), "").(string)
 			}
 		}
@@ -122,7 +122,7 @@ func (this *OrgStructure) Authorize() error {
 	if openId != "" {
 		isSubscribe = CheckUserIsSubscribe(openId)
 		if isSubscribe {
-			FindUserAndCreateSess(openId, this.Session(), "wx", false)
+			FindUserAndCreateSess(openId, this.Session(), "wx", false, true)
 		} else { //获取未关注用户uninoid
 			unionId = GetUnionid(openId)
 		}

+ 1 - 1
src/jfw/front/pchelper.go

@@ -310,7 +310,7 @@ func (l *PcHelper) ToAct(token string) error {
 						CreateSession(map[string]interface{}{
 							"i_appid": 2,
 							"s_phone": phone,
-						}, l.Session(), "pchelper", true)
+						}, l.Session(), "pchelper", true, true)
 					} else {
 						LoginInfo("", phone, l.Session())
 					}

+ 3 - 3
src/jfw/front/shorturl.go

@@ -92,7 +92,7 @@ func (s *Short) Article(stype, id string) error {
 				if code := s.GetString("code"); code != "" {
 					if openid := jyutil.Getopenid(code); openid != "" {
 						if CheckUserIsSubscribe(openid) {
-							FindUserAndCreateSess(openid, s.Session(), "wx", false)
+							FindUserAndCreateSess(openid, s.Session(), "wx", false, true)
 						}
 					}
 				}
@@ -227,7 +227,7 @@ func (s *Short) Article(stype, id string) error {
 		res, ok = public.MQFW.FindById("user", userId, `{"i_vip_status":1,"i_member_status":1,"s_m_phone":1,"s_phone":1,"l_vip_starttime":1}`)
 	}
 	entid := util.Int64All(s.GetSession("entId"))
-	userPower := jy.GetBigVipUserBaseMsg( s.Session(), *config.Middleground)
+	userPower := jy.GetBigVipUserBaseMsg(s.Session(), *config.Middleground)
 	var (
 		isEntnicheNew bool = userPower.EntIsNew           //新版超级订阅
 		isOldVip      bool = false                        //新购超级订阅不能查看拟建项目详情页
@@ -268,7 +268,7 @@ func (s *Short) Article(stype, id string) error {
 			}
 			//之前sessionkeep.go中没有放userId,造成关注有问题
 			if s.GetSession("userId") == nil {
-				FindUserAndCreateSess(ssOpenid.(string), s.Session(), "wx", false)
+				FindUserAndCreateSess(ssOpenid.(string), s.Session(), "wx", false, true)
 			}
 		}
 		surl := s.GetString("url")

+ 1 - 1
src/jfw/front/swordfish.go

@@ -1121,7 +1121,7 @@ func (m *Front) About() error {
 	if myopenid != "" {
 		isSubscribe = CheckUserIsSubscribe(myopenid)
 		if isSubscribe {
-			FindUserAndCreateSess(myopenid, m.Session(), "wx", false)
+			FindUserAndCreateSess(myopenid, m.Session(), "wx", false, true)
 			myopenid, _ = m.Session().Get("s_m_openid").(string)
 			mynickname, _ = m.Session().Get("s_nickname").(string)
 		}

+ 6 - 6
src/jfw/front/vipsubscribe.go

@@ -147,7 +147,7 @@ func (s *Subscribepay) ToSetPage() error {
 		}
 	}
 
-	vipMsg := jy.GetBigVipUserBaseMsg( s.Session(), *config.Middleground)
+	vipMsg := jy.GetBigVipUserBaseMsg(s.Session(), *config.Middleground)
 	if vipMsg.VipStatus <= 0 && vipMsg.Status <= 0 && isInTSguide(userid) { //仅免费用户跳转向导页面
 		return s.Redirect("/front/tenderSubscribe/guide?url=" + url.QueryEscape(s.Request.RequestURI))
 	} else if (vSwitch == "" || vSwitch == "v") && vipMsg.VipStatus <= 0 && !vipMsg.IsUpgrade {
@@ -211,7 +211,7 @@ func (s *Subscribepay) Introduce() error {
 				if openid != "" {
 					isSubscribe := CheckUserIsSubscribe(openid)
 					if isSubscribe {
-						FindUserAndCreateSess(openid, s.Session(), "wx", false)
+						FindUserAndCreateSess(openid, s.Session(), "wx", false, true)
 						userId = util.ObjToString(s.GetSession("userId"))
 					}
 				}
@@ -227,7 +227,7 @@ func (s *Subscribepay) Introduce() error {
 	if userId == "" {
 		return s.Redirect("/swordfish/about?v=1")
 	}
-	m := jy.GetBigVipUserBaseMsg( s.Session(), *config.Middleground)
+	m := jy.GetBigVipUserBaseMsg(s.Session(), *config.Middleground)
 	if m == nil {
 		return s.Redirect("/swordfish/about?v=2")
 	}
@@ -276,7 +276,7 @@ func (s *Subscribepay) ToPurchasePage(flag string) {
 	if userId == "" {
 		return
 	}
-	m := jy.GetBigVipUserBaseMsg( s.Session(), *config.Middleground)
+	m := jy.GetBigVipUserBaseMsg(s.Session(), *config.Middleground)
 	if m == nil {
 		s.Redirect("/swordfish/about?v=2")
 		return
@@ -421,7 +421,7 @@ func (s *Subscribepay) OpenInvoice(order_code string) {
 
 //预热活动链接跳转
 func (s *Subscribepay) PreheatPoster() {
-	u := jy.GetBigVipUserBaseMsg( s.Session(), *config.Middleground)
+	u := jy.GetBigVipUserBaseMsg(s.Session(), *config.Middleground)
 	if u != nil {
 		if u.VipStatus == 1 || u.VipStatus == 2 {
 			s.Redirect("/front/vipsubscribe/toSubVipSetPage")
@@ -465,7 +465,7 @@ func (s *Subscribepay) Msgremind() error {
 	if userId == "" {
 		return s.Render("_error.html")
 	}
-	user := jy.GetBigVipUserBaseMsg( s.Session(), *config.Middleground)
+	user := jy.GetBigVipUserBaseMsg(s.Session(), *config.Middleground)
 	if user == nil {
 		return s.Render("_error.html")
 	}

+ 1 - 1
src/jfw/front/websocket.go

@@ -155,7 +155,7 @@ func LoginInfo(shareid, openid string, Sess interface{}) map[string]interface{}
 	}
 	sess, _ := Sess.(*httpsession.Session)
 	if openid != "" {
-		ok, user, infoData := FindUserAndCreateSess(openid, sess, "pc", true)
+		ok, user, infoData := FindUserAndCreateSess(openid, sess, "pc", true, true)
 		if ok {
 			(*user)["shareid"] = shareid
 			sess.Set("user", *user)

+ 4 - 4
src/jfw/front/ws_dataExport.go

@@ -56,7 +56,7 @@ func (w *WsDataExport) WxToOrderDetail() error {
 			if code != "" {
 				openid := jyutil.Getopenid(code)
 				if openid != "" {
-					FindUserAndCreateSess(openid, w.Session(), "wx", false)
+					FindUserAndCreateSess(openid, w.Session(), "wx", false, true)
 				}
 			}
 		} else {
@@ -232,7 +232,7 @@ func (w *WsDataExport) ToPreview(_id string) error {
 			if code != "" {
 				openid = jyutil.Getopenid(code)
 				if openid != "" {
-					FindUserAndCreateSess(openid, w.Session(), "wx", false)
+					FindUserAndCreateSess(openid, w.Session(), "wx", false, true)
 				}
 			}
 		} else {
@@ -262,7 +262,7 @@ func (w *WsDataExport) SubmitOrder() error {
 			if code != "" {
 				openid = jyutil.Getopenid(code)
 				if openid != "" {
-					FindUserAndCreateSess(openid, w.Session(), "wx", false)
+					FindUserAndCreateSess(openid, w.Session(), "wx", false, true)
 				}
 			}
 		} else {
@@ -376,7 +376,7 @@ func (wd *WsDataExport) SearchExport() error {
 	}
 	saveData := reqData.PassBidSearchExport(config.Sysconfig)
 
-	saveData["selectType"] = strings.Join(jy.GetVipState( wd.Session(), *config.Middleground, userId).
+	saveData["selectType"] = strings.Join(jy.GetVipState(wd.Session(), *config.Middleground, userId).
 		GetQueryItems(wd.GetString("selectType"), util.Int64All(config.Sysconfig["bidSearchOldUserLimit"])), ",")
 	saveData["s_openid"] = openid
 	saveData["s_userid"] = userId

+ 4 - 3
src/jfw/front/wxMyOrder.go

@@ -1,13 +1,14 @@
 package front
 
 import (
-	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
 	"errors"
 	"fmt"
 	"jy/src/jfw/config"
 	"jy/src/jfw/wx"
 	"net/url"
 
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+
 	"jy/src/jfw/jyutil"
 
 	"app.yhyue.com/moapp/jypkg/public"
@@ -62,7 +63,7 @@ func (w *WxMyOrder) MyMenu() error {
 			if code != "" {
 				openid := jyutil.Getopenid(code)
 				if openid != "" {
-					FindUserAndCreateSess(openid, w.Session(), "wx", false)
+					FindUserAndCreateSess(openid, w.Session(), "wx", false, true)
 				}
 			}
 		} else {
@@ -187,7 +188,7 @@ func (w *WxMyOrder) Myset() error {
 	userid := util.ObjToString(w.GetSession("userId"))
 	isVip := false
 	if userid != "" {
-		user := jy.GetBigVipUserBaseMsg( w.Session(), *config.Middleground)
+		user := jy.GetBigVipUserBaseMsg(w.Session(), *config.Middleground)
 		if user != nil {
 			if user.VipStatus == 1 || user.VipStatus == 2 {
 				isVip = true

+ 2 - 10
src/jfw/modules/app/src/app/filter/filter.go

@@ -9,6 +9,7 @@ import (
 	util "app.yhyue.com/moapp/jybase/common"
 	fs "app.yhyue.com/moapp/jybase/fsnotify"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jypkg/identity"
 )
 
 var RouteConf struct {
@@ -41,16 +42,7 @@ func (f *Filter) Do(w http.ResponseWriter, r *http.Request) bool {
 		session.Set("mgoUserId", getSession["userId"])
 	}
 	if getSession["base_user_id"] != nil && getSession["positionId"] == nil {
-		identity := Middleground.UserCenter.IdentityByUserId(util.Int64All(getSession["base_user_id"]))
-		if identity != nil {
-			session.SetMultiple(map[string]interface{}{
-				"personId":     identity.PersonId,
-				"userName":     identity.UserName,
-				"accountId":    identity.AccountId,
-				"positionId":   identity.PositionId,
-				"positionType": identity.PositionType,
-			})
-		}
+		identity.SwitchToBest(util.Int64All(getSession["base_user_id"]), session, Middleground)
 	}
 	if !(&logFilter{w, r, getSession}).Do() {
 		return false

+ 64 - 70
src/jfw/modules/app/src/app/front/login.go

@@ -279,26 +279,40 @@ func (l *Login) Sess(ostr string) error {
 	str := strings.Split(sewx.DecodeString(strs[0]), ",")
 	if len(str) == 4 {
 		hasSession := false
-		if l.GetSession("positionId") != nil {
-			hasSession = true
-		} else {
-			loginId := str[0]
+		loginId := str[0]
+		if str[1] == "userId" || str[1] == "entUserId" || str[1] == "positionId" {
 			var identity *pb.Identity
-			if str[1] == "userId" || str[1] == "entUserId" || str[1] == "positionId" {
-				if str[1] == "userId" {
+			sessVal := l.Session().GetMultiple()
+			if str[1] == "userId" {
+				if sessVal["positionType"] == nil || qutil.IntAll(sessVal["positionType"]) != 0 {
 					identity = config.Middleground.UserCenter.IdentityByUserId(qutil.Int64All(loginId))
-				} else if str[1] == "entUserId" {
+				}
+			} else if str[1] == "entUserId" {
+				if sessVal["positionType"] == nil || sessVal["entUserId"] == nil || qutil.Int64All(sessVal["positionType"]) != 1 || qutil.Int64All(sessVal["entUserId"]) != qutil.Int64All(loginId) {
 					identity = config.Middleground.UserCenter.IdentityByEntUserId(qutil.Int64All(loginId))
-				} else if str[1] == "positionId" {
+				}
+			} else if str[1] == "positionId" {
+				if sessVal["positionId"] == nil || qutil.Int64All(sessVal["positionId"]) != qutil.Int64All(loginId) {
 					identity = config.Middleground.UserCenter.IdentityByPositionId(qutil.Int64All(loginId))
 				}
-				if identity != nil {
-					if createSession(l.Session(), nil, fmt.Sprint(identity.UserId), 3, l.ResponseWriter) {
-						hasSession = true
-					} else {
-						log.Println("创建session失败", str)
-					}
+			} else {
+				return l.Redirect("/jyapp/free/mob/err")
+			}
+			if sessVal["userId"] == nil {
+				if createSession(l.Session(), fmt.Sprint(identity.UserId), 3, l.ResponseWriter, false) {
+					hasSession = true
+				} else {
+					log.Println("创建session失败", str)
 				}
+			} else {
+				hasSession = true
+			}
+			if identity != nil {
+				hasSession = hasSession && NewIdentityInfo(identity).Switch(l.Session())
+			}
+		} else {
+			if l.GetSession("userId") != nil {
+				hasSession = true
 			} else {
 				loginType := 0
 				if str[1] == "uid" {
@@ -307,18 +321,15 @@ func (l *Login) Sess(ostr string) error {
 						loginType = 1
 					}
 				}
-				if createSession(l.Session(), nil, loginId, loginType, l.ResponseWriter) {
+				if createSession(l.Session(), loginId, loginType, l.ResponseWriter, true) {
 					hasSession = true
-					identity = config.Middleground.UserCenter.IdentityByUserId(qutil.Int64All(l.GetSession("base_user_id")))
+					if identity := config.Middleground.UserCenter.IdentityByUserId(qutil.Int64All(l.GetSession("base_user_id"))); identity != nil {
+						hasSession = hasSession && NewIdentityInfo(identity).Switch(l.Session())
+					}
 				} else {
 					log.Println("创建session失败", str)
 				}
 			}
-			if identity != nil {
-				hasSession = hasSession && NewIdentityInfo(identity).Switch(l.Session())
-			} else {
-				log.Println("获取用户身份信息失败", str)
-			}
 		}
 		if hasSession {
 			actionurl := ""
@@ -998,50 +1009,34 @@ func findWxExistsId(phoneNum string) interface{} {
  * 创建session
  * loginType 0 _id 1 s_phone 2 a_m_openid
  */
-func createSession(s *httpsession.Session, person map[string]interface{}, loginId string, loginType int, rw http.ResponseWriter) bool {
-	if person == nil {
-		if loginId == "" {
-			return false
-		}
-		query := map[string]interface{}{
-			"i_appid": 2,
-		}
-		switch loginType {
-		case 0: //_id登录
-			query["_id"], _ = primitive.ObjectIDFromHex(loginId)
-			break
-		case 1: //s_phone登录
-			query["s_phone"] = loginId
-			break
-		case 2: //a_m_openid登录
-			query["a_m_openid"] = loginId
-			break
-		case 3: //base_user_id登录
-			query["base_user_id"] = qutil.Int64All(loginId)
-			break
-		default:
-			return false
-		}
-		field := `{"s_m_openid":1,"s_phone":1,"s_jpushid":1,"s_opushid":1,"s_appponetype":1,"s_headimageurl":1,"s_phone":1,"s_nickname":1,"s_appversion":1,"i_unlimited":1,"s_jyname":1,"base_user_id":1}`
-		data, ok := mongodb.FindOneByField("user", query, field)
-		if !ok {
-			return false
-		}
-		if data == nil || len(*data) == 0 {
-			query = map[string]interface{}{
-				"s_m_openid": loginId,
-				"i_appid":    2,
-			}
-			data, ok = mongodb.FindOneByField("user", query, field)
-			if !ok {
-				return false
-			}
-		}
-		if data == nil || len(*data) == 0 {
-			return false
-		}
-		person = *data
+func createSession(s *httpsession.Session, loginId string, loginType int, rw http.ResponseWriter, isSwitchToBestIdentity bool) bool {
+	if loginId == "" {
+		return false
+	}
+	query := map[string]interface{}{
+		"i_appid": 2,
 	}
+	switch loginType {
+	case 0: //_id登录
+		query["_id"], _ = primitive.ObjectIDFromHex(loginId)
+		break
+	case 1: //s_phone登录
+		query["s_phone"] = loginId
+		break
+	case 2: //a_m_openid登录
+		query["a_m_openid"] = loginId
+		break
+	case 3: //base_user_id登录
+		query["base_user_id"] = qutil.Int64All(loginId)
+		break
+	default:
+		return false
+	}
+	data, ok := mongodb.FindOneByField("user", query, `{"s_m_openid":1,"s_phone":1,"s_jpushid":1,"s_opushid":1,"s_appponetype":1,"s_headimageurl":1,"s_phone":1,"s_nickname":1,"s_appversion":1,"i_unlimited":1,"s_jyname":1,"base_user_id":1}`)
+	if !ok || data == nil || len(*data) == 0 {
+		return false
+	}
+	person := *data
 	sessVal := map[string]interface{}{}
 	sessVal["userId"] = BsonIdToSId(person["_id"])
 	sessVal["mgoUserId"] = sessVal["userId"]
@@ -1071,6 +1066,9 @@ func createSession(s *httpsession.Session, person map[string]interface{}, loginI
 		sessVal["s_jyname"] = person["s_jyname"]
 	}
 	s.SetMultiple(sessVal)
+	if isSwitchToBestIdentity {
+		SwitchToBest(qutil.Int64All(sessVal["base_user_id"]), s, config.Middleground)
+	}
 	//cookie
 	maxAge := int(time.Hour * 72 / time.Second) //3天,单位秒
 	expires := time.Now().Add(72 * time.Hour)
@@ -1129,7 +1127,6 @@ func getSign(u *UserSign) (string, string) {
 }
 
 func afterLogin(user map[string]interface{}, session *httpsession.Session, rid, oid, phoneType, channel, deviceId string, isNewUser bool, rw http.ResponseWriter) string {
-	log.Println("===>", fmt.Sprint(session.Id()))
 	userid := BsonIdToSId(user["_id"])
 	old_rid, _ := user["s_jpushid"].(string)
 	old_oid, _ := user["s_opushid"].(string)
@@ -1215,10 +1212,7 @@ func afterLogin(user map[string]interface{}, session *httpsession.Session, rid,
 			jyutil.UnLoginPush.DeleteBuff(rid)
 		}
 	}()
-	user["s_jpushid"] = rid
-	user["s_opushid"] = oid
-	user["s_appponetype"] = phoneType
-	createSession(session, user, "", 0, rw)
+	createSession(session, userid, 0, rw, true)
 	return createSign(userid, rid, "登录后", session)
 }
 
@@ -1242,7 +1236,7 @@ func autoLogin(sign, from string, session *httpsession.Session, rw http.Response
 	// 		return -3
 	// 	}
 	// }
-	if createSession(session, nil, u.UserId, 0, rw) {
+	if createSession(session, u.UserId, 0, rw, true) {
 		return 1
 	}
 	return 0

+ 2 - 1
src/jfw/modules/app/src/config.yaml

@@ -2,4 +2,5 @@ etcd:
   hosts:
   - 127.0.0.1:2379
 userCenterKey: "usercenter.rpc" #用户中台rpc
-powerCheckCenterKey: "powercheck.rpc" #权益校验中台
+powerCheckCenterKey: "powercheck.rpc" #权益校验中台
+entManageApplication: "entmanageapplication.rpc" #企业管理中台

+ 2 - 1
src/jfw/modules/app/src/go.mod

@@ -4,7 +4,7 @@ go 1.18
 
 require (
 	app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a
-	app.yhyue.com/moapp/jypkg v0.0.0-20230207063159-81037e8f31e2
+	app.yhyue.com/moapp/jypkg v0.0.0-20230209055147-4cf703ace114
 	bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.13-0.20230207022117-85952189304d
 	github.com/SKatiyar/qr v0.0.0-20151201054752-25b6bdf44e67
 	github.com/dchest/captcha v1.0.0
@@ -16,6 +16,7 @@ require (
 require (
 	app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d // indirect
 	app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae // indirect
+	bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230209051900-1e7dcb8f83b7 // indirect
 	bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230207054315-b05f3dd4c4d3 // indirect
 	bp.jydev.jianyu360.cn/BaseService/resourceCenter v0.0.4 // indirect
 	github.com/BurntSushi/toml v0.4.1 // indirect

+ 4 - 2
src/jfw/modules/app/src/go.sum

@@ -13,11 +13,13 @@ app.yhyue.com/moapp/jybase v0.0.0-20220802080941-07f401baab8b/go.mod h1:HelrO6tc
 app.yhyue.com/moapp/jybase v0.0.0-20221229065928-e4ba75127ac9/go.mod h1:efAeRPDpJ13JuNODuqtfLlKQSQgCbnUcwGPzhFU5krY=
 app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a h1:wD4aWPSYdiX1cIP4lzzPD2s7fYhKa3muIf97l9tonJE=
 app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a/go.mod h1:zB47XTeJvpcbtBRYgkQuxOICWNexiZfbUO+7aUf6mNs=
-app.yhyue.com/moapp/jypkg v0.0.0-20230207063159-81037e8f31e2 h1:HzTwWNuWccdzWcmXo32mCb7iRHgH5QRn0i5YsmpQ2U8=
-app.yhyue.com/moapp/jypkg v0.0.0-20230207063159-81037e8f31e2/go.mod h1:0DqPlGxaufZlKaLoRndTWG4j3qUQqJ6MNZCmoPcMqSg=
+app.yhyue.com/moapp/jypkg v0.0.0-20230209055147-4cf703ace114 h1:89J5Zq4bfnocIpEWBn19PnfaT+8Dh+Rv4X8QoTwxCpg=
+app.yhyue.com/moapp/jypkg v0.0.0-20230209055147-4cf703ace114/go.mod h1:sa5YRPqTQLOVBmpltjT21EkQ7DfJbUZFARUb4ZJ7U+k=
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae h1:6rDDaz6yxvE8viTSzEBwKYOFWq14TMfuBivSazUZMz4=
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae/go.mod h1:b0zZHev3gmJao1Fo+2Z2KPVjsuLOJVvVxf+kCnu9WkA=
 bp.jydev.jianyu360.cn/BP/jynsq v0.0.0-20220222052708-ebc43af90698/go.mod h1:ojo/AUH9Yr1wzarEjOaNMkj1Cet/9r8IgLyba64Z52E=
+bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230209051900-1e7dcb8f83b7 h1:cw/PdRypNFcYOk4iWAfHjIFoMzIlXUfl9XAmWujBOPY=
+bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230209051900-1e7dcb8f83b7/go.mod h1:7Xhygw0KBuL4h0G76FnFg4otQcA9bmOO0c8M0FCjAyQ=
 bp.jydev.jianyu360.cn/BaseService/gateway v0.0.0-20220419090715-88ddb32961be/go.mod h1:Yj4oabIGItuMoF0BXYLz2XAnF581kxgXBrvlUtIJrkI=
 bp.jydev.jianyu360.cn/BaseService/gateway v1.3.4/go.mod h1:BMLd/5wb3BIEGhnEgF9y1sJN9P5/Dw9kYsoiE9V8I9g=
 bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230206031623-08905194200a/go.mod h1:5nimT8GJh46AyfeeDeyRlDQygMlO7TRM8Pwm41Gxemc=

+ 4 - 1
src/jfw/modules/app/src/jfw/config/config.go

@@ -39,5 +39,8 @@ func init() {
 		GmailAuth = append(GmailAuth, mailConf)
 	}
 	var ctx = gctx.New()
-	Middleground = middleground.NewMiddleground(g.Cfg().MustGet(ctx, "etcd.hosts").Strings()).RegUserCenter(g.Cfg().MustGet(ctx, "userCenterKey").String()).RegPowerCheckCenter(g.Cfg().MustGet(ctx, "powerCheckCenterKey").String())
+	Middleground = middleground.NewMiddleground(g.Cfg().MustGet(ctx, "etcd.hosts").Strings()).
+		RegUserCenter(g.Cfg().MustGet(ctx, "userCenterKey").String()).
+		RegPowerCheckCenter(g.Cfg().MustGet(ctx, "powerCheckCenterKey").String()).
+		RegPowerCheckCenter(g.Cfg().MustGet(ctx, "entManageApplication").String())
 }

+ 2 - 1
src/jfw/modules/publicapply/src/config.yaml

@@ -2,4 +2,5 @@ etcd:
   hosts:
   - 127.0.0.1:2379
 userCenterKey: "usercenter.rpc" #用户中台rpc
-powerCheckCenterKey: "powercheck.rpc" #权益校验中台
+powerCheckCenterKey: "powercheck.rpc" #权益校验中台
+entManageApplication: "entmanageapplication.rpc" #企业管理中台

+ 4 - 1
src/jfw/modules/publicapply/src/config/config.go

@@ -75,5 +75,8 @@ func init() {
 	qutil.ReadConfig("./adLeague.json", &AdLeaguefig)
 	qutil.ReadConfig("./shareFission.json", &ShareConfig)
 	var ctx = gctx.New()
-	Middleground = middleground.NewMiddleground(g.Cfg().MustGet(ctx, "etcd.hosts").Strings()).RegUserCenter(g.Cfg().MustGet(ctx, "userCenterKey").String()).RegPowerCheckCenter(g.Cfg().MustGet(ctx, "powerCheckCenterKey").String())
+	Middleground = middleground.NewMiddleground(g.Cfg().MustGet(ctx, "etcd.hosts").Strings()).
+		RegUserCenter(g.Cfg().MustGet(ctx, "userCenterKey").String()).
+		RegPowerCheckCenter(g.Cfg().MustGet(ctx, "powerCheckCenterKey").String()).
+		RegPowerCheckCenter(g.Cfg().MustGet(ctx, "entManageApplication").String())
 }

+ 2 - 10
src/jfw/modules/publicapply/src/filter/sessionfilter.go

@@ -8,6 +8,7 @@ import (
 	. "app.yhyue.com/moapp/jybase/api"
 	util "app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jypkg/identity"
 )
 
 //登录限制
@@ -26,16 +27,7 @@ func (l *sessionfilter) Do(w http.ResponseWriter, req *http.Request) bool {
 		session.Set("mgoUserId", getSession["userId"])
 	}
 	if getSession["base_user_id"] != nil && getSession["positionId"] == nil {
-		identity := Middleground.UserCenter.IdentityByUserId(util.Int64All(getSession["base_user_id"]))
-		if identity != nil {
-			session.SetMultiple(map[string]interface{}{
-				"personId":     identity.PersonId,
-				"userName":     identity.UserName,
-				"accountId":    identity.AccountId,
-				"positionId":   identity.PositionId,
-				"positionType": identity.PositionType,
-			})
-		}
+		identity.SwitchToBest(util.Int64All(getSession["base_user_id"]), session, Middleground)
 	}
 	if reg.MatchString(req.URL.Path) || reg.MatchString(req.URL.Path) || reg_share.MatchString(req.URL.Path) || reg_nps.MatchString(req.URL.Path) {
 		return true

+ 2 - 1
src/jfw/modules/publicapply/src/go.mod

@@ -4,7 +4,7 @@ go 1.18
 
 require (
 	app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a
-	app.yhyue.com/moapp/jypkg v0.0.0-20230208065001-1bb9895b1831
+	app.yhyue.com/moapp/jypkg v0.0.0-20230209055147-4cf703ace114
 	bp.jydev.jianyu360.cn/BaseService/userCenter v0.0.0-20230129060002-f69424aa14ba
 	github.com/SKatiyar/qr v0.0.0-20151201054752-25b6bdf44e67
 	github.com/gogf/gf/v2 v2.0.6
@@ -15,6 +15,7 @@ require (
 require (
 	app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d // indirect
 	app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae // indirect
+	bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230209051900-1e7dcb8f83b7 // indirect
 	bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230207054315-b05f3dd4c4d3 // indirect
 	bp.jydev.jianyu360.cn/BaseService/resourceCenter v0.0.4 // indirect
 	github.com/BurntSushi/toml v0.4.1 // indirect

+ 4 - 2
src/jfw/modules/publicapply/src/go.sum

@@ -13,11 +13,13 @@ app.yhyue.com/moapp/jybase v0.0.0-20220802080941-07f401baab8b/go.mod h1:HelrO6tc
 app.yhyue.com/moapp/jybase v0.0.0-20230109015757-aa3d5e19b196/go.mod h1:zB47XTeJvpcbtBRYgkQuxOICWNexiZfbUO+7aUf6mNs=
 app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a h1:wD4aWPSYdiX1cIP4lzzPD2s7fYhKa3muIf97l9tonJE=
 app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a/go.mod h1:zB47XTeJvpcbtBRYgkQuxOICWNexiZfbUO+7aUf6mNs=
-app.yhyue.com/moapp/jypkg v0.0.0-20230208065001-1bb9895b1831 h1:5cvWBzlXrD0AsUhveS4UtERAhlRf2lPTDP+5Vyw9NlU=
-app.yhyue.com/moapp/jypkg v0.0.0-20230208065001-1bb9895b1831/go.mod h1:0DqPlGxaufZlKaLoRndTWG4j3qUQqJ6MNZCmoPcMqSg=
+app.yhyue.com/moapp/jypkg v0.0.0-20230209055147-4cf703ace114 h1:89J5Zq4bfnocIpEWBn19PnfaT+8Dh+Rv4X8QoTwxCpg=
+app.yhyue.com/moapp/jypkg v0.0.0-20230209055147-4cf703ace114/go.mod h1:sa5YRPqTQLOVBmpltjT21EkQ7DfJbUZFARUb4ZJ7U+k=
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae h1:6rDDaz6yxvE8viTSzEBwKYOFWq14TMfuBivSazUZMz4=
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae/go.mod h1:b0zZHev3gmJao1Fo+2Z2KPVjsuLOJVvVxf+kCnu9WkA=
 bp.jydev.jianyu360.cn/BP/jynsq v0.0.0-20220222052708-ebc43af90698/go.mod h1:ojo/AUH9Yr1wzarEjOaNMkj1Cet/9r8IgLyba64Z52E=
+bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230209051900-1e7dcb8f83b7 h1:cw/PdRypNFcYOk4iWAfHjIFoMzIlXUfl9XAmWujBOPY=
+bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230209051900-1e7dcb8f83b7/go.mod h1:7Xhygw0KBuL4h0G76FnFg4otQcA9bmOO0c8M0FCjAyQ=
 bp.jydev.jianyu360.cn/BaseService/gateway v0.0.0-20220419090715-88ddb32961be/go.mod h1:Yj4oabIGItuMoF0BXYLz2XAnF581kxgXBrvlUtIJrkI=
 bp.jydev.jianyu360.cn/BaseService/gateway v1.3.4/go.mod h1:BMLd/5wb3BIEGhnEgF9y1sJN9P5/Dw9kYsoiE9V8I9g=
 bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230207054315-b05f3dd4c4d3 h1:jeItQ6RM1T6yPWc/5i4R6h3kViD+Rm2VnIEsc1gCFJA=