[ADD]初始化用户数据

This commit is contained in:
virus 2019-08-13 23:38:50 +08:00
parent 3f1a325c5d
commit 3e3d9a3d8b
1 changed files with 10 additions and 0 deletions

View File

@ -7,4 +7,14 @@ import (
func init() {
util.DB.AutoMigrate(&User{}, &basic.MetaDatabase{}, &basic.Vendor{}, &basic.Business{})
var count int
if err := util.DB.Model(&User{}).Count(&count).Error; err == nil && count == 0 {
//新增
util.DB.Create(&User{
Username: "admin",
Password: GetSecretPassword("123456"),
Nickname: "管理员",
})
}
}