1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace app\admin\controller;
- use app\admin\logic\AdminLogic;
- use app\BaseController;
- use think\exception\ValidateException;
- use think\facade\Config;
- use think\facade\Validate;
- //运营账号
- class Admin extends BaseController
- {
- //获取运营账号列表
- public function list()
- {
- $param = $this->request->only(['page' => 1, 'size' => 15, 'username' => '','status' => ''], 'post');
- return AdminLogic::list($param);
- }
- //添加运营账号
- public function add()
- {
- $param = $this->request->only(['username', 'role_id','card_id'], 'post');
- $val = Validate::rule(Config::get('validate_rules.adminAdd'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return AdminLogic:: add($param);
- }
- //获取运营账号详情
- public function read()
- {
- $id = $this->request->post('id/d', 0);
- return AdminLogic::read($id);
- }
- //编辑运营账号
- public function edit()
- {
- $param = $this->request->only(['id', 'username', 'role_id','card_id'], 'post');
- $val = Validate::rule(array_merge(['id' => 'require|number|gt:0'], Config::get('validate_rules.adminAdd')));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return AdminLogic::edit($param);
- }
- //删除运营账号
- public function delete()
- {
- $id = $this->request->post('id/d', 0);
- return AdminLogic::delete($id);
- }
- //启禁用运营账号
- public function status()
- {
- $param = $this->request->only(['id', 'status'], 'post');
- $val = Validate::rule(Config::get('validate_rules.status'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return AdminLogic::status($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 AdminLogic::changePasswod($param);
- }
- }
|