|
@@ -4,6 +4,7 @@ import (
|
|
|
"strconv"
|
|
|
|
|
|
"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
|
|
|
+ . "app.yhyue.com/moapp/jypkg/middleground"
|
|
|
"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
|
|
|
)
|
|
|
|
|
@@ -64,3 +65,32 @@ func (i *IdentityInfo) Switch(sess *httpsession.Session) bool {
|
|
|
sess.SetMultiple(m)
|
|
|
return ok
|
|
|
}
|
|
|
+
|
|
|
+//切换到最优身份
|
|
|
+func SwitchToBest(userId int64, sess *httpsession.Session, mgd *Middleground) bool {
|
|
|
+ list := mgd.UserCenter.IdentityList(userId)
|
|
|
+ if list == nil || len(list) == 0 {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ reqIds := []int64{}
|
|
|
+ for _, v := range list {
|
|
|
+ if v.PositionType == 1 {
|
|
|
+ reqIds = append(reqIds, v.EntUserId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(reqIds) > 0 {
|
|
|
+ if resp := mgd.EntManageApplication.EmpowerUserIds(reqIds); len(resp.Ids) > 0 {
|
|
|
+ for _, v := range list {
|
|
|
+ if v.PositionType == 1 && v.EntUserId == resp.Ids[0] {
|
|
|
+ return NewIdentityInfo(v).Switch(sess)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, v := range list {
|
|
|
+ if v.PositionType == 0 {
|
|
|
+ return NewIdentityInfo(v).Switch(sess)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|