title = '产品管理'; $this->service_id = input('service_id'); $query = $this->_query($this->table); $query->equal('status,service_id')->dateBetween('create_at'); $query->like('name,value'); $query->order('sort asc, status desc, id desc')->page(); } /** * 添加产品 * @auth true * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function add() { $this->_applyFormToken(); $this->_form($this->table, 'form'); } /** * 编辑产品 * @auth true * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function edit() { $this->_applyFormToken(); $this->_form($this->table, 'form'); } /** * 表单数据处理 * @param array $data * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ protected function _form_filter(&$data) { $this->service_id = input('service_id'); if ($this->request->isPost()) { if (empty($data['name'])) $this->error('产品名称不能为空!'); } } protected function _form_result($id, $data) { } /** * 修改产品状态 * @auth true * @throws \think\db\exception\DbException */ public function state() { $this->_applyFormToken(); $this->_save($this->table, $this->_vali([ 'status.in:0,1' => '状态值范围异常!', 'status.require' => '状态值不能为空!', ])); } /** * 删除产品 * @auth true * @throws \think\db\exception\DbException */ public function remove() { $this->_applyFormToken(); $this->_delete($this->table); } }