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