| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- // ==========================================================================
- // This is auto-generated by gf cli tool. Fill this file as you wish.
- // ==========================================================================
- package model
- import (
- "dashoo.cn/micro/app/model/internal"
- "dashoo.cn/opms_libary/utils"
- "strings"
- )
- // SysMenu is the golang structure for table sys_menu.
- type SysMenu internal.SysMenu
- // Fill with you ideas below.
- // SysMenuReq 新增页面请求参数
- type SysMenuReq struct {
- Id int `json:"id"` // ID
- ParentId int `json:"parentId"` // 父菜单ID
- MenuName string `json:"menuName" v:"required#菜单名称不能为空"` // 菜单名称
- Name string `json:"name"` // 路由名称
- Path string `json:"path"` // 路由地址
- Component string `json:"component"` // 组件路径
- Query string `json:"query"` // 路由参数
- IsFrame int `json:"isFrame"` // 是否为外链(10是20否)
- IsCache int `json:"isCache"` // 是否缓存(10缓存20不缓存)
- MenuType string `json:"menuType" v:"required#菜单类型不能为空"` // 菜单类型(M目录C菜单 F按钮)
- Visible string `json:"visible"` // 显示状态(10显示20隐藏)
- Status string `json:"status"` // 菜单状态(10正常20停用)
- Perms string `json:"perms"` // 权限标识
- Icon string `json:"icon"` // 菜单图标
- PlatformId int `json:"platformId"` // 所属平台
- Sort int `json:"sort"` // 显示顺序
- ActiveMenu string `json:"activeMenu"` // 高亮路由
- Remark string `json:"remark"` // 备注
- }
- type MenuTree struct {
- Id int `json:"id"`
- ParentId int `json:"parent_id"`
- Name string `json:"name"`
- Path string `json:"path"`
- Component string `json:"component"`
- Meta Meta `json:"meta"`
- Children []MenuTree `json:"children,omitempty"`
- }
- type Meta struct {
- Title string `json:"title"`
- Icon string `json:"icon"`
- BreadcrumbHidden bool `json:"breadcrumbHidden,omitempty"`
- NoKeepAlive bool `json:"noKeepAlive,omitempty"`
- Hidden bool `json:"hidden,omitempty"`
- ActiveMenu string `json:"activeMenu,omitempty"`
- Target string `json:"target,omitempty"`
- NoColumn bool `json:"noColumn,omitempty"`
- }
- func (m SysMenu) ConvName() string {
- if m.Name != "" {
- return m.Name
- }
- name := m.Path
- if strings.Contains(m.Path, "/") {
- nameList := strings.Split(m.Path, "/")
- for _, v := range nameList {
- if v != "" {
- name = v
- break
- }
- }
- }
- return utils.FirstUpper(name)
- }
- func (m SysMenu) ConvMenuTree() MenuTree {
- menuTree := MenuTree{
- Id: m.Id,
- ParentId: m.ParentId,
- Name: m.ConvName(),
- Path: m.Path,
- Component: m.Component,
- Meta: Meta{
- Title: m.MenuName,
- Icon: m.Icon,
- //BreadcrumbHidden: m.BreadcrumbHidden,
- ActiveMenu: m.ActiveMenu,
- NoKeepAlive: m.IsCache != 1,
- Hidden: m.Visible != "10",
- NoColumn: m.NoColumn == "20",
- },
- Children: nil,
- }
- if m.IsFrame == 1 {
- menuTree.Meta.Target = "_blank"
- }
- return menuTree
- }
|