MenuController.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\controller\auth;
  15. use app\adminapi\controller\BaseAdminController;
  16. use app\adminapi\lists\auth\MenuLists;
  17. use app\adminapi\logic\auth\MenuLogic;
  18. use app\adminapi\validate\auth\MenuValidate;
  19. /**
  20. * 系统菜单权限
  21. * Class MenuController
  22. * @package app\adminapi\controller\setting\system
  23. */
  24. class MenuController extends BaseAdminController
  25. {
  26. /**
  27. * @notes 获取菜单路由
  28. * @return \think\response\Json
  29. * @author 段誉
  30. * @date 2022/6/29 17:41
  31. */
  32. public function route()
  33. {
  34. $result = MenuLogic::getMenuByAdminId($this->adminId);
  35. return $this->data($result);
  36. }
  37. /**
  38. * @notes 获取菜单列表
  39. * @return \think\response\Json
  40. * @author 段誉
  41. * @date 2022/6/29 17:23
  42. */
  43. public function lists()
  44. {
  45. return $this->dataLists(new MenuLists());
  46. }
  47. /**
  48. * @notes 菜单详情
  49. * @return \think\response\Json
  50. * @author 段誉
  51. * @date 2022/6/30 10:07
  52. */
  53. public function detail()
  54. {
  55. $params = (new MenuValidate())->goCheck('detail');
  56. return $this->data(MenuLogic::detail($params));
  57. }
  58. /**
  59. * @notes 添加菜单
  60. * @return \think\response\Json
  61. * @author 段誉
  62. * @date 2022/6/30 10:07
  63. */
  64. public function add()
  65. {
  66. $params = (new MenuValidate())->post()->goCheck('add');
  67. MenuLogic::add($params);
  68. return $this->success('操作成功', [], 1, 1);
  69. }
  70. /**
  71. * @notes 编辑菜单
  72. * @return \think\response\Json
  73. * @author 段誉
  74. * @date 2022/6/30 10:07
  75. */
  76. public function edit()
  77. {
  78. $params = (new MenuValidate())->post()->goCheck('edit');
  79. MenuLogic::edit($params);
  80. return $this->success('操作成功', [], 1, 1);
  81. }
  82. /**
  83. * @notes 删除菜单
  84. * @return \think\response\Json
  85. * @author 段誉
  86. * @date 2022/6/30 10:07
  87. */
  88. public function delete()
  89. {
  90. $params = (new MenuValidate())->post()->goCheck('delete');
  91. MenuLogic::delete($params);
  92. return $this->success('操作成功', [], 1, 1);
  93. }
  94. /**
  95. * @notes 更新状态
  96. * @return \think\response\Json
  97. * @author 段誉
  98. * @date 2022/7/6 17:04
  99. */
  100. public function updateStatus()
  101. {
  102. $params = (new MenuValidate())->post()->goCheck('status');
  103. MenuLogic::updateStatus($params);
  104. return $this->success('操作成功', [], 1, 1);
  105. }
  106. /**
  107. * @notes 获取菜单数据
  108. * @return \think\response\Json
  109. * @throws \think\db\exception\DataNotFoundException
  110. * @throws \think\db\exception\DbException
  111. * @throws \think\db\exception\ModelNotFoundException
  112. * @author 段誉
  113. * @date 2022/10/13 11:03
  114. */
  115. public function all()
  116. {
  117. $result = MenuLogic::getAllData();
  118. return $this->data($result);
  119. }
  120. }