123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package identity
- import (
- "strconv"
- "app.yhyue.com/moapp/jybase/go-xweb/httpsession"
- "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
- )
- type IdentityInfo struct {
- Name string //名称
- PersonId int64 //自然人id
- UserName string //用户昵称
- AccountId int64 //账户id
- EntAccountId int64 //企业账户id
- PositionId int64 //职位id
- PositionType int64 //职位类型
- EntId int64 //企业id
- EntUserId int64 //企业员工id
- EntUserName string //企业员工姓名
- }
- func NewIdentityInfo(i *pb.Identity) *IdentityInfo {
- return &IdentityInfo{
- Name: i.Name,
- PersonId: i.PersonId,
- UserName: i.UserName,
- AccountId: i.AccountId,
- EntAccountId: i.EntAccountId,
- PositionId: i.PositionId,
- PositionType: i.PositionType,
- EntId: i.EntId,
- EntUserId: i.EntUserId,
- EntUserName: i.EntUserName,
- }
- }
- //切换身份
- func (i *IdentityInfo) Switch(sess *httpsession.Session) bool {
- ok := false
- m := map[string]interface{}{
- "personId": i.PersonId,
- "userName": i.UserName,
- "accountId": i.AccountId,
- "positionId": i.PositionId,
- "positionType": i.PositionType,
- }
- if i.PositionType == 0 {
- if sess.Del("entId", "entName", "entUserId", "entUserName", "entAccountId") {
- m["userId"] = sess.Get("mgoUserId")
- ok = true
- }
- } else {
- m["userId"] = strconv.FormatInt(i.PositionId, 10)
- m["entAccountId"] = i.EntAccountId
- ok = true
- }
- sess.SetMultiple(m)
- return ok
- }
|