Index.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. namespace app\admin\controller\index;
  3. use app\admin\controller\BaseController;
  4. use app\admin\model\SystemAdmin;
  5. use app\admin\server\index\IndexServer;
  6. class Index extends BaseController
  7. {
  8. /**
  9. * Notes:获取菜单列表
  10. * @return \support\Response
  11. * User: ZQ
  12. * Date: 2022/9/16
  13. */
  14. public function getAdminList()
  15. {
  16. $keywords = $this->request->get('keywords');
  17. [$page, $limit] = $this->getPage();
  18. $result = IndexServer::getAdminList($keywords,$page,$limit);
  19. return json_success($result, '成功');
  20. }
  21. /**
  22. * Notes:修改管理员
  23. * @return \support\Response
  24. * User: ZQ
  25. * Date: 2022/9/16
  26. */
  27. public function updateAdmin()
  28. {
  29. $admin_id = $this->request->post('admin_id');
  30. $admin_real_name = $this->request->post('admin_real_name','');
  31. $admin_pwd = $this->request->post('admin_pwd','');
  32. $agin_admin_pwd = $this->request->post('agin_admin_pwd','');
  33. $admin_roles = $this->request->post('admin_roles');
  34. $admin_status = $this->request->post('admin_status');
  35. if (!empty($admin_pwd) && !empty($agin_admin_pwd)){
  36. if ($admin_pwd != $agin_admin_pwd){
  37. throw new \Exception('两次密码输入不一致!');
  38. }
  39. }
  40. $this->validateCheck('index\IndexValidate', ['admin_id' => $admin_id], 'update');
  41. $result = IndexServer::updateAdmin($admin_id, $admin_real_name, $admin_pwd, $admin_roles, $admin_status);
  42. return json_success($result, '修改成功');
  43. }
  44. /**
  45. * Notes:添加管理员
  46. * @return \support\Response
  47. * User: ZQ
  48. * Date: 2022/9/16
  49. */
  50. public function insertAdmin()
  51. {
  52. $admin_real_name = $this->request->post('admin_real_name','');
  53. $admin_pwd = $this->request->post('admin_pwd','');
  54. $admin_account = $this->request->post('admin_account');
  55. $agin_admin_pwd = $this->request->post('agin_admin_pwd','');
  56. $admin_roles = $this->request->post('admin_roles');
  57. $admin_status = $this->request->post('admin_status');
  58. if (!empty($admin_pwd) && !empty($agin_admin_pwd)){
  59. if ($admin_pwd != $agin_admin_pwd){
  60. throw new \Exception('两次密码输入不一致!');
  61. }
  62. }
  63. $this->validateCheck('index\IndexValidate', ['admin_real_name' => $admin_real_name, 'admin_pwd' => $admin_pwd, 'admin_account' => $admin_account, 'agin_admin_pwd' => $agin_admin_pwd, 'admin_roles' => $admin_roles, 'admin_status' => $admin_status], 'insert');
  64. $result = IndexServer::insertAdmin($admin_account, $admin_real_name, $admin_pwd, $admin_roles, $admin_status);
  65. return json_success($result, '修改成功');
  66. }
  67. /**
  68. * Notes:删除管理员
  69. * @return \support\Response
  70. * User: ZQ
  71. * Date: 2022/9/16
  72. */
  73. public function delAdmin()
  74. {
  75. $admin_id = $this->request->get('admin_id');
  76. $this->validateCheck('index\IndexValidate', ['admin_id' => $admin_id], 'info');
  77. $result = IndexServer::delAdmin($admin_id);
  78. if ($result){
  79. return json_success($result, '删除成功');
  80. }else{
  81. throw new \Exception('删除失败!');
  82. }
  83. }
  84. /**
  85. * Notes:查询管理员详情
  86. * @return \support\Response
  87. * User: ZQ
  88. * Date: 2022/9/13
  89. */
  90. public function adminInfo()
  91. {
  92. $admin_id = $this->request->get('admin_id');
  93. $this->validateCheck('index\IndexValidate', ['admin_id' => $admin_id], 'info');
  94. $result = IndexServer::adminInfo($admin_id);
  95. return json_success($result, '成功');
  96. }
  97. /**
  98. * Notes:管理员启用禁用
  99. * @return \support\Response
  100. * User: ZQ
  101. * Date: 2022/9/13
  102. */
  103. public function updateStatus()
  104. {
  105. $admin_id = $this->request->get('admin_id');
  106. $admin_status = $this->request->get('admin_status');
  107. $this->validateCheck('index\IndexValidate', ['admin_id' => $admin_id], 'info');
  108. $result = IndexServer::updateStatus($admin_id, $admin_status);
  109. return json_success($result, '修改成功');
  110. }
  111. /**
  112. * Notes:获取小程序页面地址列表
  113. * @return \support\Response
  114. * User: yym
  115. * Date: 2022/10/25
  116. */
  117. public function getPageList()
  118. {
  119. return json_success(IndexServer::getPageList());
  120. }
  121. }