附属属性删除文件
This commit is contained in:
parent
472098a2d1
commit
fa5d39677d
@ -208,7 +208,7 @@ public class EquipmentController {
|
|||||||
return R.success(fileList);
|
return R.success(fileList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/file/read", method = RequestMethod.GET)
|
@RequestMapping(value = "/file/read", method = RequestMethod.POST)
|
||||||
public void readFile(String path, HttpServletResponse response) throws IOException {
|
public void readFile(String path, HttpServletResponse response) throws IOException {
|
||||||
if (StringUtils.isBlank(path)){
|
if (StringUtils.isBlank(path)){
|
||||||
throw new ServiceException("请输入浏览的文件路径");
|
throw new ServiceException("请输入浏览的文件路径");
|
||||||
@ -217,4 +217,14 @@ public class EquipmentController {
|
|||||||
sysEquipmentService.readFileToSteam(path, response.getOutputStream());
|
sysEquipmentService.readFileToSteam(path, response.getOutputStream());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/file/delete", method = RequestMethod.GET)
|
||||||
|
public void deleteFile(String path, HttpServletResponse response) throws IOException {
|
||||||
|
if (StringUtils.isBlank(path)){
|
||||||
|
throw new ServiceException("请输入浏览的文件路径");
|
||||||
|
}
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
sysEquipmentService.readFileToSteam(path, response.getOutputStream());
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,4 +45,6 @@ public interface SysEquipmentService {
|
|||||||
List<SysEquipmentDocs> getFileList(Long deviceId, String component);
|
List<SysEquipmentDocs> getFileList(Long deviceId, String component);
|
||||||
|
|
||||||
void readFileToSteam(String path, OutputStream stream);
|
void readFileToSteam(String path, OutputStream stream);
|
||||||
|
|
||||||
|
void deleteFile(String path);
|
||||||
}
|
}
|
||||||
|
@ -420,6 +420,17 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
|||||||
@Override
|
@Override
|
||||||
public void deleteSysEquipmentExtProps(Long id) {
|
public void deleteSysEquipmentExtProps(Long id) {
|
||||||
sysGenExtPropsMapper.deleteById(id);
|
sysGenExtPropsMapper.deleteById(id);
|
||||||
|
//查询设备下的所有图片
|
||||||
|
QueryWrapper<SysEquipmentDocs> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("deviceid",id);
|
||||||
|
List<SysEquipmentDocs> sysEquipmentDocsList = sysEquipmentDocsMapper.selectList(queryWrapper);
|
||||||
|
if (CollectionUtils.isNotEmpty(sysEquipmentDocsList)){
|
||||||
|
for (SysEquipmentDocs item : sysEquipmentDocsList){
|
||||||
|
deleteFile(item.getUrl());
|
||||||
|
sysEquipmentDocsMapper.deleteById(item.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -471,6 +482,19 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
|||||||
minioViewsServcie.readFileToStream(path, stream);
|
minioViewsServcie.readFileToStream(path, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteFile(String path) {
|
||||||
|
try {
|
||||||
|
minioViewsServcie.removeFile(minioAutoProperties.getPublicBucket(), path,false);
|
||||||
|
//删除缩略图
|
||||||
|
String thumbnailPath = path.replace("pic", "thumbnailPic");
|
||||||
|
minioViewsServcie.removeFile(minioAutoProperties.getPublicBucket(), thumbnailPath,false);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("文件删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public File scale(MultipartFile file) throws IOException {
|
public File scale(MultipartFile file) throws IOException {
|
||||||
// 获取原始文件名和文件类型
|
// 获取原始文件名和文件类型
|
||||||
String originalFileName = file.getOriginalFilename();
|
String originalFileName = file.getOriginalFilename();
|
||||||
|
Loading…
Reference in New Issue
Block a user