audit_log.go 799 B

123456789101112131415161718192021222324252627282930313233
  1. package service
  2. import (
  3. "context"
  4. "time"
  5. "go-common/library/log"
  6. manager "go-common/library/queue/databus/report"
  7. )
  8. // AddAuditLog .
  9. func (s *Service) AddAuditLog(c context.Context, bizID int, tp int8, action string, uid int64, uname string, oids []int64, index []interface{}, content map[string]interface{}) error {
  10. var err error
  11. for _, oid := range oids {
  12. managerInfo := &manager.ManagerInfo{
  13. UID: uid,
  14. Uname: uname,
  15. Business: bizID,
  16. Type: int(tp),
  17. Action: action,
  18. Oid: oid,
  19. Ctime: time.Now(),
  20. Index: index,
  21. Content: content,
  22. }
  23. if err = manager.Manager(managerInfo); err != nil {
  24. log.Error("manager.Manager(%+v) error(%+v)", managerInfo, err)
  25. continue
  26. }
  27. log.Info("s.managerSendLog(%+v)", managerInfo)
  28. }
  29. return err
  30. }