12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package controllers
- import (
- "eta_gn/eta_api/models"
- "eta_gn/eta_api/models/system"
- "eta_gn/eta_api/utils"
- )
- type SysMenuButtonController struct {
- BaseAuthController
- }
- // SysMenuButtons
- // @Title 获取菜单全部按钮
- // @Description 获取菜单全部按钮接口
- // @Param RoleId query int true "角色ID"
- // @Success 200 {object} system.MenuButtonsResp
- // @router /menu/buttons [get]
- func (this *SysRoleController) SysMenuButtons() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- list, err := system.GetButtonMenu()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- listLen := len(list)
- if listLen <= 0 {
- list = make([]*system.ButtonMenu, 0)
- }
- for i := 0; i < listLen; i++ {
- item := list[i]
- menus, err := system.GetSysMenuButtonItems(item.MenuId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- list[i].List = menus
- }
- roleId, _ := this.GetInt("RoleId")
- checkList := make([]*int, 0)
- cl, err := system.GetRoleButtonCheck(roleId)
- if err != nil && !utils.IsErrNoRow(err) {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for _, v := range cl {
- checkList = append(checkList, &v.MenuButtonId)
- }
- resp := new(system.MenuButtonsResp)
- resp.List = list
- resp.CheckList = checkList
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|