DeptController.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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\dept;
  15. use app\adminapi\controller\BaseAdminController;
  16. use app\adminapi\logic\dept\DeptLogic;
  17. use app\adminapi\validate\dept\DeptValidate;
  18. /**
  19. * 部门管理控制器
  20. * Class DeptController
  21. * @package app\adminapi\controller\dept
  22. */
  23. class DeptController extends BaseAdminController
  24. {
  25. /**
  26. * @notes 部门列表
  27. * @return \think\response\Json
  28. * @author 段誉
  29. * @date 2022/5/25 18:07
  30. */
  31. public function lists()
  32. {
  33. $params = $this->request->get();
  34. $result = DeptLogic::lists($params);
  35. return $this->success('',$result);
  36. }
  37. /**
  38. * @notes 上级部门
  39. * @return \think\response\Json
  40. * @throws \think\db\exception\DataNotFoundException
  41. * @throws \think\db\exception\DbException
  42. * @throws \think\db\exception\ModelNotFoundException
  43. * @author 段誉
  44. * @date 2022/5/26 18:36
  45. */
  46. public function leaderDept()
  47. {
  48. $result = DeptLogic::leaderDept();
  49. return $this->success('',$result);
  50. }
  51. /**
  52. * @notes 添加部门
  53. * @return \think\response\Json
  54. * @author 段誉
  55. * @date 2022/5/25 18:40
  56. */
  57. public function add()
  58. {
  59. $params = (new DeptValidate())->post()->goCheck('add');
  60. DeptLogic::add($params);
  61. return $this->success('添加成功', [], 1, 1);
  62. }
  63. /**
  64. * @notes 编辑部门
  65. * @return \think\response\Json
  66. * @author 段誉
  67. * @date 2022/5/25 18:41
  68. */
  69. public function edit()
  70. {
  71. $params = (new DeptValidate())->post()->goCheck('edit');
  72. $result = DeptLogic::edit($params);
  73. if (true === $result) {
  74. return $this->success('编辑成功', [], 1, 1);
  75. }
  76. return $this->fail(DeptLogic::getError());
  77. }
  78. /**
  79. * @notes 删除部门
  80. * @return \think\response\Json
  81. * @author 段誉
  82. * @date 2022/5/25 18:41
  83. */
  84. public function delete()
  85. {
  86. $params = (new DeptValidate())->post()->goCheck('delete');
  87. DeptLogic::delete($params);
  88. return $this->success('删除成功', [], 1, 1);
  89. }
  90. /**
  91. * @notes 获取部门详情
  92. * @return \think\response\Json
  93. * @author 段誉
  94. * @date 2022/5/25 18:41
  95. */
  96. public function detail()
  97. {
  98. $params = (new DeptValidate())->goCheck('detail');
  99. $result = DeptLogic::detail($params);
  100. return $this->data($result);
  101. }
  102. /**
  103. * @notes 获取部门数据
  104. * @return \think\response\Json
  105. * @throws \think\db\exception\DataNotFoundException
  106. * @throws \think\db\exception\DbException
  107. * @throws \think\db\exception\ModelNotFoundException
  108. * @author 段誉
  109. * @date 2022/10/13 10:28
  110. */
  111. public function all()
  112. {
  113. $result = DeptLogic::getAllData();
  114. return $this->data($result);
  115. }
  116. }