RolePath.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018-2020 rights reserved.
  6. // +----------------------------------------------------------------------
  7. // |
  8. // +----------------------------------------------------------------------
  9. // | Date: 2020-08-31 20:43
  10. // +----------------------------------------------------------------------
  11. namespace app\system\controller;
  12. use app\BaseController;
  13. use app\model\system\AdminRole;
  14. use app\model\system\RolePath as RolePathModel;
  15. use app\Request;
  16. use library\services\UtilService;
  17. class RolePath extends BaseController
  18. {
  19. /**
  20. * 基本设置
  21. */
  22. public function list()
  23. {
  24. $menuMenu = new RolePathModel();
  25. $menus = $menuMenu->getArMenu();
  26. return app('json')->success($menus);
  27. }
  28. /**
  29. * 获取树级分类
  30. */
  31. public function treeList()
  32. {
  33. $menuAr = (new RolePathModel())->order("seq", "desc")->select()->toArray();
  34. $data = sort_list_tier($menuAr, '顶级', 'pid', 'id');
  35. return app('json')->success($data);
  36. }
  37. /**
  38. * 获取详情栏目数据
  39. */
  40. public function info(Request $request)
  41. {
  42. [$id] = UtilService::getMore([
  43. ['id', 0, 'empty', '参数错误'],
  44. ], $request, true);
  45. $data = (new RolePathModel())->find(compact('id'))->toArray();
  46. return app('json')->success($data);
  47. }
  48. /**
  49. * 保存数据
  50. */
  51. public function save(Request $request)
  52. {
  53. $post = UtilService::getMore([
  54. ['id',''],
  55. ['title', ''],
  56. ['pid', '0'],
  57. ['seq', '0'],
  58. ['role_path', ''],
  59. ['menu_id', ''],
  60. ['is_show', '0']
  61. ], $request);
  62. (new RolePathModel())->saveModel($post);
  63. return app('json')->success("数据保存成功");
  64. }
  65. /**
  66. * 栏目删除
  67. * @param Request $request
  68. * @return mixed
  69. */
  70. public function del(Request $request)
  71. {
  72. [$id] = UtilService::getMore([
  73. ['id', 0, 'empty', '参数错误'],
  74. ], $request, true);
  75. $bool = (new RolePathModel())->delMenu($id);
  76. return app('json')->success("栏目删除成功");
  77. }
  78. /**
  79. * 系统分类显示 | 关闭
  80. */
  81. public function status(Request $request)
  82. {
  83. [$id, $is_show] = UtilService::getMore([
  84. ['id', '0', 'empty', '参数错误'],
  85. ['is_show', '0'],
  86. ], $request, true);
  87. $bool = (new RolePathModel())->setStatus($id, $is_show);
  88. if ($bool) {
  89. return app('json')->success('操作成功');
  90. } else {
  91. return app('json')->fail('提交失败');
  92. }
  93. }
  94. }