优化巡查记录的图片回显

master
yangxiaozhong 4 weeks ago
parent 09cef02a87
commit 46222610b1

@ -84,12 +84,11 @@ public class FileServiceImpl implements FileService {
FileClient client = fileConfigService.getMasterFileClient();
Assert.notNull(client, "客户端(master) 不能为空");
String url = client.upload(content, path, type);
FileDO fileDO = new FileDO().setConfigId(client.getId())
.setName(name).setPath(path).setUrl(url)
.setType(type).setSize(content.length);
// 3. 保存到数据库
fileMapper.insert(fileDO);
return fileDO.getId().toString();
fileMapper.insert(new FileDO().setConfigId(client.getId())
.setName(name).setPath(path).setUrl(url)
.setType(type).setSize(content.length));
return url;
}
@VisibleForTesting

@ -80,16 +80,8 @@ public class DustPatrolRecordController {
public CommonResult<DustPatrolRecordRespVO> getDustPatrolRecord(@RequestParam("id") String id) {
DustPatrolRecordDO dustPatrolRecord = dustPatrolRecordService.getDustPatrolRecord(id);
DustPatrolRecordRespVO respVO = BeanUtils.toBean(dustPatrolRecord, DustPatrolRecordRespVO.class);
String[] strings = dustPatrolRecord.getPatrolPicture().split(",");
List<String> arrayList = new ArrayList<>();
for (String imgId : strings) {
CommonResult<String> urlById = fileApi.getUrlById(imgId);
if (urlById.getData()!=null){
String url = urlById.getData();
arrayList.add(url);
}
}
respVO.setPatrolPictures(arrayList);
List<String> list = Arrays.stream(dustPatrolRecord.getPatrolPicture().split(",")).toList();
respVO.setPatrolPictures(list);
return success(respVO);
}
@ -104,15 +96,8 @@ public class DustPatrolRecordController {
for (DustPatrolRecordRespVO vo : list) {
if (vo.getPatrolPicture() != null) {
List<String> strings = Arrays.stream(vo.getPatrolPicture().split(",")).toList();
List<String> urls = new ArrayList<>();
for (String id : strings) {
CommonResult<String> urlById = fileApi.getUrlById(id);
if (urlById.getData()!=null){
String url = urlById.getData();
urls.add(url);
}
}
vo.setPatrolPictures(urls);
vo.setPatrolPictures(strings);
}
}
return success(voPageResult);

@ -80,16 +80,8 @@ public class DustPatrolRectifyController {
public CommonResult<DustPatrolRectifyRespVO> getDustPatrolRectify(@RequestParam("id") String id) {
DustPatrolRectifyDO dustPatrolRectify = dustPatrolRectifyService.getDustPatrolRectify(id);
DustPatrolRectifyRespVO respVO = BeanUtils.toBean(dustPatrolRectify, DustPatrolRectifyRespVO.class);
String[] strings = dustPatrolRectify.getRectifyImg().split(",");
List<String> arrayList = new ArrayList<>();
for (String imgId : strings) {
CommonResult<String> urlById = fileApi.getUrlById(imgId);
if (urlById.getData()!=null){
String url = urlById.getData();
arrayList.add(url);
}
}
respVO.setRectifyImgs(arrayList);
List<String> list = Arrays.stream(dustPatrolRectify.getRectifyImg().split(",")).toList();
respVO.setRectifyImgs(list);
return success(respVO);
}
@ -102,15 +94,7 @@ public class DustPatrolRectifyController {
List<DustPatrolRectifyRespVO> list = result.getList();
for (DustPatrolRectifyRespVO respVO : list) {
if (respVO.getRectifyImg() != null){
List<String> strings = Arrays.stream(respVO.getRectifyImg().split(",")).toList();
List<String> urls = new ArrayList<>();
for (String id : strings) {
CommonResult<String> urlById = fileApi.getUrlById(id);
if (urlById.getData()!=null){
String url = urlById.getData();
urls.add(url);
}
}
List<String> urls = Arrays.stream(respVO.getRectifyImg().split(",")).toList();
respVO.setRectifyImgs(urls);
}
}

Loading…
Cancel
Save