|
@@ -3,7 +3,6 @@ package cn.com.yusys.yusp.controller;
|
|
|
import cn.com.yusys.yusp.annotation.ApiOperationType;
|
|
import cn.com.yusys.yusp.annotation.ApiOperationType;
|
|
|
import cn.com.yusys.yusp.commons.exception.BizException;
|
|
import cn.com.yusys.yusp.commons.exception.BizException;
|
|
|
import cn.com.yusys.yusp.commons.module.adapter.web.rest.ResultDto;
|
|
import cn.com.yusys.yusp.commons.module.adapter.web.rest.ResultDto;
|
|
|
-import cn.com.yusys.yusp.util.SessionCommonUtil;
|
|
|
|
|
import cn.com.yusys.yusp.domain.dto.TagInfoDto;
|
|
import cn.com.yusys.yusp.domain.dto.TagInfoDto;
|
|
|
import cn.com.yusys.yusp.domain.entity.AitagTagInfoEntity;
|
|
import cn.com.yusys.yusp.domain.entity.AitagTagInfoEntity;
|
|
|
import cn.com.yusys.yusp.domain.vo.AitagTagInfoQueryVo;
|
|
import cn.com.yusys.yusp.domain.vo.AitagTagInfoQueryVo;
|
|
@@ -31,9 +30,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
-import java.nio.file.Files;
|
|
|
|
|
-import java.nio.file.Path;
|
|
|
|
|
-import java.nio.file.Paths;
|
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -242,15 +238,11 @@ public class AitagTagInfoController {
|
|
|
@GetMapping("/downloadFile")
|
|
@GetMapping("/downloadFile")
|
|
|
public ResponseEntity<Resource> downloadFile( ) throws IOException {
|
|
public ResponseEntity<Resource> downloadFile( ) throws IOException {
|
|
|
|
|
|
|
|
- // 1. 构造文件路径并进行规范化,防止路径遍历攻击 (如 ../../恶意路径)
|
|
|
|
|
- Path filePath = Paths.get("template").resolve("tag_batch_Import_template.xlsx").normalize();
|
|
|
|
|
- ClassPathResource resource = new ClassPathResource(filePath.toString());
|
|
|
|
|
-
|
|
|
|
|
|
|
+ ClassPathResource resource = new ClassPathResource("template/tag_batch_Import_template.xlsx");
|
|
|
// 2. 校验文件是否存在且可读
|
|
// 2. 校验文件是否存在且可读
|
|
|
if (resource.exists() && resource.isReadable()) {
|
|
if (resource.exists() && resource.isReadable()) {
|
|
|
// 3. 推断文件的 MediaType (MIME type)
|
|
// 3. 推断文件的 MediaType (MIME type)
|
|
|
- String contentType = MediaType.APPLICATION_OCTET_STREAM_VALUE;
|
|
|
|
|
- contentType = Files.probeContentType(filePath);
|
|
|
|
|
|
|
+ String contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
|
// 4. 返回 ResponseEntity,设置响应头
|
|
// 4. 返回 ResponseEntity,设置响应头
|
|
|
return ResponseEntity.ok()
|
|
return ResponseEntity.ok()
|
|
|
.contentType(MediaType.parseMediaType(contentType))
|
|
.contentType(MediaType.parseMediaType(contentType))
|