123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- package cn.cslg.pas.controller;
- import cn.cslg.pas.common.AAA;
- import cn.cslg.pas.common.core.annotation.Permission;
- import cn.cslg.pas.common.core.base.Constants;
- import cn.cslg.pas.common.model.vo.PatentInstructionVO;
- import cn.cslg.pas.common.utils.FileUtils;
- import cn.cslg.pas.common.utils.Response;
- import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
- import cn.cslg.pas.common.utils.auth.checkAuth;
- import cn.cslg.pas.domain.PatentInstruction;
- import cn.cslg.pas.service.PatentInstructionService;
- import cn.cslg.pas.service.patentPDF.PatentPDFService;
- import cn.hutool.core.io.FileUtil;
- import cn.hutool.core.io.IoUtil;
- import io.swagger.v3.oas.annotations.Operation;
- import io.swagger.v3.oas.annotations.tags.Tag;
- import lombok.RequiredArgsConstructor;
- import org.springframework.context.annotation.Lazy;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import javax.servlet.ServletOutputStream;
- import javax.servlet.http.HttpServletResponse;
- import java.io.IOException;
- import java.util.List;
- /**
- * <p>
- * 专利说明书 前端控制器
- * </p>
- *
- * @author 王岩
- * @since 2022-03-02
- */
- @Tag(name = "专利说明书")
- @RestController
- @RequestMapping(Constants.API_VERSION_V2 + "/patent/instruction")
- @RequiredArgsConstructor(onConstructor_ = {@Lazy})
- public class PatentInstructionController {
- private final PatentInstructionService patentInstructionService;
- private final PatentPDFService patentPDFService;
- private final FileUtils fileUtils;
- private final LoginUtils loginUtils;
- @GetMapping("list")
- @Operation(summary = "说明书列表")
- public String getPageList(PatentInstructionVO params) {
- return Response.success(patentInstructionService.getPageList(params));
- }
- @checkAuth(FunId = "/workspace/folder/batchUploadSpecification")
- @PostMapping("/batch/upload")
- @Operation(summary = "批量上传说明书")
- public String batchUpload(String url, Integer type, String remark) throws IOException {
- patentInstructionService.batchUpload(url, type, remark, loginUtils.getId());
- return Response.success(true);
- }
- @Permission(roles = {1, 2})
- @PostMapping("add")
- @Operation(summary = "新增说明书")
- public String add(MultipartFile file, PatentInstruction patentInstruction) {
- return patentInstructionService.add(file, patentInstruction);
- }
- @checkAuth(FunId = "/workspace/details/updataInstruction")
- @PostMapping("edit")
- @Operation(summary = "编辑说明书")
- public String edit(MultipartFile file, PatentInstruction patentInstruction) {
- return patentInstructionService.edit(file, patentInstruction);
- }
- @Permission(roles = {1, 2})
- @PostMapping("delete")
- @Operation(summary = "删除说明书")
- public String delete(Integer id) {
- return patentInstructionService.delete(id);
- }
- @PostMapping("file")
- @Operation(summary = "获取说明书文件流")
- public void pdfFile(String patentNo, Integer type, HttpServletResponse response) {
- try {
- PatentInstruction patentInstruction = patentInstructionService.getPatentInstructionByPatentNoAndType(patentNo, type);
- if (patentInstruction != null) {
- response.setHeader("Content-Disposition", "attachment;filename=" + patentInstruction.getFileName());
- ServletOutputStream out = response.getOutputStream();
- // out.write(FileUtil.readBytes(fileUtils.getSystemPath(patentInstruction.getUrl())));
- String fil = fileUtils.getSystemPath() + patentInstruction.getUrl();
- out.write(FileUtil.readBytes(fil));
- IoUtil.close(out);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- @PostMapping("/pdfFirstPage")
- @Operation(summary = "获取说明书首页")
- public void pdfFileFirstPage(@RequestBody AAA aaa) throws IOException {
- patentPDFService.queryPatentPdfFirstPages(aaa.getPatentNos());
- }
- }
|