|
@@ -347,4 +347,69 @@ class FormService implements FormServiceInterface
|
|
|
return Result::error('查询失败:' . $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 删除自定义表里面的某一条数据
|
|
|
+ */
|
|
|
+ public function delGlobalTableData(array $data): array
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ //查询global库的表GlobalTable模型中id为$data['id']的数据
|
|
|
+ $globalTable = GlobalTable::where('id',$data['table_id'])->first();
|
|
|
+ if(empty($globalTable)){
|
|
|
+ return Result::error('表单不存在');
|
|
|
+ }
|
|
|
+ // 构建查询
|
|
|
+ $query = Db::connection('global')->table($globalTable->table);
|
|
|
+ $query->where('id',$data['id']);
|
|
|
+ $query->delete();
|
|
|
+ return Result::success('删除成功');
|
|
|
+ }catch (\Throwable $e){
|
|
|
+ return Result::error('删除失败:' . $e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 修改自定义表里面的某一条数据
|
|
|
+ */
|
|
|
+ public function updateGlobalTableData(array $data): array
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ //查询global库的表GlobalTable模型中id为$data['id']的数据
|
|
|
+ $globalTable = GlobalTable::where('id',$data['table_id'])->first();
|
|
|
+ if(empty($globalTable)){
|
|
|
+ return Result::error('表单不存在');
|
|
|
+ }
|
|
|
+ unset($data['table_id']);
|
|
|
+ // 构建查询
|
|
|
+ $query = Db::connection('global')->table($globalTable->table);
|
|
|
+ $query->where('id',$data['id']);
|
|
|
+ $query->update($data);
|
|
|
+ return Result::success('修改成功');
|
|
|
+ }catch (\Throwable $e){
|
|
|
+ return Result::error('修改失败:' . $e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 查看自定义表里面的某条数据
|
|
|
+ */
|
|
|
+ public function getGlobalTableDataById(array $data): array
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ //查询
|
|
|
+ $globalTable = GlobalTable::where('id',$data['table_id'])->first();
|
|
|
+ if(empty($globalTable)){
|
|
|
+ return Result::error('表单不存在');
|
|
|
+ }
|
|
|
+ $query = Db::connection('global')->table($globalTable->table);
|
|
|
+ $query->where('id',$data['id']);
|
|
|
+ $dataInfo = $query->first();
|
|
|
+ $globalTableField = GlobalTableField::where(['table_id'=>$data['table_id']])->get();
|
|
|
+ $return = [
|
|
|
+ 'data'=>$dataInfo,
|
|
|
+ 'tableFields'=>$globalTableField->toArray(),
|
|
|
+ ];
|
|
|
+ return Result::success($return);
|
|
|
+ }catch (\Throwable $e){
|
|
|
+ return Result::error('查询失败:' . $e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|