Bläddra i källkod

feat:健康档案-历史档案

caoliqin 4 dagar sedan
förälder
incheckning
31c35c3115

+ 10 - 1
fs-user-app/src/main/java/com/fs/app/controller/HealthRecordController.java

@@ -1,5 +1,7 @@
 package com.fs.app.controller;
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.bean.copier.CopyOptions;
 import com.fs.app.annotation.Login;
 import com.fs.common.BeanCopyUtils;
 import com.fs.common.annotation.RepeatSubmit;
@@ -29,6 +31,7 @@ import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.collections4.map.HashedMap;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -154,7 +157,13 @@ public class HealthRecordController extends AppBaseController
         if (existing == null) {
             return R.error("请先新增健康档案");
         }
-        FsHealthRecord fsHealthRecord = BeanCopyUtils.copy(param, FsHealthRecord.class);
+        FsHealthRecord fsHealthRecord = new FsHealthRecord();
+        // 将existing的值复制到fsHealthRecord
+        BeanCopyUtils.copy(existing, fsHealthRecord);
+        CopyOptions copyOptions = CopyOptions.create()
+                .setIgnoreNullValue(true);
+        BeanUtil.copyProperties(param, fsHealthRecord, copyOptions);
+
         int rows = fsHealthRecordService.insertFsHealthRecordNewVersion(fsHealthRecord, userId);
         if (rows <= 0) {
             return R.error("修改健康档案失败");