tool.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package ugc
  2. import (
  3. appDao "go-common/app/job/main/tv/dao/app"
  4. arccli "go-common/app/service/main/archive/api"
  5. "go-common/library/log"
  6. )
  7. // call ArcRPC for types data
  8. func (s *Service) loadTypes() {
  9. var (
  10. resp *arccli.TypesReply
  11. err error
  12. )
  13. if resp, err = s.arcClient.Types(ctx, &arccli.NoArgRequest{}); err != nil {
  14. log.Error("arcRPC loadType Error %v", err)
  15. return
  16. }
  17. s.arcTypes = resp.Types
  18. }
  19. func (s *Service) hitPGC(tid int32) (hit bool) {
  20. _, hit = s.pgcTypes[s.getPTypeName(tid)]
  21. return
  22. }
  23. func (s *Service) delPGC(tid int32, aid int64) (hit bool, err error) {
  24. if hit = s.hitPGC(tid); !hit { // if not hit, do nothing
  25. appDao.PromInfo("HitPGC:FdSucc")
  26. return
  27. }
  28. log.Info("delPGC Aid %d, Tid %d", aid, tid)
  29. appDao.PromInfo("HitPGC:DelSucc")
  30. if err = s.delArc(aid); err != nil { // if hit, delete it if exist
  31. appDao.PromInfo("HitPGC:DelErr")
  32. log.Error("HitPGC DelArc %d, Err %v", aid, err)
  33. }
  34. return
  35. }
  36. func pickKeys(q map[int64]int) (res []int64) {
  37. for k := range q {
  38. res = append(res, k)
  39. }
  40. return
  41. }