123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- namespace app\admin\controller;
- use app\admin\logic\AccountLogic;
- use app\BaseController;
- use think\exception\ValidateException;
- use think\facade\Config;
- use think\facade\Validate;
- class Account extends BaseController
- {
- //账户列表
- public function list()
- {
- $param = $this->request->only(['page' => 1, 'size' => 10, 'username' => '', 'name' => '', 'mobile' => ''], 'post');
- return AccountLogic::list($param);
- }
- //添加账户
- public function add()
- {
- $param = $this->request->only(['company_id', 'card_id', 'username', 'starttime', 'expiretime', 'video_ids', 'mobile' => '', 'name' => '', 'remark' => ''], 'post');
- $val = Validate::rule(Config::get('validate_rules.AccountAdd'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return AccountLogic::add($param);
- }
- //账户详情
- public function read()
- {
- $id = $this->request->post('id/d', 0);
- return AccountLogic::read($id);
- }
- //编辑账户
- public function edit()
- {
- $param = $this->request->only(['id', 'starttime', 'expiretime', 'video_ids', 'mobile' => '', 'name' => '', 'remark' => ''], 'post');
- $val = Validate::rule([
- 'id' => 'require|number|gt:0',
- 'starttime|开始日期' => 'require|date|lt:expiretime',
- 'expiretime|结束日期' => 'require|date|gt:starttime',
- 'video_ids|视频id集合' => 'require|array|max:100',
- 'mobile|手机号' => 'mobile',
- 'name|姓名' => 'max:255',
- 'remark|备注' => 'max:255',
- ]);
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return AccountLogic::edit($param);
- }
- //批量添加账户
- public function batchAdd()
- {
- $param = $this->request->only(['company_id', 'card_id', 'username_prefix', 'username_year', 'starttime', 'expiretime'], 'post');
- $val = Validate::rule(Config::get('validate_rules.AccountBatchAdd'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return AccountLogic::batchAdd($param);
- }
- //删除
- public function delete()
- {
- $id = $this->request->post('id/d', 0);
- return AccountLogic::delete($id);
- }
- //批量添加账户列表
- public function batchLog()
- {
- $param = $this->request->only(['page' => 1, 'size' => 10, 'company_title' => '', 'card_title' => '', 'status' => ''], 'post');
- return AccountLogic::batchLog($param);
- }
- //修改密码
- public function changePasswod(){
- $param = $this->request->only(['id', 'new_password'], 'post');
- $val = Validate::rule(Config::get('validate_rules.adminChangePasswod'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return AccountLogic::changePasswod($param);
- }
- }
|