You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
1.9 KiB
99 lines
1.9 KiB
package menus
|
|
|
|
import (
|
|
"appPlatform/models/modelAppPlatform"
|
|
"appPlatform/overall"
|
|
"appPlatform/overall/publicmethod"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-05-22 13:26:16
|
|
@ 功能: 获取路由树
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GetMenusThree(c *gin.Context) {
|
|
var menusList []modelAppPlatform.Menus
|
|
err := overall.CONSTANT_DB_AppPlatform.Where("visible IN ?", []int{1, 2}).Find(&menusList).Error
|
|
if err != nil && len(menusList) < 1 {
|
|
publicmethod.Result(1, err, c, "没有路由!")
|
|
return
|
|
}
|
|
routerThree := publicmethod.GetMenuRouterThree(0, menusList)
|
|
publicmethod.Result(0, routerThree, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-05-22 15:36:33
|
|
@ 功能: 获取菜单列表树
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GetMenusListTree(c *gin.Context) {
|
|
var requestData ShearMenu
|
|
c.ShouldBindJSON(&requestData)
|
|
var menusList []modelAppPlatform.Menus
|
|
gormDb := overall.CONSTANT_DB_AppPlatform.Where("visible IN ?", []int{1, 2})
|
|
if requestData.Title != "" {
|
|
gormDb = gormDb.Where("`name` LIKE ?", "%"+requestData.Title+"%")
|
|
}
|
|
err := gormDb.Find(&menusList).Error
|
|
if err != nil && len(menusList) < 1 {
|
|
publicmethod.Result(1, err, c, "没有路由!")
|
|
return
|
|
}
|
|
routerThree := publicmethod.GetAppMenuThree(0, menusList)
|
|
publicmethod.Result(0, routerThree, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-05-22 16:21:11
|
|
@ 功能: 菜单下拉列表
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) MenuOptions(c *gin.Context) {
|
|
var menusList []modelAppPlatform.Menus
|
|
err := overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.Menus{}).Select("`id`,`name`,`parentId`").Where("visible IN ?", []int{1, 2}).Find(&menusList).Error
|
|
if err != nil && len(menusList) < 1 {
|
|
publicmethod.Result(1, err, c, "没有路由!")
|
|
return
|
|
}
|
|
routerThree := publicmethod.GetMenuOptionsThree(0, menusList)
|
|
publicmethod.Result(0, routerThree, c)
|
|
}
|
|
|