From 79914dabac38d83676ea16ff65da8d941a099285 Mon Sep 17 00:00:00 2001 From: Jay <csj123456> Date: 星期二, 08 十月 2024 10:38:01 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MpkFileController.java | 35 ++++++++++++++++++++++++++++------- 1 files changed, 28 insertions(+), 7 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MpkFileController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MpkFileController.java index f172db5..f7c2e75 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MpkFileController.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MpkFileController.java @@ -8,6 +8,7 @@ import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -41,6 +42,10 @@ @GetMapping("{id}") public CommonResult<MpkFileDTO> info(@PathVariable("id") String id) { MpkFileDTO schedule = mpkFileService.get(id); + List<String> menuAndGroup = new ArrayList<>(); + menuAndGroup.add(schedule.getMenuName()); + menuAndGroup.add(schedule.getGroupName()); + schedule.setMenuAndGroup(menuAndGroup); return success(schedule); } @@ -55,6 +60,12 @@ @PreAuthorize("@ss.hasPermission('mpk:file:create')") @PostMapping public CommonResult<Boolean> save(@RequestBody MpkFileDTO dto) { + if (!CollectionUtils.isEmpty(dto.getMenuAndGroup())) { + dto.setMenuName(dto.getMenuAndGroup().get(0)); + if (dto.getMenuAndGroup().size() > 1) { + dto.setGroupName(dto.getMenuAndGroup().get(1)); + } + } mpkFileService.save(dto); return CommonResult.success(true); } @@ -69,20 +80,30 @@ @PreAuthorize("@ss.hasPermission('mpk:file:update')") @PutMapping public CommonResult<Boolean> update(@RequestBody MpkFileDTO dto) { + if (!CollectionUtils.isEmpty(dto.getMenuAndGroup())) { + dto.setMenuName(dto.getMenuAndGroup().get(0)); + if (dto.getMenuAndGroup().size() > 1) { + dto.setGroupName(dto.getMenuAndGroup().get(1)); + } + } mpkFileService.update(dto); return CommonResult.success(true); } @GetMapping("generat") - public void generat(String id, String remark,String zipFileName, HttpServletResponse response) throws IOException { - byte[] data = mpkFileService.generatorCode(id, remark,zipFileName); + public void generat(String id, String remark,String zipFileName, HttpServletResponse response) { + try { + byte[] data = mpkFileService.generatorCode(id, remark,zipFileName); - response.reset(); - response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(zipFileName, "UTF-8") + "\""); - response.addHeader("Content-Length", "" + data.length); - response.setContentType("application/octet-stream; charset=UTF-8"); + response.reset(); + response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(zipFileName, "UTF-8") + "\""); + response.addHeader("Content-Length", "" + data.length); + response.setContentType("application/octet-stream; charset=UTF-8"); - IOUtils.write(data, response.getOutputStream()); + IOUtils.write(data, response.getOutputStream()); + } catch (Exception e) { + throw new RuntimeException("代码生成异常",e); + } } @GetMapping("packageModel") -- Gitblit v1.9.3