model = new RuleAdded(); $this->validate = true; $this->validateClass = new RuleAddedValidate(); } public function select(Request $request): Response { [$where, $format, $limit, $field, $order] = $this->selectInput($request); $order = $request->get('order', 'desc'); $field = $field ?? 'rule_added_addtimes'; $query = $this->doSelect($where, $field, $order); return $this->doFormat($query, $format, $limit); } public function selectList(Request $request) { $data = $this->model->where('rule_added_status', 'ACTIVED') ->select('rule_added_id', 'rule_added_name') ->get() ->toArray(); return json_success('', $data); } protected function insertInput(Request $request): array { $data = $this->inputFilter($request->post()); $data['rule_added_id'] = "RA" . str_pad(SysSerial::getSerial(), 16, '0', STR_PAD_LEFT) . random_string(6, 'up'); return $data; } protected function updateInput(Request $request): array { $primary_key = $this->model->getKeyName(); $id = $request->post($primary_key); $data = $this->inputFilter($request->post()); if (!empty($data['rule_pricing_goods_json'])) { $data['rule_pricing_goods_json'] = json_encode(explode(',', $data['rule_pricing_goods_json'])); } else { $data['rule_pricing_goods_json'] = '[]'; } $model = $this->model->find($id); if (!$model) { throw new BusinessException('记录不存在', 2); } unset($data[$primary_key]); return [$id, $data]; } }