批量优化
This commit is contained in:
1 parent
e3db229f41
commit
aa92ca40a2
79 files changed
+7495
-1104
No files matched your search
@@ -18,17 +18,18 @@ type BackendMenuController struct {
|
||||
type AdminMenuController = BackendMenuController
|
||||
|
||||
type menuPayload struct {
|
||||
Pid *int64 `json:"pid"`
|
||||
Title *string `json:"title"`
|
||||
Path *string `json:"path"`
|
||||
ComponentPath *string `json:"component_path"`
|
||||
Icon *string `json:"icon"`
|
||||
Sort *int64 `json:"sort"`
|
||||
Status *int8 `json:"status"`
|
||||
IsVisible *int8 `json:"is_visible"`
|
||||
Views []int `json:"views"`
|
||||
Type *int8 `json:"type"`
|
||||
Permission *string `json:"permission"`
|
||||
Pid *int64 `json:"pid"`
|
||||
Title *string `json:"title"`
|
||||
Path *string `json:"path"`
|
||||
ComponentPath *string `json:"component_path"`
|
||||
Icon *string `json:"icon"`
|
||||
Sort *int64 `json:"sort"`
|
||||
Status *int8 `json:"status"`
|
||||
IsVisible *int8 `json:"is_visible"`
|
||||
Views []int `json:"views"`
|
||||
Platforms []string `json:"platforms"` // 展示端:["web"] ["app"] ["web","app"];空=继承所属模块
|
||||
Type *int8 `json:"type"`
|
||||
Permission *string `json:"permission"`
|
||||
}
|
||||
|
||||
func parseViews(raw *string) []int {
|
||||
@@ -86,7 +87,10 @@ func (c *BackendMenuController) GetBackendMenu() {
|
||||
_ = c.ServeJSON()
|
||||
return
|
||||
}
|
||||
backendMenus := filterMenusByView(menus, 2)
|
||||
// 先按 views 过滤租户端,再按展示端过滤出 Web 端可见菜单。
|
||||
// 菜单未单独配置 platforms 时继承所属模块,因此要传入全部模块。
|
||||
allModules, _ := services.ListAllModulesForScope()
|
||||
backendMenus := services.FilterMenusByPlatformWithModules(filterMenusByView(menus, 2), allModules, models.PlatformWeb)
|
||||
|
||||
// 按当前登录用户角色过滤可见功能菜单:
|
||||
// 角色 rights 为空(或未分配角色)→ 全权限,返回全部后端菜单;
|
||||
@@ -375,6 +379,7 @@ type menuNode struct {
|
||||
Status int8 `json:"status"`
|
||||
IsVisible *int8 `json:"is_visible,omitempty"`
|
||||
Views []int `json:"views,omitempty"`
|
||||
Platforms []string `json:"platforms,omitempty"` // 展示端,空=继承所属模块
|
||||
Type int8 `json:"type"`
|
||||
Permission string `json:"permission,omitempty"`
|
||||
Locked bool `json:"locked,omitempty"`
|
||||
@@ -393,6 +398,7 @@ func buildMenuTree(menus []models.SystemMenu, pid int64) []*menuNode {
|
||||
Status: m.Status,
|
||||
IsVisible: m.IsVisible,
|
||||
Views: parseViews(m.Views),
|
||||
Platforms: services.ParsePlatforms(m.Platforms),
|
||||
Type: m.Type,
|
||||
}
|
||||
if m.Path != nil {
|
||||
@@ -469,6 +475,8 @@ func (c *BackendMenuController) CreateMenu() {
|
||||
ComponentPath: ptrString(valueString(payload.ComponentPath, "")),
|
||||
Icon: ptrString(valueString(payload.Icon, "")),
|
||||
Permission: ptrString(valueString(payload.Permission, "")),
|
||||
// 空串表示「继承所属模块的展示端」(模块也未配置则全端)
|
||||
Platforms: ptrString(services.NormalizePlatforms(payload.Platforms)),
|
||||
}
|
||||
|
||||
id, err := models.Orm.Insert(&menu)
|
||||
@@ -510,6 +518,7 @@ func (c *BackendMenuController) UpdateMenu() {
|
||||
"status": valueInt8(payload.Status, 1),
|
||||
"is_visible": valueInt8(payload.IsVisible, 1),
|
||||
"views": string(viewsBytes),
|
||||
"platforms": services.NormalizePlatforms(payload.Platforms),
|
||||
"type": valueInt8(payload.Type, 1),
|
||||
"permission": valueString(payload.Permission, ""),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user