Migrate the gva project to the cmd folder, delete other redundant database configurations, optimize the initialization method of viper, zap, and gorm
This commit is contained in:
23
server/cmd/datas/authorities.go
Normal file
23
server/cmd/datas/authorities.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package datas
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gin-vue-admin/model"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var Authorities = []model.SysAuthority{
|
||||
{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "888", AuthorityName: "普通用户", ParentId: "0"},
|
||||
{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "8881", AuthorityName: "普通用户子角色", ParentId: "888"},
|
||||
{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "9528", AuthorityName: "测试角色", ParentId: "0"},
|
||||
}
|
||||
|
||||
func InitSysAuthority(db *gorm.DB) (err error) {
|
||||
return db.Transaction(func(tx *gorm.DB) error {
|
||||
if tx.Create(&Authorities).Error != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user