123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package service
- import (
- "encoding/base64"
- "encoding/json"
- "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/redis"
- "bp.jydev.jianyu360.cn/BaseService/biService/entity"
- "github.com/gogf/gf/v2/util/gconv"
- "github.com/tjfoc/gmsm/sm4"
- )
- type InfoService struct {
- }
- func (l *InfoService) Myinfo(sid string) []byte {
- infoMap := map[string]string{}
- info_i := redis.Get("session", sid)
- if info_i != nil {
- info_m, _ := info_i.(map[string]interface{})
- entNicheDis := common.Int64All(info_m["entNicheDis"])
- depIDArr := ""
- if entNicheDis > 0 {
- //查询所有部门标识
- entId := gconv.String(info_m["entId"])
- entDeptId := gconv.String(info_m["entDeptId"])
- deptArr := entity.JyMysql.SelectBySql("select GROUP_CONCAT(DISTINCT b.id) as depIDArr from entniche_department_parent a"
- " INNER JOIN entniche_department b "
- "on (b.ent_id=? and (b.id=? or (a.pid=? and a.id=b.id)))", entId, entDeptId, entDeptId)
- if len(*deptArr) > 0 {
- depIDArr = common.InterfaceToStr((*deptArr)[0]["depIDArr"])
- }
- }
- //营销版本查询
- accountId := gconv.Int64(info_m["accountId"])
- entAccountId := gconv.Int64(info_m["entAccountId"])
- entId := gconv.Int64(info_m["entId"])
- entUserId := gconv.Int64(info_m["entUserId"])
- res := entity.Middleground.ResourceCenter.Haspowers(accountId, entAccountId, entId, entUserId)
- version := "0"
- for _, pCode := range res.Powers {
- //0:通用版 1:物业专版
- if pCode == "bi_yx_wyzb" {
- version = "1"
- }
- }
- infoMap = map[string]string{
- "nickName": RsaEncrypt([]byte(gconv.String(info_m["s_nickname"]))),
- "entRole": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["entRole"])))),
- "entNicheDis": RsaEncrypt([]byte(gconv.String(entNicheDis))),
- "positionId": RsaEncrypt([]byte(gconv.String(info_m["positionId"]))),
- "accountId": RsaEncrypt([]byte(gconv.String(info_m["accountId"]))),
- "entAccountId": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["entAccountId"])))),
- "entId": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["entId"])))),
- "entName": RsaEncrypt([]byte(gconv.String(info_m["entName"]))),
- "entUserName": RsaEncrypt([]byte(gconv.String(info_m["entUserName"]))),
- "entUserId": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["entUserId"])))),
- "userId": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["base_user_id"])))),
- "entDeptId": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["entDeptId"])))),
- "entChildDept": RsaEncrypt([]byte(depIDArr)),
- "crmVersion": RsaEncrypt([]byte(version)),
- }
- }
- infoByte, _ := json.Marshal(infoMap)
- return infoByte
- }
- // 加密
- func RsaEncrypt(data []byte) string {
- key := []byte(entity.PublicKey)
- //加密
- b, _ := sm4.Sm4Ecb(key, data, true)
- return base64.StdEncoding.EncodeToString(b)
- }
|