infoService.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package service
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "app.yhyue.com/moapp/jybase/redis"
  5. "bp.jydev.jianyu360.cn/BaseService/biService/entity"
  6. "encoding/base64"
  7. "github.com/gogf/gf/v2/util/gconv"
  8. "github.com/tjfoc/gmsm/sm4"
  9. "log"
  10. )
  11. type InfoService struct {
  12. }
  13. func (l *InfoService) Myinfo(sid string) map[string]string {
  14. log.Println("1111", sid)
  15. infoMap := map[string]string{}
  16. info_i := redis.Get("session", sid)
  17. if info_i != nil {
  18. info_m, _ := info_i.(map[string]interface{})
  19. entNicheDis := common.Int64All(info_m["entNicheDis"])
  20. depIDArr := ""
  21. if entNicheDis > 0 {
  22. //查询所有部门标识
  23. entId := gconv.String(info_m["entId"])
  24. entDeptId := gconv.String(info_m["entDeptId"])
  25. deptArr := entity.JyMysql.SelectBySql("select GROUP_CONCAT(DISTINCT b.id) as depIDArr from entniche_department_parent a"+
  26. " INNER JOIN entniche_department b "+
  27. "on (b.ent_id=? and (b.id=? or (a.pid=? and a.id=b.id)))", entId, entDeptId, entDeptId)
  28. if len(*deptArr) > 0 {
  29. depIDArr = common.InterfaceToStr((*deptArr)[0]["depIDArr"])
  30. }
  31. }
  32. infoMap = map[string]string{
  33. "nickName": RsaEncrypt([]byte(gconv.String(info_m["s_nickname"]))),
  34. "entRole": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["entRole"])))),
  35. "entNicheDis": RsaEncrypt([]byte(gconv.String(entNicheDis))),
  36. "positionId": RsaEncrypt([]byte(gconv.String(info_m["positionId"]))),
  37. "accountId": RsaEncrypt([]byte(gconv.String(info_m["accountId"]))),
  38. "entAccountId": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["entAccountId"])))),
  39. "entId": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["entId"])))),
  40. "entName": RsaEncrypt([]byte(gconv.String(info_m["entName"]))),
  41. "entUserName": RsaEncrypt([]byte(gconv.String(info_m["entUserName"]))),
  42. "entUserId": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["entUserId"])))),
  43. "userId": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["base_user_id"])))),
  44. "entDeptId": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["entDeptId"])))),
  45. "entChildDept": RsaEncrypt([]byte(depIDArr)),
  46. }
  47. }
  48. return infoMap
  49. }
  50. // 加密
  51. func RsaEncrypt(data []byte) string {
  52. key := []byte(entity.PublicKey)
  53. //加密
  54. b, _ := sm4.Sm4Ecb(key, data, true)
  55. return base64.StdEncoding.EncodeToString(b)
  56. }