hyy 5 months ago
parent
commit
275b946073

+ 3 - 1
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/dal/dataobject/specimeninfo/SpecimenInfoDO.java

@@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.museums.enums.common.SpecimenTypeEnum;
 import lombok.*;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
+import java.util.List;
+
 import com.baomidou.mybatisplus.annotation.*;
 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
 import org.springframework.stereotype.Component;
@@ -133,7 +135,7 @@ public class SpecimenInfoDO extends BaseDO {
      * 图片路径
      */
     private String imagePath;
-//    private String[] imagePath;
+//    private List<String> imagePath;
     /**
      * 入库操作员
      */

+ 31 - 4
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/service/specimeninfo/SpecimenInfoServiceImpl.java

@@ -47,14 +47,11 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
     private SpecimenOutboundMapper specimenOutboundMapper;
     @Resource
     private FileApi fileApi;
-
-
     public SpecimenInfoServiceImpl(SpecimenInfoMapper specimenInfoMapper, FileApi fileApi) {
         this.specimenInfoMapper = specimenInfoMapper;
         this.fileApi = fileApi;
     }
 
-
 //    @Override
 //    public Integer createSpecimenInfo(SpecimenInfoSaveReqVO createReqVO) {
 //        // 插入
@@ -71,22 +68,52 @@ public class SpecimenInfoServiceImpl implements SpecimenInfoService {
             throw new IllegalArgumentException("标本编号已存在,无法新增");
         }
         // 插入新标本信息
+        List<String> imagePath = createReqVO.getImagePath();
+        ObjectMapper objectMapper = new ObjectMapper();
         SpecimenInfoDO specimenInfo = BeanUtils.toBean(createReqVO, SpecimenInfoDO.class);
+        try {
+            String jsonString = objectMapper.writeValueAsString(imagePath);
+            specimenInfo.setImagePath(jsonString);
+        } catch (JsonProcessingException e) {
+            throw new RuntimeException("图像路径转换为 JSON 失败", e);
+        }
+
         specimenInfoMapper.insert(specimenInfo);
         // 返回新创建的标本ID
         return specimenInfo.getId();
     }
 
+//    @Override
+//    public void updateSpecimenInfo(SpecimenInfoSaveReqVO updateReqVO) {
+//        // 校验存在
+//        validateSpecimenInfoExists(updateReqVO.getId());
+//        // 更新
+//        SpecimenInfoDO updateObj = BeanUtils.toBean(updateReqVO, SpecimenInfoDO.class);
+//        specimenInfoMapper.updateById(updateObj);
+//    }
 
     @Override
     public void updateSpecimenInfo(SpecimenInfoSaveReqVO updateReqVO) {
         // 校验存在
         validateSpecimenInfoExists(updateReqVO.getId());
-        // 更新
+
+        // 获取图像路径列表并转换为 JSON
+        List<String> imagePath = updateReqVO.getImagePath();
+        ObjectMapper objectMapper = new ObjectMapper();
+        String jsonString;
+        try {
+            jsonString = objectMapper.writeValueAsString(imagePath);
+        } catch (JsonProcessingException e) {
+            throw new RuntimeException("图像路径转换为 JSON 失败", e);
+        }
+
+        // 更新标本信息
         SpecimenInfoDO updateObj = BeanUtils.toBean(updateReqVO, SpecimenInfoDO.class);
+        updateObj.setImagePath(jsonString); // 设置 JSON 字符串
         specimenInfoMapper.updateById(updateObj);
     }
 
+
 //    @Override
 //    public void deleteSpecimenInfo(Integer id) {
 //        // 校验存在