12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace app\admin\controller;
- use app\admin\logic\CardLogic;
- use app\BaseController;
- use think\exception\ValidateException;
- use think\facade\Config;
- use think\facade\Validate;
- class Card extends BaseController
- {
- //获取卡类型列表
- public function list()
- {
- $param = $this->request->only(['page' => 1, 'size' => 10, 'status' => '', 'title' => '',], 'post');
- $val = Validate::rule(Config::get('validate_rules.common'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return CardLogic::list($param);
- }
- //获取全部卡类型
- public function all()
- {
- $keyword = $this->request->post('keyword', '');
- return CardLogic::all($keyword);
- }
- //添加卡类型
- public function add()
- {
- $param = $this->request->only(['title'], 'post');
- $val = Validate::rule(Config::get('validate_rules.cardAdd'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return CardLogic::add($param);
- }
- //获取卡类型详情
- public function read()
- {
- $id = $this->request->post('id/d', 0);
- return CardLogic::read($id);
- }
- //编辑卡类型
- public function edit()
- {
- $param = $this->request->only(['id', 'title'], 'post');
- $val = Validate::rule(Config::get('validate_rules.cardEdit'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return CardLogic::edit($param);
- }
- //卡类型启禁用
- public function change()
- {
- $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 CardLogic::change($param);
- }
- //删除卡类型
- public function delete()
- {
- $id = $this->request->post('id/d', 0);
- return CardLogic::delete($id);
- }
- }
|