|
@@ -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) {
|
|
|
// // 校验存在
|