mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
新增cad三维看图能力相关
This commit is contained in:
+6
@@ -8,6 +8,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -75,6 +76,11 @@ public interface FileApi {
|
||||
@Parameter(name = "path", description = "文件地址", example = "url", required = true)
|
||||
CommonResult<Boolean> deleteFileByPath(String path);
|
||||
|
||||
@DeleteMapping(PREFIX + "/{id}")
|
||||
@Operation(summary = "根据文件id删除文件")
|
||||
@Parameter(name = "id", description = "文件id", example = "123L", required = true)
|
||||
CommonResult<Boolean> deleteFileById(@PathVariable Long id);
|
||||
|
||||
@PostMapping(PREFIX + "/create/id")
|
||||
@Operation(summary = "保存文件,并返回文件id")
|
||||
CommonResult<Long> createFileAndReturnId(@Valid @RequestBody FileCreateReqDTO createReqDTO);
|
||||
|
||||
+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