调整角色ID为uint格式,增加embed打包,更改日志格式。 (#1144)
* feature: 根据 #377 pr进行修改embed, 打包静态文件夹与配置文件 * 修改角色id为uint * 修改日志格式 Co-authored-by: SliverHorn <503551462@qq.com> Co-authored-by: cg81344 <cg831344@126.com>
This commit is contained in:
@@ -43,9 +43,9 @@ func (i *initAuthority) InitializeData(ctx context.Context) (context.Context, er
|
||||
return ctx, system.ErrMissingDBContext
|
||||
}
|
||||
entities := []sysModel.SysAuthority{
|
||||
{AuthorityId: "888", AuthorityName: "普通用户", ParentId: "0", DefaultRouter: "dashboard"},
|
||||
{AuthorityId: "9528", AuthorityName: "测试角色", ParentId: "0", DefaultRouter: "dashboard"},
|
||||
{AuthorityId: "8881", AuthorityName: "普通用户子角色", ParentId: "888", DefaultRouter: "dashboard"},
|
||||
{AuthorityId: 888, AuthorityName: "普通用户", ParentId: 0, DefaultRouter: "dashboard"},
|
||||
{AuthorityId: 9528, AuthorityName: "测试角色", ParentId: 0, DefaultRouter: "dashboard"},
|
||||
{AuthorityId: 8881, AuthorityName: "普通用户子角色", ParentId: 888, DefaultRouter: "dashboard"},
|
||||
}
|
||||
|
||||
if err := db.Create(&entities).Error; err != nil {
|
||||
@@ -54,17 +54,17 @@ func (i *initAuthority) InitializeData(ctx context.Context) (context.Context, er
|
||||
// data authority
|
||||
if err := db.Model(&entities[0]).Association("DataAuthorityId").Replace(
|
||||
[]*sysModel.SysAuthority{
|
||||
{AuthorityId: "888"},
|
||||
{AuthorityId: "9528"},
|
||||
{AuthorityId: "8881"},
|
||||
{AuthorityId: 888},
|
||||
{AuthorityId: 9528},
|
||||
{AuthorityId: 8881},
|
||||
}); err != nil {
|
||||
return ctx, errors.Wrapf(err, "%s表数据初始化失败!",
|
||||
db.Model(&entities[0]).Association("DataAuthorityId").Relationship.JoinTable.Name)
|
||||
}
|
||||
if err := db.Model(&entities[1]).Association("DataAuthorityId").Replace(
|
||||
[]*sysModel.SysAuthority{
|
||||
{AuthorityId: "9528"},
|
||||
{AuthorityId: "8881"},
|
||||
{AuthorityId: 9528},
|
||||
{AuthorityId: 8881},
|
||||
}); err != nil {
|
||||
return ctx, errors.Wrapf(err, "%s表数据初始化失败!",
|
||||
db.Model(&entities[1]).Association("DataAuthorityId").Relationship.JoinTable.Name)
|
||||
|
@@ -54,7 +54,7 @@ func (i *initUser) InitializeData(ctx context.Context) (next context.Context, er
|
||||
Password: adminPassword,
|
||||
NickName: "超级管理员",
|
||||
HeaderImg: "https://qmplusimg.henrongyi.top/gva_header.jpg",
|
||||
AuthorityId: "888",
|
||||
AuthorityId: 888,
|
||||
Phone: "17611111111",
|
||||
Email: "333333333@qq.com",
|
||||
},
|
||||
@@ -64,7 +64,7 @@ func (i *initUser) InitializeData(ctx context.Context) (next context.Context, er
|
||||
Password: password,
|
||||
NickName: "QMPlusUser",
|
||||
HeaderImg: "https:///qmplusimg.henrongyi.top/1572075907logo.png",
|
||||
AuthorityId: "9528",
|
||||
AuthorityId: 9528,
|
||||
Phone: "17611111111",
|
||||
Email: "333333333@qq.com"},
|
||||
}
|
||||
@@ -95,5 +95,5 @@ func (i *initUser) DataInserted(ctx context.Context) bool {
|
||||
Preload("Authorities").First(&record).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据
|
||||
return false
|
||||
}
|
||||
return len(record.Authorities) > 0 && record.Authorities[0].AuthorityId == "888"
|
||||
return len(record.Authorities) > 0 && record.Authorities[0].AuthorityId == 888
|
||||
}
|
||||
|
Reference in New Issue
Block a user