feat:完善项目信息

This commit is contained in:
henry
2022-01-07 16:12:43 +08:00
parent 657fdc5750
commit 2bf3c01702
21 changed files with 379 additions and 129 deletions

View File

@ -6,8 +6,6 @@ import (
model2 "SciencesServer/app/common/model"
"SciencesServer/app/session"
"SciencesServer/serve/orm"
"errors"
"gorm.io/gorm"
)
@ -24,16 +22,7 @@ func (c *Menu) Index(roleID uint64) ([]*menu2.TreeChecked, error) {
// Bind 绑定菜单
func (c *Menu) Bind(roleID uint64, menuIDs []uint64) error {
if len(menuIDs) > 0 {
var count int64
mSysMenu := model.NewSysMenu()
if err := model2.Count(mSysMenu.SysMenu, &count, model2.NewWhereIn("id", menuIDs),
model2.NewWhere("auth", model2.SysMenuAuthForSystem)); err != nil {
return err
} else if count > 0 {
return errors.New("不可设置超管菜单")
}
}
mSysRoleMenu := model.NewSysRoleMenu()
@ -54,9 +43,7 @@ func (c *Menu) Bind(roleID uint64, menuIDs []uint64) error {
if _, has := mark[v]; has {
continue
}
menus = append(menus, &model2.SysRoleMenu{
ModelTenant: model2.ModelTenant{TenantID: c.TenantID}, RoleID: roleID, MenuID: v,
})
menus = append(menus, &model2.SysRoleMenu{RoleID: roleID, MenuID: v})
mark[v] = v
}
if err = model2.Creates(mSysRoleMenu.SysRoleMenu, menus, tx); err != nil {