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"
@@ -13,6 +14,10 @@ var Customers = []model.ExaCustomer{
func InitExaCustomer(db *gorm.DB) (err error) {
return db.Transaction(func(tx *gorm.DB) error {
if tx.Where("id IN ? ", []int{1}).Find(&[]model.ExaCustomer{}).RowsAffected == 1 {
color.Danger.Println("exa_customers表的初始数据已存在!")
return nil
}
if tx.Create(&Customers).Error != nil { // 遇到错误时回滚事务
return err
}