|
@ -0,0 +1,78 @@ |
|
|
|
|
|
package com.inscloudtech.functional.controller; |
|
|
|
|
|
|
|
|
|
|
|
import com.inscloudtech.common.annotation.RepeatSubmit; |
|
|
|
|
|
import com.inscloudtech.common.config.ProjectConfig; |
|
|
|
|
|
import com.inscloudtech.common.core.controller.BaseController; |
|
|
|
|
|
import com.inscloudtech.common.core.domain.PageQuery; |
|
|
|
|
|
import com.inscloudtech.common.core.domain.R; |
|
|
|
|
|
import com.inscloudtech.common.core.page.TableDataInfo; |
|
|
|
|
|
import com.inscloudtech.common.core.validate.AddGroup; |
|
|
|
|
|
import com.inscloudtech.common.utils.StringUtils; |
|
|
|
|
|
import com.inscloudtech.common.utils.file.FileUtils; |
|
|
|
|
|
import com.inscloudtech.functional.domain.FuncCarApi; |
|
|
|
|
|
import com.inscloudtech.functional.service.IFuncCarApiService; |
|
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
|
import org.springframework.http.MediaType; |
|
|
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 测试工具及操纵手册下载 |
|
|
|
|
|
* |
|
|
|
|
|
* @author inscloudtech |
|
|
|
|
|
* @date 2024-06-11 |
|
|
|
|
|
*/ |
|
|
|
|
|
@RequiredArgsConstructor |
|
|
|
|
|
@RestController |
|
|
|
|
|
@RequestMapping("/functional/toolDownLoad") |
|
|
|
|
|
public class ToolDownLoadController extends BaseController { |
|
|
|
|
|
|
|
|
|
|
|
private final ProjectConfig projectConfig; |
|
|
|
|
|
|
|
|
|
|
|
private final static String CPU_SHIPEI_TEST_TOOL = "CUP适配测试工具.zip"; |
|
|
|
|
|
|
|
|
|
|
|
private final static String CPU_SHIPEI_TEST_TIPS = "CPU适配测试工具操作手册.zip"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* CUP适配测试工具测试工具下载 |
|
|
|
|
|
*/ |
|
|
|
|
|
@GetMapping("/cpuShipeiTestTooldownload") |
|
|
|
|
|
public void cpuShipeiTestTooldownload(HttpServletResponse response, HttpServletRequest request) { |
|
|
|
|
|
doDownLoad(CPU_SHIPEI_TEST_TOOL,response); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* CPU适配测试工具操作手册下载 |
|
|
|
|
|
*/ |
|
|
|
|
|
@GetMapping("/cpuShipeiTestTipsdownload") |
|
|
|
|
|
public void cpuShipeiTestTipsdownload(HttpServletResponse response, HttpServletRequest request) { |
|
|
|
|
|
doDownLoad(CPU_SHIPEI_TEST_TIPS,response); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void doDownLoad(String filename,HttpServletResponse response){ |
|
|
|
|
|
try { |
|
|
|
|
|
if (!FileUtils.checkAllowDownload(filename)) { |
|
|
|
|
|
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", filename)); |
|
|
|
|
|
} |
|
|
|
|
|
String realFileName = System.currentTimeMillis() + filename.substring(filename.indexOf("_") + 1); |
|
|
|
|
|
String filePath = projectConfig.getDownloadPath() + filename; |
|
|
|
|
|
|
|
|
|
|
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
|
|
|
|
|
FileUtils.setAttachmentResponseHeader(response, realFileName); |
|
|
|
|
|
FileUtils.writeBytes(filePath, response.getOutputStream()); |
|
|
|
|
|
// if (delete) { |
|
|
|
|
|
// FileUtils.deleteFile(filePath); |
|
|
|
|
|
// } |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |