com_handler_user_logs.go 475 B

12345678910111213141516171819202122
  1. package services
  2. import (
  3. "app/commons/model/entity"
  4. "fmt"
  5. "gorm.io/gorm"
  6. )
  7. func (s *CommonService) CreateUserRelationActionLog(txDb *gorm.DB, user *entity.User, opName string, source, target interface{}) error {
  8. setLog := entity.UserRelationActionLog{
  9. UserId: user.Id,
  10. Uid: user.Uid,
  11. Source: fmt.Sprintf("%v", source),
  12. Target: fmt.Sprintf("%v", target),
  13. Action: opName,
  14. }
  15. err := txDb.Create(&setLog).Error
  16. if err != nil {
  17. return err
  18. }
  19. return nil
  20. }