AdminController.php 3.7 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\auth;
  15. use app\adminapi\controller\BaseAdminController;
  16. use app\adminapi\lists\auth\AdminLists;
  17. use app\adminapi\validate\auth\AdminValidate;
  18. use app\adminapi\logic\auth\AdminLogic;
  19. use app\adminapi\validate\auth\editSelfValidate;
  20. /**
  21. * 管理员控制器
  22. * Class AdminController
  23. * @package app\adminapi\controller\auth
  24. */
  25. class AdminController extends BaseAdminController
  26. {
  27. /**
  28. * @notes 查看管理员列表
  29. * @return \think\response\Json
  30. * @author 段誉
  31. * @date 2021/12/29 9:55
  32. */
  33. public function lists()
  34. {
  35. return $this->dataLists(new AdminLists());
  36. }
  37. /**
  38. * @notes 添加管理员
  39. * @return \think\response\Json
  40. * @author 段誉
  41. * @date 2021/12/29 10:21
  42. */
  43. public function add()
  44. {
  45. $params = (new AdminValidate())->post()->goCheck('add');
  46. $result = AdminLogic::add($params);
  47. if (true === $result) {
  48. return $this->success('操作成功', [], 1, 1);
  49. }
  50. return $this->fail(AdminLogic::getError());
  51. }
  52. /**
  53. * @notes 编辑管理员
  54. * @return \think\response\Json
  55. * @author 段誉
  56. * @date 2021/12/29 11:03
  57. */
  58. public function edit()
  59. {
  60. $params = (new AdminValidate())->post()->goCheck('edit');
  61. $result = AdminLogic::edit($params);
  62. if (true === $result) {
  63. return $this->success('操作成功', [], 1, 1);
  64. }
  65. return $this->fail(AdminLogic::getError());
  66. }
  67. /**
  68. * @notes 删除管理员
  69. * @return \think\response\Json
  70. * @author 段誉
  71. * @date 2021/12/29 11:03
  72. */
  73. public function delete()
  74. {
  75. $params = (new AdminValidate())->post()->goCheck('delete');
  76. $result = AdminLogic::delete($params);
  77. if (true === $result) {
  78. return $this->success('操作成功', [], 1, 1);
  79. }
  80. return $this->fail(AdminLogic::getError());
  81. }
  82. /**
  83. * @notes 查看管理员详情
  84. * @return \think\response\Json
  85. * @author 段誉
  86. * @date 2021/12/29 11:07
  87. */
  88. public function detail()
  89. {
  90. $params = (new AdminValidate())->goCheck('detail');
  91. $result = AdminLogic::detail($params);
  92. return $this->data($result);
  93. }
  94. /**
  95. * @notes 获取当前管理员信息
  96. * @return \think\response\Json
  97. * @author 段誉
  98. * @date 2021/12/31 10:53
  99. */
  100. public function mySelf()
  101. {
  102. $result = AdminLogic::detail(['id' => $this->adminId], 'auth');
  103. return $this->data($result);
  104. }
  105. /**
  106. * @notes 编辑超级管理员信息
  107. * @return \think\response\Json
  108. * @author 段誉
  109. * @date 2022/4/8 17:54
  110. */
  111. public function editSelf()
  112. {
  113. $params = (new editSelfValidate())->post()->goCheck('', ['admin_id' => $this->adminId]);
  114. $result = AdminLogic::editSelf($params);
  115. return $this->success('操作成功', [], 1, 1);
  116. }
  117. }