log.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package service
  2. import (
  3. "context"
  4. "strconv"
  5. "time"
  6. "go-common/app/admin/main/videoup-task/model"
  7. "go-common/library/log"
  8. "go-common/library/queue/databus/report"
  9. )
  10. // send to log service
  11. func (s *Service) sendVideoLog(c context.Context, vp *model.VideoParam, others string) (err error) {
  12. var (
  13. v *model.ArcVideo
  14. a *model.Archive
  15. )
  16. if vp.Cid != 0 {
  17. v, err = s.dao.ArcVideoByCID(c, vp.Cid)
  18. } else if vp.ID != 0 {
  19. v, err = s.dao.NewVideoByID(c, vp.ID)
  20. }
  21. if err != nil || v == nil {
  22. v = &model.ArcVideo{} // ignore err
  23. }
  24. a, err = s.dao.Archive(c, vp.Aid)
  25. if err != nil || a == nil {
  26. a = &model.Archive{} // ignore err
  27. }
  28. // send
  29. logData := &report.ManagerInfo{
  30. Uname: vp.Oname,
  31. UID: vp.UID,
  32. Business: model.LogClientVideo,
  33. Type: model.LogClientTypeVideo,
  34. Oid: vp.Cid,
  35. Action: strconv.Itoa(int(vp.Status)),
  36. Ctime: time.Now(),
  37. Index: []interface{}{int64(vp.Attribute), v.CTime.Unix(), vp.TagID, a.Title, vp.Note},
  38. Content: map[string]interface{}{
  39. "content": vp,
  40. "others": others,
  41. },
  42. }
  43. report.Manager(logData)
  44. return
  45. }
  46. // sendConsumerLog send consumer log
  47. func (s *Service) sendConsumerLog(c context.Context, cl *model.ConsumerLog) (err error) {
  48. logData := &report.ManagerInfo{
  49. Uname: cl.Uname,
  50. UID: cl.UID,
  51. Business: model.LogClientConsumer,
  52. Type: model.LogClientTypeConsumer,
  53. Oid: cl.UID,
  54. Action: strconv.Itoa(int(cl.Action)),
  55. Ctime: time.Now(),
  56. Index: []interface{}{cl.UID, cl.Action, cl.Ctime},
  57. Content: map[string]interface{}{
  58. "content": cl,
  59. },
  60. }
  61. report.Manager(logData)
  62. log.Info("sendConsumerLog logData(%+v)", cl)
  63. return
  64. }