修改方法
This commit is contained in:
parent
61ffcec858
commit
4fd3d58ea0
|
@ -15,7 +15,7 @@ func (identity *Identify) Name() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (identity *Identify) Initialize(db *gorm.DB) (err error) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,10 +121,10 @@ func (validate *Validate) findRule(name string, rules []*validateRule) *validate
|
||||||
|
|
||||||
func (validate *Validate) Initialize(db *gorm.DB) (err error) {
|
func (validate *Validate) Initialize(db *gorm.DB) (err error) {
|
||||||
validate.validator = validator.New()
|
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
|
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
|
return
|
||||||
}
|
}
|
||||||
if err = validate.validator.RegisterValidationCtx("telephone", validate.telephoneValidate); err != nil {
|
if err = validate.validator.RegisterValidationCtx("telephone", validate.telephoneValidate); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue