dddd
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.

79 lines
2.5 KiB

package systemuser
import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
"github.com/flipped-aurora/gin-vue-admin/server/model/systemuser"
"github.com/gin-gonic/gin"
)
//菜单相关
func (s *SysTemMenuApi) SystemMenuList(c *gin.Context) {
// response.Result(101, global.Gva_Authority_Authentication, "数据获取失败!", c)
var systemMenuList []systemuser.SystemMenu
menuOperErr := global.GVA_DB_Master.Where("`m_steat` IN ?", []int{1, 2}).Order("m_id desc").Find(&systemMenuList).Error
if menuOperErr != nil {
response.Result(101, menuOperErr, "数据获取失败!", c)
return
}
systemListMenu := GetMenuThree(1, 0, systemMenuList)
response.Result(0, systemListMenu, "数据获取成功!", c)
}
//递归无限树
func GetMenuThree(jurisd int, parentId int64, threeData []systemuser.SystemMenu) []SystemMenuThree {
treeList := []SystemMenuThree{}
for _, v := range threeData {
if v.ParentId == parentId {
child := GetMenuThree(jurisd, v.Id, threeData)
node := SystemMenuThree{
Id: v.Id,
Title: v.Title,
State: v.State,
ParentId: v.ParentId,
ApiUrl: v.ApiUrl,
Time: v.Time,
EiteTime: v.EiteTime,
UserId: v.UserId,
Sort: v.Sort,
}
isTrue, menuOper := MenuOperation(jurisd, v.Id)
if isTrue == true {
node.MenuOperation = menuOper
}
node.Child = child
treeList = append(treeList, node)
}
}
return treeList
}
//获取菜单操作项目
func MenuOperation(jurisd int, menuId int64) (isTrue bool, operation []systemuser.MenuOperation) {
isTrue = false
if jurisd != 1 {
operErr := global.GVA_DB_Master.Where("`menu_id` = ? AND oper_id IN ?", menuId, global.Gva_Authority_Authentication).Order("oper_id desc").Find(&operation).Error
if operErr == nil {
isTrue = true
}
} else {
operErr := global.GVA_DB_Master.Where("`menu_id` = ?", menuId).Order("oper_id desc").Find(&operation).Error
if operErr == nil {
isTrue = true
}
}
return
}
//获取左侧菜单栏
func (s *SysTemMenuApi) GetMenu(c *gin.Context) {
var systemMenuList []systemuser.SystemMenu
menuOperErr := global.GVA_DB_Master.Where("`m_steat` IN ? AND m_id IN ?", []int{1, 2}, global.Gva_Authority_Authentication_Subsidiary).Order("m_id desc").Find(&systemMenuList).Error
if menuOperErr != nil {
response.Result(101, menuOperErr, "数据获取失败!", c)
return
}
systemListMenu := GetMenuThree(2, 0, systemMenuList)
response.Result(0, systemListMenu, "数据获取成功!", c)
}