|
@@ -24,6 +24,58 @@ class WellnessRecordController extends Curd
|
|
|
$this->validateClass = new WellnessRecordValidate();
|
|
|
}
|
|
|
|
|
|
+ public function info(Request $request): Response
|
|
|
+ {
|
|
|
+ $primaryKey = $this->model->getKeyName();
|
|
|
+ $validateArr = [
|
|
|
+ $primaryKey => $request->get('id')
|
|
|
+ ];
|
|
|
+
|
|
|
+ if ($this->validate && !$this->validateClass->scene('info')->check($validateArr)) {
|
|
|
+ return json_fail($this->validateClass->getError());
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = $this->model->where($primaryKey, $request->get('id'))->first();
|
|
|
+ if ($data['wellness_record_category'] == 'Examine'){
|
|
|
+ $data->wellness_record_status = 'ACTIVED';
|
|
|
+ $data->save();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (method_exists($this, "afterInfoQuery")) {
|
|
|
+ $data = call_user_func([$this, "afterInfoQuery"], $data);
|
|
|
+ }
|
|
|
+
|
|
|
+ return json_success('', $data);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function insert(Request $request): Response
|
|
|
+ {
|
|
|
+ if ($this->validate && !$this->validateClass->scene('add')->check($request->post())) {
|
|
|
+ return json_fail($this->validateClass->getError());
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ $data = $this->insertInput($request);
|
|
|
+ if ($data['wellness_record_category'] == 'Examine' && !empty($data['wellness_record_file_json'])) {
|
|
|
+ $recordJson = json_decode($data['wellness_record_file_json'], true);
|
|
|
+ foreach ($recordJson as $file) {
|
|
|
+ unset($data['wellness_record_file_json']);
|
|
|
+ $data['wellness_record_file_json'] = json_encode($file);
|
|
|
+ $this->doInsert($data);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $this->doInsert($data);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (BusinessException $customException) {
|
|
|
+ return json_fail($customException->getMessage());
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ dump($e->getMessage());
|
|
|
+ return json_fail('数据写入失败11');
|
|
|
+ }
|
|
|
+ return json_success('success');
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @Desc 我的档案
|
|
|
* @Author Gorden
|
|
@@ -232,11 +284,23 @@ class WellnessRecordController extends Curd
|
|
|
];
|
|
|
if (!empty($item->wellness_record_file_json)) {
|
|
|
$item->wellness_record_file_json = json_decode($item->wellness_record_file_json, true);
|
|
|
- foreach ($item->wellness_record_file_json as $value) {
|
|
|
+ if (isset($item->wellness_record_file_json['file_filename']) && isset($item->wellness_record_file_json['file_savepath'])) {
|
|
|
$itemNew['wellness_record_file_json'][] = [
|
|
|
- 'url' => isset($value['url']) ? getenv('STORAGE_DOMAIN') . $value['url'] : '',
|
|
|
- 'name' => isset($value['name']) ? $value['name'] : ''
|
|
|
+ 'url' => getenv('STORAGE_DOMAIN') . $item->wellness_record_file_json['file_savepath'],
|
|
|
+ 'name' => $item->wellness_record_file_json['file_filename']
|
|
|
+ ];
|
|
|
+ } else if (isset($item->wellness_record_file_json['url']) && isset($item->wellness_record_file_json['name'])) {
|
|
|
+ $itemNew['wellness_record_file_json'][] = [
|
|
|
+ 'url' => getenv('STORAGE_DOMAIN') . $item->wellness_record_file_json['url'],
|
|
|
+ 'name' => $item->wellness_record_file_json['name']
|
|
|
];
|
|
|
+ } else {
|
|
|
+ foreach ($item->wellness_record_file_json as $value) {
|
|
|
+ $itemNew['wellness_record_file_json'][] = [
|
|
|
+ 'url' => isset($value['url']) ? getenv('STORAGE_DOMAIN') . $value['url'] : '',
|
|
|
+ 'name' => isset($value['name']) ? $value['name'] : ''
|
|
|
+ ];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -359,38 +423,30 @@ class WellnessRecordController extends Curd
|
|
|
protected function afterQuery($items)
|
|
|
{
|
|
|
foreach ($items as &$item) {
|
|
|
-// $item->wellness_record_file_json = json_decode($item->wellness_record_file_json, true);
|
|
|
-// $upload = SysUpload::whereIn('upload_file_path', $item->wellness_record_file_json)->get();
|
|
|
-// $itemNew = [];
|
|
|
-// foreach ($upload as $value) {
|
|
|
-// $itemNew['wellness_record_file_json'][] = [
|
|
|
-// 'url' => getenv('STORAGE_DOMAIN') . $value->upload_file_path,
|
|
|
-// 'name' => $value->upload_name
|
|
|
-// ];
|
|
|
-// }
|
|
|
-// $item->wellness_record_file_array = $itemNew;
|
|
|
if (!empty($item->wellness_record_file_json)) {
|
|
|
$item->wellness_record_file_json = json_decode($item->wellness_record_file_json, true);
|
|
|
$wellnessRecordFileJson = [];
|
|
|
- foreach ($item->wellness_record_file_json as $value) {
|
|
|
- if (!empty($value['url']) && !empty($value['name'])) {
|
|
|
- $wellnessRecordFileJson[] = [
|
|
|
- 'url' => getenv('STORAGE_DOMAIN') . $value['url'],
|
|
|
- 'name' => $value['name']
|
|
|
- ];
|
|
|
- //{
|
|
|
- // "ext_name": "jpg",
|
|
|
- // "file_filename": "Screenshot_20240512_182111_com.yx.WanYueWellness.jpg",
|
|
|
- // "file_savename": "file-1715511770731.jpg",
|
|
|
- // "file_savepath": "runtime/upload/MR20240511085148QZY9CQ/"
|
|
|
- //}
|
|
|
- } elseif (!empty($value['file_filename']) && !empty($value['file_savepath'])) {
|
|
|
- $wellnessRecordFileJson[] = [
|
|
|
- 'url' => getenv('STORAGE_DOMAIN') . $value['file_savepath'],
|
|
|
- 'name' => $value['file_savename']
|
|
|
- ];
|
|
|
+ if (isset($item->wellness_record_file_json['file_filename']) && isset($item->wellness_record_file_json['file_savepath'])) {
|
|
|
+ $wellnessRecordFileJson[] = [
|
|
|
+ 'url' => getenv('STORAGE_DOMAIN') . $item->wellness_record_file_json['file_savepath'],
|
|
|
+ 'name' => $item->wellness_record_file_json['file_filename']
|
|
|
+ ];
|
|
|
+ } else if (isset($item->wellness_record_file_json['url']) && isset($item->wellness_record_file_json['name'])) {
|
|
|
+ $wellnessRecordFileJson[] = [
|
|
|
+ 'url' => getenv('STORAGE_DOMAIN') . $item->wellness_record_file_json['url'],
|
|
|
+ 'name' => $item->wellness_record_file_json['name']
|
|
|
+ ];
|
|
|
+ } else {
|
|
|
+ foreach ($item->wellness_record_file_json as $value) {
|
|
|
+ if (!empty($value['url']) && !empty($value['name'])) {
|
|
|
+ $wellnessRecordFileJson[] = [
|
|
|
+ 'url' => getenv('STORAGE_DOMAIN') . $value['url'],
|
|
|
+ 'name' => $value['name']
|
|
|
+ ];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
$item->wellness_record_file_json = $wellnessRecordFileJson;
|
|
|
}
|
|
|
}
|