mpk
dengzedong
2024-09-12 449017535241b56997db62daa8935a6db5bef44a
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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") Long id){
        GeneratorCodeHistoryDTO data = generatorCodeHistoryService.get(id);
 
        return success(data);
    }
 
    @PostMapping
    public CommonResult save(@RequestBody GeneratorCodeHistoryDTO dto){
 
        generatorCodeHistoryService.save(dto);
 
        return CommonResult.success();
    }
 
    @PutMapping
    public CommonResult update(@RequestBody GeneratorCodeHistoryDTO dto){
 
        generatorCodeHistoryService.update(dto);
 
        return CommonResult.success();
    }
 
    @DeleteMapping
    public CommonResult delete(@RequestBody Long[] ids){
 
        generatorCodeHistoryService.delete(ids);
 
        return CommonResult.success();
    }
 
    @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());
    }
 
}