1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace app\admin\controller;
- use app\admin\logic\ServiceLogic;
- use app\BaseController;
- use app\model\CommonModel;
- use think\exception\ValidateException;
- use think\facade\Config;
- use think\facade\Validate;
- //【服务】
- class Service extends BaseController
- {
- //获取服务列表
- public function list()
- {
- $param = $this->request->only(['page' => 1, 'size' => 10, 'status' => '', 'activity_status' => '', 'company_title' => '', 'card_title' => ''], 'post');
- return ServiceLogic::list($param);
- }
- //添加服务
- public function add()
- {
- $param = $this->request->only(['company_id', 'card_id', 'original_price', 'activity_price', 'title', 'content', 'starttime', 'endtime', 'expiretime', 'remark' => ''], 'post');
- $val = Validate::rule(Config::get('validate_rules.ServiceAdd'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return ServiceLogic::add($param);
- }
- //获取服务详情
- public function read()
- {
- $id = $this->request->post('id/d', 0);
- return ServiceLogic::read($id);
- }
- //编辑服务
- public function edit()
- {
- $param = $this->request->only(['id', 'company_id', 'card_id', 'original_price', 'activity_price', 'title', 'content', 'starttime', 'endtime', 'expiretime'], 'post');
- $val = Validate::rule(array_merge(Config::get('validate_rules.ServiceAdd'), ['id|服务id' => 'require|number|gt:0']));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return ServiceLogic::edit($param);
- }
- //服务上下架
- 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 ServiceLogic::status($param);
- }
- //删除服务
- public function delete()
- {
- $ids = $this->request->post('id/a', []);
- return ServiceLogic::delete($ids);
- }
- }
|