infoService.go 2.8 KB

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