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