| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- package dto
- import (
- "IotAdmin/app/system/models"
- "IotAdmin/common/dto"
- common "IotAdmin/common/models"
- "IotAdmin/core/tools/utils"
- )
- // SysMenuGetPageReq 列表或者搜索使用结构体
- type SysMenuGetPageReq struct {
- dto.Pagination `search:"-"`
- Title string `form:"title" search:"type:contains;column:title;table:sys_menu" comment:"菜单名称"` // 菜单名称
- IsHide int `form:"isHide" search:"type:exact;column:idHide;table:sys_menu" comment:"显示状态"` // 显示状态
- }
- func (m *SysMenuGetPageReq) GetNeedSearch() interface{} {
- return *m
- }
- type SysMenuInsertReq struct {
- MenuId int `uri:"id" comment:"编码"` // 编码
- Path string `form:"path" comment:"菜单path"` //菜单name
- MenuName string `form:"menuName" comment:"显示名称"` //显示名称
- Icon string `form:"icon" comment:"图标"` //图标
- //Path string `form:"path" comment:"路径"` //路径
- Paths string `form:"paths" comment:"id路径"` //id路径
- MenuType string `form:"menuType" comment:"菜单类型"` //菜单类型
- SysApi []models.SysApi `form:"sysApi"`
- Apis []int `form:"apis"`
- Action string `form:"action" comment:"请求方式"` //请求方式
- Permission string `form:"permission" comment:"权限编码"` //权限编码
- ParentId int `form:"parentId" comment:"上级菜单"` //上级菜单
- //Breadcrumb string `form:"breadcrumb" comment:"是否面包屑"` //是否面包屑
- Component string `form:"component" comment:"组件"` //组件
- BtnClass string `form:"btnClass" comment:"按钮样式"` //按钮样式
- BtnScript string `form:"btnScript" comment:"按钮脚本"` //按钮脚本
- Sort int `form:"sort" comment:"排序"` //排序
- NoCache string `form:"noCache" comment:"是否缓存"` //是否缓存
- IsHide string `form:"isHide" comment:"是否显示"` //是否显示
- IsFrame string `form:"isFrame" comment:"是否frame"` //是否frame
- common.ControlBy
- }
- func (s *SysMenuInsertReq) Generate(model *models.SysMenu) {
- if s.MenuId != 0 {
- model.MenuId = s.MenuId
- }
- model.MenuName = s.MenuName
- model.Path = s.Path
- model.Icon = s.Icon
- model.Paths = s.Paths
- model.MenuType = s.MenuType
- model.Action = s.Action
- model.SysApi = s.SysApi
- model.Permission = s.Permission
- model.ParentId = s.ParentId
- model.NoCache = s.NoCache == "1"
- //model.Breadcrumb = s.Breadcrumb
- model.Component = s.Component
- model.BtnClass = s.BtnClass
- model.BtnScript = s.BtnScript
- model.Sort = s.Sort
- model.IsHide = s.IsHide == "1"
- model.IsFrame = s.IsFrame == "1"
- if s.CreateBy != 0 {
- model.CreateBy = s.CreateBy
- }
- if s.UpdateBy != 0 {
- model.UpdateBy = s.UpdateBy
- }
- }
- func (s *SysMenuInsertReq) GetId() interface{} {
- return s.MenuId
- }
- type SysMenuUpdateReq struct {
- MenuId int `uri:"id" comment:"编码"` // 编码
- Path string `form:"path" comment:"菜单path"` //菜单Path
- MenuName string `form:"title" comment:"显示名称"` //显示名称
- Icon string `form:"icon" comment:"图标"` //图标
- Paths string `form:"paths" comment:"id路径"` //id路径
- MenuType string `form:"menuType" comment:"菜单类型"` //菜单类型
- SysApi []models.SysApi `form:"sysApi"`
- Apis []int `form:"apis"`
- Action string `form:"action" comment:"请求方式"` //请求方式
- Permission string `form:"permission" comment:"权限编码"` //权限编码
- ParentId int `form:"parentId" comment:"上级菜单"` //上级菜单
- //Breadcrumb string `form:"breadcrumb" comment:"是否面包屑"` //是否面包屑
- Component string `form:"component" comment:"组件"` //组件
- BtnClass string `form:"btnClass" comment:"按钮样式"` //按钮样式
- BtnScript string `form:"btnScript" comment:"按钮脚本"` //按钮脚本
- Sort int `form:"sort" comment:"排序"` //排序
- NoCache string `form:"noCache" comment:"是否缓存"` //是否缓存
- IsHide string `form:"isHide" comment:"是否显示"` //是否显示
- IsFrame string `form:"isFrame" comment:"是否frame"` //是否frame
- common.ControlBy
- }
- func (s *SysMenuUpdateReq) Generate(model *models.SysMenu) {
- if s.MenuId != 0 {
- model.MenuId = s.MenuId
- }
- model.Path = s.Path
- model.MenuName = s.MenuName
- model.Icon = s.Icon
- model.Paths = s.Paths
- model.MenuType = s.MenuType
- model.Action = s.Action
- model.SysApi = s.SysApi
- model.Permission = s.Permission
- model.ParentId = s.ParentId
- model.NoCache = s.NoCache == "1"
- //model.Breadcrumb = s.Breadcrumb
- model.Component = s.Component
- model.BtnClass = s.BtnClass
- model.BtnScript = s.BtnScript
- model.Sort = s.Sort
- model.IsHide = s.IsHide == "1"
- model.IsFrame = s.IsFrame == "1"
- if s.CreateBy != 0 {
- model.CreateBy = s.CreateBy
- }
- if s.UpdateBy != 0 {
- model.UpdateBy = s.UpdateBy
- }
- }
- func (s *SysMenuUpdateReq) GetId() interface{} {
- return s.MenuId
- }
- type SysMenuGetReq struct {
- Id int `uri:"id"`
- }
- func (s *SysMenuGetReq) GetId() interface{} {
- return s.Id
- }
- type SysMenuDeleteReq struct {
- Ids []int `json:"ids"`
- common.ControlBy
- }
- func (s *SysMenuDeleteReq) GetId() interface{} {
- return s.Ids
- }
- const (
- LAYOUT = "Layout"
- PARENT_VIEW = "ParentView"
- INNER_LINK = "InnerLink"
- )
- type SysRouterVo struct {
- Name string `json:"name"` // 路由名称
- Path string `json:"path"` // 路由地址
- Hidden bool `json:"hidden"` // 是否隐藏
- Redirect string `json:"redirect"` // 重定向地址,当设置noRedirect的时候该路由在面包屑导航中不可被点击
- Component string `json:"component"` // 组件
- Query string `json:"query"` // 路由query参数
- AlwaysShow bool `json:"alwaysShow"` // children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
- Meta SysRouterMetaVo `json:"meta"`
- Children []SysRouterVo `json:"children"` // 子路由
- }
- type SysRouterMetaVo struct {
- Title string `json:"title"`
- Icon string `json:"icon"`
- Link string `json:"link"`
- NoCache bool `json:"noCache"` //设置为true,则不会被 <keep-alive>缓存
- }
- func (m *SysRouterVo) Generate(model *models.SysMenu) {
- m.Name = utils.FirstUpper(model.Path)
- m.Path = model.Path
- m.Hidden = model.IsHide
- m.Redirect = "noRedirect"
- m.Component = model.Component
- m.AlwaysShow = true
- m.Query = ""
- m.Meta = SysRouterMetaVo{
- Title: model.MenuName,
- Icon: model.Icon,
- NoCache: model.NoCache,
- }
- m.Children = []SysRouterVo{}
- }
- type MenuLabel struct {
- Id int `json:"id,omitempty" gorm:"-"`
- Label string `json:"label,omitempty" gorm:"-"`
- Children []MenuLabel `json:"children,omitempty" gorm:"-"`
- }
- type MenuRole struct {
- models.SysMenu
- IsSelect bool `json:"is_select" gorm:"-"`
- }
- type SelectRole struct {
- RoleId int `uri:"roleId"`
- }
- type SelectMenuBtnChildren struct {
- Permission string `uri:"permission"`
- }
|