Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow

 Conflicts:
	server/cmd/datas/init.go
This commit is contained in:
pixel
2020-11-17 17:41:12 +08:00
22 changed files with 532 additions and 123 deletions
+7 -3
View File
@@ -4,6 +4,7 @@ import (
gormadapter "github.com/casbin/gorm-adapter/v3"
"github.com/gookit/color"
"gorm.io/gorm"
"os"
)
var Carbines = []gormadapter.CasbinRule{
@@ -161,8 +162,8 @@ var Carbines = []gormadapter.CasbinRule{
{PType: "p", V0: "9528", V1: "/autoCode/createTemp", V2: "POST"},
}
func InitCasbinModel(db *gorm.DB) (err error) {
return db.Transaction(func(tx *gorm.DB) error {
func InitCasbinModel(db *gorm.DB) {
if err := db.Transaction(func(tx *gorm.DB) error {
if tx.Where("p_type = ? AND v0 IN ?", "p", []string{"888", "8881", "9528"}).Find(&[]gormadapter.CasbinRule{}).RowsAffected == 142 {
color.Danger.Println("casbin_rule表的初始数据已存在!")
return nil
@@ -171,5 +172,8 @@ func InitCasbinModel(db *gorm.DB) (err error) {
return err
}
return nil
})
}); err != nil {
color.Warn.Printf("[Mysql]--> casbin_rule 表的初始数据失败,err: %v\n", err)
os.Exit(0)
}
}