power.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package service
  2. import (
  3. . "bp.jydev.jianyu360.cn/BaseService/resourceCenter/public/entity"
  4. )
  5. /*
  6. * 获取已有的权益
  7. * @param appid
  8. * @param function_code 功能代码
  9. * @param user_id 用户id
  10. * @param ent_id 企业id
  11. * @return 所有已开通的权益
  12. */
  13. func HasPowers(appid string, user_id, ent_id, ent_user_id int64) []string {
  14. result := []string{}
  15. m := map[string]bool{}
  16. bps := Base_power.FindMyPowers(appid, user_id, ent_id)
  17. if bps != nil {
  18. for _, v := range *bps {
  19. if v.Power_type == 1 || (v.Power_type == 2 && Base_ent_empower.HasEmpower(appid, v.Function_code, ent_id, ent_user_id)) {
  20. if m[v.Function_code] {
  21. continue
  22. }
  23. m[v.Function_code] = true
  24. result = append(result, v.Function_code)
  25. }
  26. }
  27. }
  28. return result
  29. }
  30. /*
  31. * 获取已有的权益
  32. * @param appid
  33. * @param function_code 功能代码
  34. * @param user_id 用户id
  35. * @param ent_id 企业id
  36. * @return 所有已开通的权益
  37. */
  38. func ReDistribution(appid string, ent_id int64, ent_user_id []int) []string {
  39. result := []string{}
  40. m := map[string]bool{}
  41. bps := Base_power.FindMyPowers(appid, user_id, ent_id)
  42. if bps != nil {
  43. for _, v := range *bps {
  44. if v.Power_type == 1 || (v.Power_type == 2 && Base_ent_empower.HasEmpower(appid, v.Function_code, ent_id, ent_user_id)) {
  45. if m[v.Function_code] {
  46. continue
  47. }
  48. m[v.Function_code] = true
  49. result = append(result, v.Function_code)
  50. }
  51. }
  52. }
  53. return result
  54. }