123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace app\admin\controller;
- use app\admin\logic\GroupItemLogic;
- use app\BaseController;
- use app\model\CommonModel;
- use app\model\GroupModel;
- use think\exception\ValidateException;
- use think\facade\Config;
- use think\facade\Validate;
- //【分组明细】
- class GroupItem extends BaseController
- {
- //获取分组明细列表
- public function list()
- {
- $param = $this->request->only(['group_id' => 0, 'type' => GroupModel::$type_good, 'page' => 1, 'size' => 10, 'title' => ''], 'post');
- $val = Validate::rule([
- 'group_id|分组id' => 'require|number|gt:0',
- 'type|明细类型' => 'require|number|in:' . GroupModel::$type_good . ',' . GroupModel::$type_video,
- 'page|页码' => 'require|number|gt:0',
- 'size|每页数量' => 'require|number|elt:100',
- ]);
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return GroupItemLogic::list($param);
- }
- //添加分组明细
- public function add()
- {
- $param = $this->request->only(['group_id', 'type', 'item_id', 'weight' => 0], 'post');
- $val = Validate::rule(Config::get('validate_rules.GroupItemAdd'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return GroupItemLogic::add($param);
- }
- //获取分组明细详情
- public function read()
- {
- $id = $this->request->post('id/d', 0);
- return GroupItemLogic::read($id);
- }
- //编辑分组明细
- public function edit()
- {
- $param = $this->request->only(['id', 'item_id', 'weight' => 0], 'post');
- $val = Validate::rule([
- 'id|分组明细id' => 'require|number|gt:0',
- 'item_id|明细id' => 'require|number|gt:0',
- 'weight|权重' => 'number|egt:0',
- ]);
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return GroupItemLogic::edit($param);
- }
- //删除分组明细
- public function delete()
- {
- $ids = $this->request->post('id/a', []);
- return GroupItemLogic::delete($ids);
- }
- //置顶
- public function top()
- {
- $param = $this->request->only(['id', 'is_top'], 'post');
- $val = Validate::rule([
- 'id' => 'require|number|gt:0',
- 'is_top|是否置顶' => 'require|number|in:' . CommonModel::$top_no . ',' . CommonModel::$top_yes,
- ]);
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return GroupItemLogic::top($param);
- }
- }
|