fix platform workflow integrity and permissions
This commit is contained in:
@@ -53,10 +53,10 @@ var PlatformMenus = [][]Menu{
|
||||
{Identity: "product_info", ParentIdentity: "device", MenuCode: "device", Name: "产品信息", Path: "/product/product-info", SortNo: 3, Status: common.StatusEnable},
|
||||
},
|
||||
{
|
||||
{Identity: "gasorder", MenuCode: "delivery", Name: "气体配送订单管理", Icon: "icon-list", Path: "/gasorder", SortNo: 70, Status: common.StatusEnable},
|
||||
{Identity: "gasorder_contract", ParentIdentity: "gasorder", MenuCode: "delivery", Name: "合同管理", Path: "/gasorder/contracts", SortNo: 1, Status: common.StatusEnable},
|
||||
{Identity: "gasorder_basic", ParentIdentity: "gasorder", MenuCode: "delivery", Name: "配送订单", Path: "/gasorder/orders", SortNo: 2, Status: common.StatusEnable},
|
||||
{Identity: "gasorder_track", ParentIdentity: "gasorder", MenuCode: "delivery", Name: "运行轨迹", Path: "/gasorder/tracks", SortNo: 3, Status: common.StatusEnable},
|
||||
{Identity: "gasorder", MenuCode: "gasorder", Name: "气体配送订单管理", Icon: "icon-list", Path: "/gasorder", SortNo: 70, Status: common.StatusEnable},
|
||||
{Identity: "gasorder_contract", ParentIdentity: "gasorder", MenuCode: "gasorder_contract", Name: "合同管理", Path: "/gasorder/contracts", SortNo: 1, Status: common.StatusEnable},
|
||||
{Identity: "gasorder_basic", ParentIdentity: "gasorder", MenuCode: "gasorder_basic", Name: "配送订单", Path: "/gasorder/orders", SortNo: 2, Status: common.StatusEnable},
|
||||
{Identity: "gasorder_track", ParentIdentity: "gasorder", MenuCode: "gasorder_track", Name: "运行轨迹", Path: "/gasorder/tracks", SortNo: 3, Status: common.StatusEnable},
|
||||
},
|
||||
{
|
||||
{Identity: "ec", MenuCode: "ec", Name: "商城管理", Icon: "icon-gift", Path: "/ec", SortNo: 80, Status: common.StatusEnable},
|
||||
@@ -127,19 +127,24 @@ func LoadPlatformMenus(roleCode string) ([]Menu, error) {
|
||||
if err := impl.DBService.Where("role_code = ? AND status = ?", roleCode, common.StatusEnable).First(&role).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var codes []string
|
||||
var identities []string
|
||||
if err := impl.DBService.Model(&models.PlatformRoleMenu{}).
|
||||
Where("platform_role_id = ?", role.ID).
|
||||
Pluck("menu_code", &codes).Error; err != nil {
|
||||
Pluck("menu_identity", &identities).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
allowed := make(map[string]struct{}, len(codes))
|
||||
for _, code := range codes {
|
||||
allowed[code] = struct{}{}
|
||||
allowed := make(map[string]struct{}, len(identities))
|
||||
for _, identity := range identities {
|
||||
allowed[identity] = struct{}{}
|
||||
}
|
||||
for _, menu := range menus {
|
||||
if _, ok := allowed[menu.Identity]; ok && menu.ParentIdentity != "" {
|
||||
allowed[menu.ParentIdentity] = struct{}{}
|
||||
}
|
||||
}
|
||||
filtered := make([]Menu, 0, len(menus))
|
||||
for _, menu := range menus {
|
||||
if _, ok := allowed[menu.MenuCode]; ok {
|
||||
if _, ok := allowed[menu.Identity]; ok {
|
||||
filtered = append(filtered, menu)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user