infoService.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 INNER JOIN entniche_department b "+
  25. "on (b.ent_id=? and (b.id=? or (a.pid=? and a.id=b.id)))", entId, entDeptId, entDeptId)
  26. if len(*deptArr) > 0 {
  27. depIDArr = common.InterfaceToStr((*deptArr)[0]["depIDArr"])
  28. }
  29. }
  30. //营销版本查询
  31. accountId := gconv.Int64(info_m["accountId"])
  32. entAccountId := gconv.Int64(info_m["entAccountId"])
  33. entId := gconv.Int64(info_m["entId"])
  34. entUserId := gconv.Int64(info_m["entUserId"])
  35. res := entity.Middleground.ResourceCenter.Haspowers(accountId, entAccountId, entId, entUserId)
  36. version := "0"
  37. for _, pCode := range res.Powers {
  38. //0:通用版 1:物业专版
  39. if pCode == "bi_yx_wyzb" {
  40. version = "1"
  41. }
  42. }
  43. infoMap = map[string]string{
  44. "nickName": RsaEncrypt([]byte(gconv.String(info_m["s_nickname"]))),
  45. "entRole": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["entRole"])))),
  46. "entNicheDis": RsaEncrypt([]byte(gconv.String(entNicheDis))),
  47. "positionId": RsaEncrypt([]byte(gconv.String(info_m["positionId"]))),
  48. "accountId": RsaEncrypt([]byte(gconv.String(info_m["accountId"]))),
  49. "entAccountId": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["entAccountId"])))),
  50. "entId": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["entId"])))),
  51. "entName": RsaEncrypt([]byte(gconv.String(info_m["entName"]))),
  52. "entUserName": RsaEncrypt([]byte(gconv.String(info_m["entUserName"]))),
  53. "entUserId": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["entUserId"])))),
  54. "userId": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["base_user_id"])))),
  55. "entDeptId": RsaEncrypt([]byte(gconv.String(common.Int64All(info_m["entDeptId"])))),
  56. "entChildDept": RsaEncrypt([]byte(depIDArr)),
  57. "crmVersion": RsaEncrypt([]byte(version)),
  58. }
  59. }
  60. infoByte, _ := json.Marshal(infoMap)
  61. return infoByte
  62. }
  63. // 加密
  64. func RsaEncrypt(data []byte) string {
  65. key := []byte(entity.PublicKey)
  66. //加密
  67. b, _ := sm4.Sm4Ecb(key, data, true)
  68. return base64.StdEncoding.EncodeToString(b)
  69. }