package com.iailab.module.model.mpk.controller.admin; import com.iailab.framework.common.page.PageData; import com.iailab.framework.common.pojo.CommonResult; import com.iailab.module.model.mpk.dto.ProjectPackageHistoryDTO; import com.iailab.module.model.mpk.dto.ProjectPackageHistoryModelDTO; import com.iailab.module.model.mpk.service.ProjectPackageHistoryModelService; import com.iailab.module.model.mpk.service.ProjectPackageHistoryService; import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.net.URLEncoder; import java.util.List; import java.util.Map; /** * 项目打包历史记录表 * * @author Dzd * @since 1.0.0 2024-08-22 */ @RestController @RequestMapping("/model/mpk/projectPackageHistory") public class ProjectPackageHistoryController { @Autowired private ProjectPackageHistoryService projectPackageHistoryService; @Autowired private ProjectPackageHistoryModelService projectPackageHistoryModelService; @GetMapping("page") public CommonResult> page(@RequestParam Map params){ PageData page = projectPackageHistoryService.page(params); return CommonResult.success(page); } @GetMapping("download") public void generat(String filePath, String fileName, HttpServletResponse response) throws IOException { byte[] data = projectPackageHistoryService.download(filePath); response.reset(); response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(fileName,"utf-8") + "\""); response.addHeader("Content-Length", "" + data.length); response.setContentType("application/octet-stream; charset=UTF-8"); IOUtils.write(data, response.getOutputStream()); } @GetMapping("getPackageModel") public CommonResult> getPackageModel(@RequestParam Map params){ PageData page = projectPackageHistoryModelService.page(params); return CommonResult.success(page); } }