1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?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 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);
- }
- }
|