generate model and update model

This commit is contained in:
landaiqing
2024-09-10 23:29:41 +08:00
parent 5c30db51f1
commit cd1ce8f578
8 changed files with 76 additions and 8 deletions

View File

@@ -43,7 +43,7 @@ func (permission *ScaAuthPermission) UnmarshalBinary(data []byte) error {
return json.Unmarshal(data, permission)
}
func (permission *ScaAuthPermission) BeforeCreate(tx *gorm.DB) (err error) {
userId, b := global.DB.Get("user_id")
userId, b := tx.Get("user_id")
if !b {
global.LOG.Error("user_id is not in global.DB")
return fmt.Errorf("user_id is not in global.DB")
@@ -60,7 +60,7 @@ func (permission *ScaAuthPermission) BeforeCreate(tx *gorm.DB) (err error) {
}
func (permission *ScaAuthPermission) BeforeUpdate(tx *gorm.DB) (err error) {
userId, b := global.DB.Get("user_id")
userId, b := tx.Get("user_id")
if !b {
global.LOG.Error("user_id is not in global.DB")
return fmt.Errorf("user_id is not in global.DB")