Skip to content

Commit

Permalink
refactor: remove the has field
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor-Lan committed Dec 2, 2022
1 parent 98f121c commit e54f104
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 18 deletions.
1 change: 0 additions & 1 deletion app/core/cmd/api/desc/sys/menu.api
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type (
ViewPath string `json:"viewPath"`
IsShow int64 `json:"isShow"`
ActiveRouter string `json:"activeRouter"`
Has int64 `json:"has"`
}
SysPermMenuListResp {
List []PermMenu `json:"list"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"ark-admin-zero/app/core/cmd/api/internal/types"
"ark-admin-zero/common/errorx"
"ark-admin-zero/common/globalkey"
"ark-admin-zero/common/utils"

"github.com/jinzhu/copier"
"github.com/zeromicro/go-zero/core/logx"
Expand All @@ -35,31 +34,17 @@ func (l *GetSysPermMenuListLogic) GetSysPermMenuList() (resp *types.SysPermMenuL
return nil, errorx.NewSystemError(errorx.ServerErrorCode, err.Error())
}

currentUserId := utils.GetUserId(l.ctx)
var currentUserPermMenuIds []int64
if currentUserId != globalkey.SysSuperUserId {
currentUserPermMenuIds = l.getCurrentUserPermMenuIds(currentUserId)
}

var menu types.PermMenu
PermMenuList := make([]types.PermMenu, 0)
for _, v := range permMenus {
err := copier.Copy(&menu, &v)
if err != nil {
return nil, errorx.NewSystemError(errorx.ServerErrorCode, err.Error())
}

var perms []string
err = json.Unmarshal([]byte(v.Perms), &perms)
menu.Perms = perms
if currentUserId == globalkey.SysSuperUserId {
menu.Has = 1
} else {
if utils.ArrayContainValue(currentUserPermMenuIds, v.Id) {
menu.Has = 1
} else {
menu.Has = 0
}
}
PermMenuList = append(PermMenuList, menu)
}

Expand Down
1 change: 0 additions & 1 deletion app/core/cmd/api/internal/types/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e54f104

Please sign in to comment.