Admin.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\logic\AdminLogic;
  4. use app\BaseController;
  5. use think\exception\ValidateException;
  6. use think\facade\Config;
  7. use think\facade\Validate;
  8. //运营账号
  9. class Admin extends BaseController
  10. {
  11. //获取运营账号列表
  12. public function list()
  13. {
  14. $param = $this->request->only(['page' => 1, 'size' => 15, 'username' => '','status' => ''], 'post');
  15. return AdminLogic::list($param);
  16. }
  17. //添加运营账号
  18. public function add()
  19. {
  20. $param = $this->request->only(['username', 'role_id','card_id'], 'post');
  21. $val = Validate::rule(Config::get('validate_rules.adminAdd'));
  22. if (!$val->check($param)) throw new ValidateException($val->getError());
  23. return AdminLogic:: add($param);
  24. }
  25. //获取运营账号详情
  26. public function read()
  27. {
  28. $id = $this->request->post('id/d', 0);
  29. return AdminLogic::read($id);
  30. }
  31. //编辑运营账号
  32. public function edit()
  33. {
  34. $param = $this->request->only(['id', 'username', 'role_id','card_id'], 'post');
  35. $val = Validate::rule(array_merge(['id' => 'require|number|gt:0'], Config::get('validate_rules.adminAdd')));
  36. if (!$val->check($param)) throw new ValidateException($val->getError());
  37. return AdminLogic::edit($param);
  38. }
  39. //删除运营账号
  40. public function delete()
  41. {
  42. $id = $this->request->post('id/d', 0);
  43. return AdminLogic::delete($id);
  44. }
  45. //启禁用运营账号
  46. public function status()
  47. {
  48. $param = $this->request->only(['id', 'status'], 'post');
  49. $val = Validate::rule(Config::get('validate_rules.status'));
  50. if (!$val->check($param)) throw new ValidateException($val->getError());
  51. return AdminLogic::status($param);
  52. }
  53. //更改密码
  54. public function changePasswod()
  55. {
  56. $param = $this->request->only(['id', 'new_password'], 'post');
  57. $val = Validate::rule(Config::get('validate_rules.adminChangePasswod'));
  58. if (!$val->check($param)) throw new ValidateException($val->getError());
  59. return AdminLogic::changePasswod($param);
  60. }
  61. }