member_log.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/main/member/model"
  5. "go-common/library/log"
  6. "go-common/library/queue/databus/report"
  7. "go-common/library/time"
  8. )
  9. // consts
  10. const (
  11. MoralLogID = 12
  12. )
  13. // AddMoralLogReport is
  14. func (d *Dao) AddMoralLogReport(ctx context.Context, ul *model.UserLog) {
  15. d.addLogReport(ctx, MoralLogID, "log_moral_change", ul)
  16. }
  17. // addLogReport is
  18. func (d *Dao) addLogReport(ctx context.Context, business int, action string, ul *model.UserLog) {
  19. t := time.Time(ul.TS)
  20. content := make(map[string]interface{}, len(ul.Content))
  21. for k, v := range ul.Content {
  22. content[k] = v
  23. }
  24. if ul.LogID == "" {
  25. ul.LogID = model.UUID4()
  26. }
  27. content["log_id"] = ul.LogID
  28. ui := &report.UserInfo{
  29. Mid: ul.Mid,
  30. Platform: "",
  31. Build: 0,
  32. Buvid: "",
  33. Business: business,
  34. Type: 0,
  35. Oid: 0,
  36. Action: action,
  37. Ctime: t.Time(),
  38. IP: ul.IP,
  39. // extra
  40. Index: []interface{}{ul.LogID},
  41. Content: content,
  42. }
  43. report.User(ui)
  44. log.Info("add log to report: userlog: %+v userinfo: %+v", ul, ui)
  45. }