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());
|
}
|
|
}
|