Menu.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. namespace app\admin\controller\menu;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\menu\MenuServer;
  5. class Menu extends BaseController
  6. {
  7. /**
  8. * Notes:获取菜单列表
  9. * @return \support\Response
  10. * User: ZQ
  11. * Date: 2022/9/14
  12. */
  13. public function getMenuList()
  14. {
  15. $keywords = $this->request->get('keywords');
  16. $result = MenuServer::getMenuList($keywords);
  17. return json_success($result, '成功');
  18. }
  19. /**
  20. * Notes:修改菜单
  21. * @return \support\Response
  22. * User: ZQ
  23. * Date: 2022/9/14
  24. */
  25. public function updateMenu()
  26. {
  27. $menu_id = $this->request->post('menu_id');
  28. $menu_name = $this->request->post('menu_name','');
  29. $menu_pid = $this->request->post('menu_pid','');
  30. $menu_path = $this->request->post('menu_path','');
  31. $menu_icon = $this->request->post('menu_icon','');
  32. $menu_route = $this->request->post('menu_route','');
  33. $menu_params = $this->request->post('menu_params','');
  34. $menu_sort = $this->request->post('menu_sort','');
  35. $menu_is_menu = $this->request->post('menu_is_menu');
  36. $menu_is_show = $this->request->post('menu_is_show');
  37. $this->validateCheck('menu\MenuValidate', ['menu_id'=>$menu_id], 'update');
  38. $result = MenuServer::updateMenu($menu_id, $menu_name, $menu_pid, $menu_path, $menu_icon, $menu_route, $menu_params, $menu_sort, $menu_is_menu, $menu_is_show);
  39. return json_success($result, '修改成功');
  40. }
  41. /**
  42. * Notes:删除菜单
  43. * @return \support\Response
  44. * User: ZQ
  45. * Date: 2022/9/14
  46. */
  47. public function delMenu()
  48. {
  49. $menu_id = $this->request->get('menu_id');
  50. $this->validateCheck('menu\MenuValidate', ['menu_id' => $menu_id], 'info');
  51. $result = MenuServer::delMenu($menu_id);
  52. if ($result){
  53. return json_success($result, '删除成功');
  54. }else{
  55. throw new \Exception('删除失败!');
  56. }
  57. }
  58. /**
  59. * Notes:添加菜单
  60. * @return \support\Response
  61. * User: ZQ
  62. * Date: 2022/9/14
  63. */
  64. public function addMenu()
  65. {
  66. $menu_name = $this->request->post('menu_name','');
  67. $menu_pid = $this->request->post('menu_pid',0);
  68. $menu_path = $this->request->post('menu_path','');
  69. $menu_icon = $this->request->post('menu_icon','');
  70. $menu_route = $this->request->post('menu_route','');
  71. $menu_params = $this->request->post('menu_params','');
  72. $menu_sort = $this->request->post('menu_sort',1);
  73. $menu_is_menu = $this->request->post('menu_is_menu');
  74. $menu_is_show = $this->request->post('menu_is_show');
  75. $this->validateCheck('menu\MenuValidate', ['menu_name' => $menu_name, 'menu_pid' => $menu_pid, 'menu_is_menu' => $menu_is_menu, 'menu_is_show' => $menu_is_show], 'create');
  76. $result = MenuServer::insertMenu($menu_name, $menu_pid, $menu_path, $menu_icon, $menu_route, $menu_params, $menu_sort, $menu_is_menu, $menu_is_show);
  77. return json_success($result, '添加成功');
  78. }
  79. /**
  80. * Notes:查询菜单详情
  81. * @return \support\Response
  82. * User: ZQ
  83. * Date: 2022/9/13
  84. */
  85. public function menuInfo()
  86. {
  87. $menu_id = $this->request->get('menu_id');
  88. $this->validateCheck('menu\MenuValidate', ['menu_id' => $menu_id], 'info');
  89. $result = MenuServer::menuInfo($menu_id);
  90. if (!empty($result))
  91. return json_success($result, '成功');
  92. }
  93. /*
  94. * Notes:角色三级菜单
  95. * @return \support\Response
  96. * User: ZQ
  97. * Date: 2022/9/15
  98. */
  99. public function menuLevel()
  100. {
  101. $result = MenuServer::menuLevel();
  102. return json_success($result, '成功');
  103. }
  104. /*
  105. * Notes:角色二级菜单
  106. * @return \support\Response
  107. * User: ZQ
  108. * Date: 2022/9/15
  109. */
  110. public function secondLevel()
  111. {
  112. $result = MenuServer::secondLevel();
  113. return json_success($result, '成功');
  114. }
  115. /**
  116. * Notes:修改菜单状态
  117. * @return \support\Response
  118. * User: ZQ
  119. * Date: 2022/9/14
  120. */
  121. public function updateStatus()
  122. {
  123. $menu_id = $this->request->get('menu_id');
  124. $menu_is_show = $this->request->get('menu_is_show');
  125. $this->validateCheck('menu\MenuValidate', ['menu_id'=>$menu_id], 'update');
  126. $result = MenuServer::updateStatus($menu_id, $menu_is_show);
  127. return json_success($result, '修改成功');
  128. }
  129. /**
  130. * Notes:菜单列表
  131. * @return \support\Response
  132. * User: yym
  133. * Date: 2022/9/21
  134. */
  135. public function getHomeMenuList()
  136. {
  137. $admin_info = $this->request->admin_info;
  138. return json_success(MenuServer::getHomeMenuList($admin_info->toArray()));
  139. }
  140. }