package services import ( "app/commons/model/entity" "fmt" "gorm.io/gorm" ) func (s *CommonService) CreateUserRelationActionLog(txDb *gorm.DB, user *entity.User, opName string, source, target interface{}) error { setLog := entity.UserRelationActionLog{ UserId: user.Id, Uid: user.Uid, Source: fmt.Sprintf("%v", source), Target: fmt.Sprintf("%v", target), Action: opName, } err := txDb.Create(&setLog).Error if err != nil { return err } return nil }