scene('add')->check($request->post())) { return json_fail($validate->getError()); } // 验证数据表是否存在 if (!FieldService::checkTableExist($request->post('field_table'))) { return json_fail('数据表不存在'); } // 验证字段重复 if (FieldService::checkFieldExist($request->post('field_table'), $request->post('field_column_key'))) { return json_fail('字段已存在,请勿重复添加'); } return FieldService::addField($request->post()); } /** * @Desc 修改字段 * @Author Gorden * @Date 2024/2/22 14:41 * * @param $id * @param Request $request * @return \support\Response */ public function updateField($id, Request $request) { $validate = new FieldValidate(); if (!$validate->scene('update')->check($request->post())) { return json_fail($validate->getError()); } // 验证数据表是否存在 if (!FieldService::checkTableExist($request->post('field_table'))) { return json_fail('数据表不存在'); } return FieldService::updateField($id, $request->post()); } /** * @Desc 修改字段状态 * @Author Gorden * @Date 2024/2/22 15:05 * * @param $id * @param Request $request * @return \support\Response */ public function updateStatus($id, Request $request) { $validate = new FieldValidate(); if (!$validate->scene('update_status')->check($request->post())) { return json_fail($validate->getError()); } return FieldService::updateStatus($id, $request->post()); } /** * @Desc 删除字段 * @Author Gorden * @Date 2024/2/22 15:08 * * @param $id * @return \support\Response */ public function delField(Request $request) { $fieldId = $request->post('field_id'); return FieldService::delField($fieldId); } }