feat:优化信息
This commit is contained in:
@ -1,19 +1,29 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"ArmedPolice/app/controller/menu"
|
||||
model2 "ArmedPolice/app/common/model"
|
||||
"ArmedPolice/app/controller/basic"
|
||||
"ArmedPolice/app/model"
|
||||
"ArmedPolice/app/service"
|
||||
"ArmedPolice/utils"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Menu struct{ *service.Session }
|
||||
|
||||
type MenuHandle func(session *service.Session) *Menu
|
||||
|
||||
type MenuInfo struct {
|
||||
basic.CommonIDString
|
||||
*model2.SysMenuBasic
|
||||
ParentID string `json:"parent_id"`
|
||||
// 与前端约定
|
||||
Meta struct {
|
||||
Title string `json:"title"`
|
||||
} `json:"meta"`
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
// Menu 用户菜单信息
|
||||
func (c *Menu) Menu() ([]*menu.InstanceIdentityInfo, error) {
|
||||
func (c *Menu) Menu() ([]*MenuInfo, error) {
|
||||
mSysMenu := model.NewSysMenu()
|
||||
|
||||
out := make([]*model.SysMenuScene, 0)
|
||||
@ -28,9 +38,25 @@ func (c *Menu) Menu() ([]*menu.InstanceIdentityInfo, error) {
|
||||
if out, err = mSysMenu.UserMenu(c.UID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fmt.Println(utils.AnyToJSON(out))
|
||||
RETURN:
|
||||
return menu.TreeIdentity(mSysMenu.SysMenu, out, 0), nil
|
||||
list := make([]*MenuInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
mSysMenu.SetID(v.ID)
|
||||
data := &MenuInfo{
|
||||
CommonIDString: basic.CommonIDString{ID: mSysMenu.GetEncodeID()},
|
||||
SysMenuBasic: v.SysMenuBasic,
|
||||
ParentID: (&model2.Model{ID: v.ParentID}).GetEncodeID(),
|
||||
Meta: struct {
|
||||
Title string `json:"title"`
|
||||
}{Title: v.Name},
|
||||
}
|
||||
data.Name = v.Link
|
||||
data.Path = v.Link
|
||||
list = append(list, data)
|
||||
}
|
||||
return list, nil
|
||||
//return menu.TreeIdentity(mSysMenu.SysMenu, out, 0), nil
|
||||
}
|
||||
|
||||
func NewMenu() MenuHandle {
|
||||
|
Reference in New Issue
Block a user