dengzedong
2024-10-14 3e18d4bfbf2c657b08b21512c2d884cc9d59df7b
提交 | 用户 | 时间
449017 1 package com.iailab.module.model.mpk.controller.admin;
D 2
3
4 import com.iailab.framework.common.page.PageData;
5 import com.iailab.framework.common.pojo.CommonResult;
6 import com.iailab.module.model.mpk.dto.GeneratorCodeHistoryDTO;
7 import com.iailab.module.model.mpk.service.GeneratorCodeHistoryService;
8 import org.apache.commons.io.IOUtils;
9 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.web.bind.annotation.*;
11
12 import javax.servlet.http.HttpServletResponse;
13 import java.io.IOException;
14 import java.util.Map;
15
16 import static com.iailab.framework.common.pojo.CommonResult.success;
17
18
19 /**
20  * @description: 生成代码记录表
21  * @author: dzd
22  * @date: 2024/8/20 11:49
23  **/
24 @RestController
25 @RequestMapping("/model/mpk/generatorCodeHistory")
26 public class GeneratorCodeHistoryController {
27     @Autowired
28     private GeneratorCodeHistoryService generatorCodeHistoryService;
29
30     @GetMapping("page")
31     public CommonResult<PageData<GeneratorCodeHistoryDTO>> page(@RequestParam Map<String, Object> params){
32         PageData<GeneratorCodeHistoryDTO> page = generatorCodeHistoryService.page(params);
33
34         return success(page);
35     }
36
37     @GetMapping("{id}")
558ffc 38     public CommonResult<GeneratorCodeHistoryDTO> get(@PathVariable("id") String id){
449017 39         GeneratorCodeHistoryDTO data = generatorCodeHistoryService.get(id);
D 40
41         return success(data);
42     }
43
44     @GetMapping("download")
45     public void generat(String id, HttpServletResponse response) throws IOException {
46         GeneratorCodeHistoryDTO dto = generatorCodeHistoryService.get(id);
47         byte[] data = generatorCodeHistoryService.download(dto);
48
49         response.reset();
50         response.setHeader("Content-Disposition", "attachment; filename=\"" + dto.getFileName() + "\"");
51         response.addHeader("Content-Length", "" + data.length);
52         response.setContentType("application/octet-stream; charset=UTF-8");
53
54         IOUtils.write(data, response.getOutputStream());
55     }
56
57 }