1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package service
- import (
- "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/redis"
- "bp.jydev.jianyu360.cn/BaseService/biService/entity"
- "encoding/base64"
- "encoding/json"
- "github.com/gogf/gf/v2/util/gconv"
- "github.com/tjfoc/gmsm/sm4"
- "log"
- )
- type InfoService struct {
- }
- func (l *InfoService) Myinfo(sid string) []byte {
- log.Println("1111", sid)
- 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"])
- }
- }
- 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)),
- }
- }
- 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)
- }
|