AdminController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\controller\auth;
  20. use app\adminapi\controller\BaseAdminController;
  21. use app\adminapi\validate\auth\AdminValidate;
  22. use app\adminapi\logic\auth\AdminLogic;
  23. use app\adminapi\validate\ResetPasswordValidate;
  24. class AdminController extends BaseAdminController
  25. {
  26. /**
  27. * @notes 查看管理员列表
  28. * @return \think\response\Json
  29. * @author Tab
  30. * @date 2021/7/13 11:32
  31. */
  32. public function lists()
  33. {
  34. return $this->dataLists();
  35. }
  36. /**
  37. * @notes 添加管理员
  38. * @return \think\response\Json
  39. * @author Tab
  40. * @date 2021/7/13 11:33
  41. */
  42. public function add()
  43. {
  44. $params = (new AdminValidate())->post()->goCheck('add');
  45. AdminLogic::add($params);
  46. return $this->success('添加管理员成功');
  47. }
  48. /**
  49. * @notes 编辑管理员
  50. * @return \think\response\Json
  51. * @author Tab
  52. * @date 2021/7/13 11:41
  53. */
  54. public function edit()
  55. {
  56. $params = (new AdminValidate())->post()->goCheck('edit');
  57. $result = AdminLogic::edit($params);
  58. if ($result) {
  59. return $this->success('编辑成功');
  60. }
  61. return $this->fail(AdminLogic::getError());
  62. }
  63. /**
  64. * @notes 删除管理员
  65. * @return \think\response\Json
  66. * @author Tab
  67. * @date 2021/7/13 11:42
  68. */
  69. public function delete()
  70. {
  71. $params = (new AdminValidate())->post()->goCheck('delete');
  72. $result = AdminLogic::delete($params);
  73. if ($result) {
  74. return $this->success('删除成功');
  75. }
  76. return $this->fail(AdminLogic::getError());
  77. }
  78. /**
  79. * @notes 查看管理员详情
  80. * @return \think\response\Json
  81. * @author Tab
  82. * @date 2021/7/13 11:43
  83. */
  84. public function detail()
  85. {
  86. $params = (new AdminValidate())->goCheck('detail');
  87. $result = AdminLogic::detail($params);
  88. return $this->data($result);
  89. }
  90. /**
  91. * @notes 获取管理员的基本信息
  92. * @return \think\response\Json
  93. * @author cjhao
  94. * @date 2022/4/21 15:05
  95. */
  96. public function getAdminInfo()
  97. {
  98. $result = AdminLogic::getAdminInfo($this->adminId);
  99. return $this->data($result);
  100. }
  101. /**
  102. * @notes 修改管理员密码
  103. * @return \think\response\Json
  104. * @author cjhao
  105. * @date 2022/4/21 15:16
  106. *
  107. */
  108. public function resetPassword(){
  109. $params = (new ResetPasswordValidate())->post()->goCheck(null,['admin_id'=>$this->adminId]);
  110. $result = AdminLogic::resetPassword($params,$this->adminId);
  111. if(true === $result){
  112. return $this->success('密码修改成功',[],1,1);
  113. }
  114. return $this->fail($result);
  115. }
  116. }