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"
"time"
"gin-vue-admin/model"
@@ -36,6 +37,10 @@ func InitSysDictionaryDetail(db *gorm.DB) (err error) {
{gorm.Model{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "tinyint", 0, status, 0, 6},
}
return db.Transaction(func(tx *gorm.DB) error {
if tx.Where("id IN ?", []int{1, 23}).Find(&[]model.SysDictionaryDetail{}).RowsAffected == 2 {
color.Danger.Println("sys_dictionary_details表的初始数据已存在!")
return nil
}
if tx.Create(&DictionaryDetail).Error != nil { // 遇到错误时回滚事务
return err
}