add gva error message

This commit is contained in:
SliverHorn
2020-10-26 15:55:55 +08:00
parent a7bb4a7ac4
commit f7804b627e
13 changed files with 79 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
package datas
import (
"github.com/gookit/color"
"gorm.io/gorm"
)
@@ -19,6 +20,10 @@ var DataAuthorityId = []SysDataAuthorityId{
func InitSysDataAuthorityId(db *gorm.DB) (err error) {
return db.Table("sys_data_authority_id").Transaction(func(tx *gorm.DB) error {
if tx.Where("sys_authority_authority_id IN ?", []string{"888", "9528"}).Find(&[]SysDataAuthorityId{}).RowsAffected == 5 {
color.Danger.Println("sys_data_authority_id表的初始数据已存在!")
return nil
}
if tx.Create(&DataAuthorityId).Error != nil { // 遇到错误时回滚事务
return err
}