Account.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\logic\AccountLogic;
  4. use app\BaseController;
  5. use think\exception\ValidateException;
  6. use think\facade\Config;
  7. use think\facade\Validate;
  8. class Account extends BaseController
  9. {
  10. //账户列表
  11. public function list()
  12. {
  13. $param = $this->request->only(['page' => 1, 'size' => 10, 'username' => '', 'name' => '', 'mobile' => ''], 'post');
  14. return AccountLogic::list($param);
  15. }
  16. //添加账户
  17. public function add()
  18. {
  19. $param = $this->request->only(['company_id', 'card_id', 'username', 'starttime', 'expiretime', 'video_ids', 'mobile' => '', 'name' => '', 'remark' => ''], 'post');
  20. $val = Validate::rule(Config::get('validate_rules.AccountAdd'));
  21. if (!$val->check($param)) throw new ValidateException($val->getError());
  22. return AccountLogic::add($param);
  23. }
  24. //账户详情
  25. public function read()
  26. {
  27. $id = $this->request->post('id/d', 0);
  28. return AccountLogic::read($id);
  29. }
  30. //编辑账户
  31. public function edit()
  32. {
  33. $param = $this->request->only(['id', 'starttime', 'expiretime', 'video_ids', 'mobile' => '', 'name' => '', 'remark' => ''], 'post');
  34. $val = Validate::rule([
  35. 'id' => 'require|number|gt:0',
  36. 'starttime|开始日期' => 'require|date|lt:expiretime',
  37. 'expiretime|结束日期' => 'require|date|gt:starttime',
  38. 'video_ids|视频id集合' => 'require|array|max:100',
  39. 'mobile|手机号' => 'mobile',
  40. 'name|姓名' => 'max:255',
  41. 'remark|备注' => 'max:255',
  42. ]);
  43. if (!$val->check($param)) throw new ValidateException($val->getError());
  44. return AccountLogic::edit($param);
  45. }
  46. //批量添加账户
  47. public function batchAdd()
  48. {
  49. $param = $this->request->only(['company_id', 'card_id', 'username_prefix', 'username_year', 'starttime', 'expiretime'], 'post');
  50. $val = Validate::rule(Config::get('validate_rules.AccountBatchAdd'));
  51. if (!$val->check($param)) throw new ValidateException($val->getError());
  52. return AccountLogic::batchAdd($param);
  53. }
  54. //删除
  55. public function delete()
  56. {
  57. $id = $this->request->post('id/d', 0);
  58. return AccountLogic::delete($id);
  59. }
  60. //批量添加账户列表
  61. public function batchLog()
  62. {
  63. $param = $this->request->only(['page' => 1, 'size' => 10, 'company_title' => '', 'card_title' => '', 'status' => ''], 'post');
  64. return AccountLogic::batchLog($param);
  65. }
  66. //修改密码
  67. public function changePasswod(){
  68. $param = $this->request->only(['id', 'new_password'], 'post');
  69. $val = Validate::rule(Config::get('validate_rules.adminChangePasswod'));
  70. if (!$val->check($param)) throw new ValidateException($val->getError());
  71. return AccountLogic::changePasswod($param);
  72. }
  73. }