audit.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package channel
  2. import (
  3. "context"
  4. "go-common/app/interface/main/app-channel/model"
  5. "go-common/library/log"
  6. )
  7. var (
  8. _auditRids = map[int8]map[int]struct{}{
  9. model.PlatIPad: map[int]struct{}{
  10. 1: struct{}{},
  11. 160: struct{}{},
  12. 119: struct{}{},
  13. 155: struct{}{},
  14. 165: struct{}{},
  15. 5: struct{}{},
  16. 181: struct{}{},
  17. 65552: struct{}{},
  18. 65556: struct{}{},
  19. },
  20. model.PlatIPhone: map[int]struct{}{
  21. 1: struct{}{},
  22. 160: struct{}{},
  23. 119: struct{}{},
  24. 155: struct{}{},
  25. 165: struct{}{},
  26. 5: struct{}{},
  27. 181: struct{}{},
  28. 65552: struct{}{},
  29. 65556: struct{}{},
  30. },
  31. }
  32. )
  33. // auditRegion region data list.
  34. func (s *Service) auditRegion(mobiApp string, plat int8, build, rid int) (isAudit bool) {
  35. if plats, ok := s.auditCache[mobiApp]; ok {
  36. if _, ok = plats[build]; ok {
  37. if rids, ok := _auditRids[plat]; ok {
  38. if _, ok = rids[rid]; ok {
  39. return true
  40. }
  41. }
  42. }
  43. }
  44. return false
  45. }
  46. func (s *Service) auditList(mobiApp string, plat int8, build int) (isAudit bool) {
  47. if plats, ok := s.auditCache[mobiApp]; ok {
  48. if _, ok = plats[build]; ok {
  49. return true
  50. }
  51. }
  52. return false
  53. }
  54. func (s *Service) loadAuditCache() {
  55. as, err := s.adt.Audits(context.TODO())
  56. if err != nil {
  57. log.Error("s.adt.Audits error(%v)", err)
  58. return
  59. }
  60. s.auditCache = as
  61. }