修改方法

This commit is contained in:
fancl 2024-12-12 17:02:01 +08:00
parent 61ffcec858
commit 4fd3d58ea0
2 changed files with 3 additions and 3 deletions

View File

@ -15,7 +15,7 @@ func (identity *Identify) Name() string {
}
func (identity *Identify) Initialize(db *gorm.DB) (err error) {
err = db.Callback().Create().Before("gorm:create").Register("auto_identified", identity.Grant)
err = db.Callback().Create().Before("gorm:create").Register("rest_auto_identified", identity.Grant)
return
}

View File

@ -121,10 +121,10 @@ func (validate *Validate) findRule(name string, rules []*validateRule) *validate
func (validate *Validate) Initialize(db *gorm.DB) (err error) {
validate.validator = validator.New()
if err = db.Callback().Create().Before("gorm:before_create").Register("model_validate", validate.Validate); err != nil {
if err = db.Callback().Create().Before("gorm:before_create").Register("rest_validate_create", validate.Validate); err != nil {
return
}
if err = db.Callback().Create().Before("gorm:before_update").Register("model_validate", validate.Validate); err != nil {
if err = db.Callback().Create().Before("gorm:before_update").Register("rest_validate_update", validate.Validate); err != nil {
return
}
if err = validate.validator.RegisterValidationCtx("telephone", validate.telephoneValidate); err != nil {