From 008181b0798e233662b49732345b0e498b013868 Mon Sep 17 00:00:00 2001 From: Jie Zheng <201507802@qq.com> Date: Wed, 15 Jan 2025 10:30:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=BF=90=E7=BB=B4?= =?UTF-8?q?=E7=AE=A1=E7=90=86=EF=BC=9A=E6=95=B0=E6=8D=AE=E5=BA=93=E5=92=8C?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E7=AE=A1=E7=90=86=E4=B8=AD=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E4=BB=BB=E6=84=8F=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E5=92=8C?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=BC=8F=E6=B4=9E=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=9D=9E=E6=B3=95=E6=96=87=E4=BB=B6=E5=90=8D=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=20close=20https://github.com/elunez/eladmin/issues/851?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/mnt/rest/DatabaseController.java | 4 ++-- .../modules/mnt/rest/DeployController.java | 22 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DatabaseController.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DatabaseController.java index 0ce1a4e8..ded799d3 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DatabaseController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DatabaseController.java @@ -111,8 +111,8 @@ public class DatabaseController { DatabaseDto database = databaseService.findById(id); String fileName; if(database != null){ - fileName = file.getOriginalFilename(); - File executeFile = new File(fileSavePath+fileName); + fileName = FileUtil.verifyFilename(file.getOriginalFilename()); + File executeFile = new File(fileSavePath + fileName); FileUtil.del(executeFile); file.transferTo(executeFile); String result = SqlUtils.executeFile(database.getJdbcUrl(), database.getUserName(), database.getPwd(), executeFile); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DeployController.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DeployController.java index 3f13813b..161e7b5d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DeployController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DeployController.java @@ -18,6 +18,7 @@ package me.zhengjie.modules.mnt.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import me.zhengjie.annotation.Log; import me.zhengjie.modules.mnt.domain.Deploy; import me.zhengjie.modules.mnt.domain.DeployHistory; @@ -39,13 +40,13 @@ import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; -import java.util.Objects; import java.util.Set; /** * @author zhanghouying * @date 2019-08-24 */ +@Slf4j @RestController @Api(tags = "运维:部署管理") @RequiredArgsConstructor @@ -67,7 +68,7 @@ public class DeployController { @GetMapping @PreAuthorize("@el.check('deploy:list')") public ResponseEntity> queryDeployData(DeployQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(deployService.queryAll(criteria,pageable),HttpStatus.OK); + return new ResponseEntity<>(deployService.queryAll(criteria,pageable),HttpStatus.OK); } @Log("新增部署") @@ -105,21 +106,21 @@ public class DeployController { Long id = Long.valueOf(request.getParameter("id")); String fileName = ""; if(file != null){ - fileName = file.getOriginalFilename(); - File deployFile = new File(fileSavePath+fileName); + fileName = FileUtil.verifyFilename(file.getOriginalFilename()); + File deployFile = new File(fileSavePath + fileName); FileUtil.del(deployFile); file.transferTo(deployFile); //文件下一步要根据文件名字来 - deployService.deploy(fileSavePath+fileName ,id); + deployService.deploy(fileSavePath + fileName ,id); }else{ - System.out.println("没有找到相对应的文件"); + log.warn("没有找到相对应的文件"); } - System.out.println("文件上传的原名称为:"+ Objects.requireNonNull(file).getOriginalFilename()); Map map = new HashMap<>(2); - map.put("errno",0); + map.put("error",0); map.put("id",fileName); return new ResponseEntity<>(map,HttpStatus.OK); } + @Log("系统还原") @ApiOperation(value = "系统还原") @PostMapping(value = "/serverReduction") @@ -128,14 +129,16 @@ public class DeployController { String result = deployService.serverReduction(resources); return new ResponseEntity<>(result,HttpStatus.OK); } + @Log("服务运行状态") @ApiOperation(value = "服务运行状态") @PostMapping(value = "/serverStatus") @PreAuthorize("@el.check('deploy:edit')") public ResponseEntity serverStatus(@Validated @RequestBody Deploy resources){ String result = deployService.serverStatus(resources); - return new ResponseEntity<>(result,HttpStatus.OK); + return new ResponseEntity<>(result,HttpStatus.OK); } + @Log("启动服务") @ApiOperation(value = "启动服务") @PostMapping(value = "/startServer") @@ -144,6 +147,7 @@ public class DeployController { String result = deployService.startServer(resources); return new ResponseEntity<>(result,HttpStatus.OK); } + @Log("停止服务") @ApiOperation(value = "停止服务") @PostMapping(value = "/stopServer")