infoService.go 2.3 KB

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