新增菜单结构体字段,新增了两个
This commit is contained in:
parent
e09d1f051b
commit
db36b2f32b
@ -4,4 +4,5 @@ package controller
|
||||
type Api struct {
|
||||
Basic // 基础数据
|
||||
Role // 角色数据
|
||||
Menu // 菜单数据
|
||||
}
|
||||
|
||||
14
api/controller/menu.go
Normal file
14
api/controller/menu.go
Normal file
@ -0,0 +1,14 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-admin-api/api/responses"
|
||||
)
|
||||
|
||||
type Menu struct{}
|
||||
|
||||
// GetMenuList 获取菜单列表
|
||||
func (r *Menu) GetMenuList(c *gin.Context) {
|
||||
responses.Ok(c)
|
||||
return
|
||||
}
|
||||
@ -5,6 +5,7 @@ type AdminMenu struct {
|
||||
Model
|
||||
MenuId int64 `gorm:"column:menu_id;type:bigint(19);primary_key;comment:主键id" json:"menu_id"`
|
||||
MenuName string `gorm:"column:menu_name;type:varchar(30);comment:菜单名称" json:"menu_name"`
|
||||
MenuTitle string `gorm:"column:title;menu_title:varchar(30);comment:菜单名称" json:"menu_title"`
|
||||
ParentId int64 `gorm:"column:parent_id;type:int(10);default:0;comment:父菜单ID(0表示一级)" json:"parent_id"`
|
||||
MenuStatus int `gorm:"column:menu_status;type:tinyint(1);default:1;comment:菜单状态(0:隐藏 1:正常)此优先级最高" json:"menu_status"`
|
||||
MenuType int `gorm:"column:menu_type;type:tinyint(1);comment:菜单类型(1:模块 2:菜单 3:按钮)" json:"menu_type"`
|
||||
@ -12,6 +13,7 @@ type AdminMenu struct {
|
||||
OrderNum int `gorm:"column:order_num;type:int(4);default:0;comment:显示顺序" json:"order_num"`
|
||||
Icon string `gorm:"column:icon;type:varchar(255);comment:图标地址" json:"icon"`
|
||||
Path string `gorm:"column:path;type:varchar(255);comment:页面地址(#表示当前页)" json:"path"`
|
||||
Component string `gorm:"column:component;type:varchar(255);comment:组件名称" json:"component"`
|
||||
}
|
||||
|
||||
func (m *AdminMenu) TableName() string {
|
||||
|
||||
15
api/responses/menuResponse/menuResponse.go
Normal file
15
api/responses/menuResponse/menuResponse.go
Normal file
@ -0,0 +1,15 @@
|
||||
package menuResponse
|
||||
|
||||
// GetMenuList 角色详情
|
||||
type GetMenuList struct {
|
||||
MenuId int64 `json:"menu_id"`
|
||||
MenuName string `json:"menu_name"` // 菜单名称
|
||||
MenuTitle string `json:"menu_title"` // 菜单名称
|
||||
ParentId int64 `json:"parent_id"` // 父菜单ID(0表示一级)
|
||||
MenuStatus int `json:"menu_status"` // 菜单状态(0:隐藏 1:正常)此优先级最高
|
||||
MenuType int `json:"menu_type"` // 菜单类型(1:模块 2:菜单 3:按钮)
|
||||
Permission string `json:"permission"` // 标识
|
||||
OrderNum int `json:"order_num"` // 显示顺序
|
||||
Icon string `json:"icon"` // 图标地址
|
||||
Path string `json:"path"` // 页面地址(#表示当前页)
|
||||
}
|
||||
@ -4,6 +4,7 @@ package roleResponse
|
||||
type RoleMenuList struct {
|
||||
MenuId int64 `json:"menu_id"` // 主键id
|
||||
MenuName string `json:"menu_name"` // 菜单名称
|
||||
MenuTitle string `json:"menu_title"` // 菜单名称
|
||||
ParentId int64 `json:"parent_id"` // 父菜单ID(0表示一级)
|
||||
MenuStatus int `json:"menu_status"` // 菜单状态(0:隐藏 1:正常)此优先级最高
|
||||
MenuType int `json:"menu_type"` // 菜单类型(1:模块 2:菜单 3:按钮)
|
||||
@ -11,6 +12,7 @@ type RoleMenuList struct {
|
||||
OrderNum int `json:"order_num"` // 显示顺序
|
||||
Icon string `json:"icon"` // 图标地址
|
||||
Path string `json:"path"` // 页面地址(#表示当前页)
|
||||
Component string `json:"component"` // 组件名称
|
||||
Children []*RoleMenuList `json:"children"` // 下级页面
|
||||
}
|
||||
|
||||
|
||||
@ -55,13 +55,13 @@ func Init() *gin.Engine {
|
||||
// publicRouter 公开路由-不验证权限
|
||||
func publicRouter(r *gin.Engine, api controller.Api) {
|
||||
adminGroup := r.Group("/admin")
|
||||
baseGroup := adminGroup.Group("/basic")
|
||||
basicGroup := adminGroup.Group("/basic")
|
||||
{
|
||||
// 验证码
|
||||
baseGroup.GET("captcha", api.Basic.GetCaptcha)
|
||||
basicGroup.GET("captcha", api.Basic.GetCaptcha)
|
||||
|
||||
// 登陆
|
||||
baseGroup.POST("login", api.Basic.Login)
|
||||
basicGroup.POST("login", api.Basic.Login)
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,22 +70,28 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
adminGroup := r.Group("/admin")
|
||||
|
||||
// 角色
|
||||
base1Group := adminGroup.Group("/role")
|
||||
roleGroup := adminGroup.Group("/role")
|
||||
{
|
||||
// 获取登陆角色菜单列表
|
||||
base1Group.GET("menu", api.Role.GetRoleMenuList)
|
||||
roleGroup.GET("menu", api.Role.GetRoleMenuList)
|
||||
|
||||
// 搜索角色列表
|
||||
base1Group.GET("list", api.Role.GetRoleList)
|
||||
roleGroup.GET("", api.Role.GetRoleList)
|
||||
|
||||
// 角色禁用/启用
|
||||
base1Group.PUT("status/:id", api.Role.PutRoleStatus)
|
||||
roleGroup.PUT("status/:id", api.Role.PutRoleStatus)
|
||||
|
||||
// 角色新增
|
||||
base1Group.POST("", api.Role.AddRole)
|
||||
roleGroup.POST("", api.Role.AddRole)
|
||||
|
||||
// 角色详情
|
||||
base1Group.GET("/:role_id", api.Role.GetRole)
|
||||
roleGroup.GET("/:role_id", api.Role.GetRole)
|
||||
}
|
||||
|
||||
// 菜单
|
||||
menuGroup := adminGroup.Group("/menu")
|
||||
{
|
||||
// 获取菜单列表
|
||||
menuGroup.GET("", api.Menu.GetMenuList)
|
||||
}
|
||||
}
|
||||
|
||||
7
api/service/menu.go
Normal file
7
api/service/menu.go
Normal file
@ -0,0 +1,7 @@
|
||||
package service
|
||||
|
||||
type MenuService struct{}
|
||||
|
||||
// func (r *MenuService) GetMenuList() ([]*roleResponse.RoleMenuList, error) {
|
||||
//
|
||||
// }
|
||||
@ -51,6 +51,7 @@ func buildMenuTree(menuIds []int64, menuData []*model.AdminMenu) []*roleResponse
|
||||
node := &roleResponse.RoleMenuList{
|
||||
MenuId: menu.MenuId,
|
||||
MenuName: menu.MenuName,
|
||||
MenuTitle: menu.MenuTitle,
|
||||
ParentId: menu.ParentId,
|
||||
MenuStatus: menu.MenuStatus,
|
||||
MenuType: menu.MenuType,
|
||||
@ -58,6 +59,7 @@ func buildMenuTree(menuIds []int64, menuData []*model.AdminMenu) []*roleResponse
|
||||
OrderNum: menu.OrderNum,
|
||||
Icon: menu.Icon,
|
||||
Path: menu.Path,
|
||||
Component: menu.Component,
|
||||
Children: nil,
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user