mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-14 13:42:07 +08:00
新增cad三维看图能力相关
This commit is contained in:
+6
@@ -28,6 +28,12 @@ public class FileApiImpl implements FileApi {
|
||||
return success(fileService.deleteFileByPath(path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteFileById(Long id) {
|
||||
fileService.deleteFile(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Long> createFileAndReturnId(FileCreateReqDTO createReqDTO) {
|
||||
return success(fileService.createFileDO(createReqDTO.getName(), createReqDTO.getPath(),
|
||||
|
||||
+24
@@ -50,6 +50,14 @@ public class FileController {
|
||||
return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
|
||||
}
|
||||
|
||||
@PostMapping("/cadview")
|
||||
@Operation(summary = "上传CAD图纸数据")
|
||||
@OperateLog(logArgs = false) // 上传文件,没有记录操作日志的必要
|
||||
public CommonResult<Long> uploadCadViewFile(@RequestPart("file") MultipartFile file) throws Exception {
|
||||
return success(fileService.createFileDO("cadViewFile", null, file.getBytes()));
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除文件")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@@ -101,6 +109,22 @@ public class FileController {
|
||||
ServletUtils.writeAttachment(response, String.valueOf(id), content);
|
||||
}
|
||||
|
||||
@GetMapping("/txt/{id}")
|
||||
@Operation(summary = "根据文件编号下载文本文件")
|
||||
@Parameter(name = "id", description = "文件编号", required = true)
|
||||
@OperateLog(enable = false)
|
||||
@PermitAll
|
||||
public void getTxtFileContentById(HttpServletResponse response,
|
||||
@PathVariable("id") Long id) throws Exception {
|
||||
byte[] content = fileService.getFileById(id);
|
||||
if (content == null) {
|
||||
log.warn("[getFileContent][id({}) 文件不存在]", id);
|
||||
response.setStatus(HttpStatus.NOT_FOUND.value());
|
||||
return;
|
||||
}
|
||||
ServletUtils.writeAttachmentText(response, String.valueOf(id), content);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得文件分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file:query')")
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ public interface FileService {
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteFile(Long id) throws Exception;
|
||||
void deleteFile(Long id);
|
||||
|
||||
/**
|
||||
* 获得文件内容
|
||||
|
||||
+6
-2
@@ -105,14 +105,18 @@ public class FileServiceImpl implements FileService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFile(Long id) throws Exception {
|
||||
public void deleteFile(Long id) {
|
||||
// 校验存在
|
||||
FileDO file = validateFileExists(id);
|
||||
|
||||
// 从文件存储器中删除
|
||||
FileClient client = fileConfigService.getFileClient(file.getConfigId());
|
||||
Assert.notNull(client, CLIENT_ERR_NOTIFICATION, file.getConfigId());
|
||||
client.delete(file.getPath());
|
||||
try {
|
||||
client.delete(file.getPath());
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(FILE_REMOVE_FAIL);
|
||||
}
|
||||
|
||||
// 删除记录
|
||||
fileMapper.deleteById(id);
|
||||
|
||||
Reference in New Issue
Block a user