提交 | 用户 | 时间
|
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}") |
|
38 |
public CommonResult<GeneratorCodeHistoryDTO> get(@PathVariable("id") Long id){ |
|
39 |
GeneratorCodeHistoryDTO data = generatorCodeHistoryService.get(id); |
|
40 |
|
|
41 |
return success(data); |
|
42 |
} |
|
43 |
|
|
44 |
@PostMapping |
|
45 |
public CommonResult save(@RequestBody GeneratorCodeHistoryDTO dto){ |
|
46 |
|
|
47 |
generatorCodeHistoryService.save(dto); |
|
48 |
|
|
49 |
return CommonResult.success(); |
|
50 |
} |
|
51 |
|
|
52 |
@PutMapping |
|
53 |
public CommonResult update(@RequestBody GeneratorCodeHistoryDTO dto){ |
|
54 |
|
|
55 |
generatorCodeHistoryService.update(dto); |
|
56 |
|
|
57 |
return CommonResult.success(); |
|
58 |
} |
|
59 |
|
|
60 |
@DeleteMapping |
|
61 |
public CommonResult delete(@RequestBody Long[] ids){ |
|
62 |
|
|
63 |
generatorCodeHistoryService.delete(ids); |
|
64 |
|
|
65 |
return CommonResult.success(); |
|
66 |
} |
|
67 |
|
|
68 |
@GetMapping("download") |
|
69 |
public void generat(String id, HttpServletResponse response) throws IOException { |
|
70 |
GeneratorCodeHistoryDTO dto = generatorCodeHistoryService.get(id); |
|
71 |
byte[] data = generatorCodeHistoryService.download(dto); |
|
72 |
|
|
73 |
response.reset(); |
|
74 |
response.setHeader("Content-Disposition", "attachment; filename=\"" + dto.getFileName() + "\""); |
|
75 |
response.addHeader("Content-Length", "" + data.length); |
|
76 |
response.setContentType("application/octet-stream; charset=UTF-8"); |
|
77 |
|
|
78 |
IOUtils.write(data, response.getOutputStream()); |
|
79 |
} |
|
80 |
|
|
81 |
} |