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 f2ff0a19..c18395d7 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 @@ -49,7 +49,7 @@ import java.util.Set; @RequestMapping("/api/database") public class DatabaseController { - private final String fileSavePath = System.getProperty("java.io.tmpdir"); + private final String fileSavePath = FileUtil.getTmpDirPath()+"/"; private final DatabaseService databaseService; @Log("导出数据库数据") 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 31a0cb48..7b11b8db 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 @@ -50,7 +50,7 @@ import java.util.Set; @RequestMapping("/api/deploy") public class DeployController { - private final String fileSavePath = System.getProperty("java.io.tmpdir"); + private final String fileSavePath = FileUtil.getTmpDirPath()+"/"; private final DeployService deployService; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java index 783edec8..e3e2ab54 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java @@ -28,7 +28,10 @@ import me.zhengjie.modules.mnt.repository.DeployRepository; import me.zhengjie.modules.mnt.service.DeployHistoryService; import me.zhengjie.modules.mnt.service.DeployService; import me.zhengjie.modules.mnt.service.ServerDeployService; -import me.zhengjie.modules.mnt.service.dto.*; +import me.zhengjie.modules.mnt.service.dto.AppDto; +import me.zhengjie.modules.mnt.service.dto.DeployDto; +import me.zhengjie.modules.mnt.service.dto.DeployQueryCriteria; +import me.zhengjie.modules.mnt.service.dto.ServerDeployDto; import me.zhengjie.modules.mnt.service.mapstruct.DeployMapper; import me.zhengjie.modules.mnt.util.ExecuteShellUtil; import me.zhengjie.modules.mnt.util.ScpClientUtil; @@ -41,6 +44,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; + import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.*; @@ -155,7 +159,7 @@ public class DeployServiceImpl implements DeployService { stopApp(port, executeShellUtil); sendMsg("备份原来应用", MsgType.INFO); //备份应用 - backupApp(executeShellUtil, ip, app.getDeployPath(), app.getName(), app.getBackupPath(), id); + backupApp(executeShellUtil, ip, app.getDeployPath()+FILE_SEPARATOR, app.getName(), app.getBackupPath()+FILE_SEPARATOR, id); } sendMsg("部署应用", MsgType.INFO); //部署文件,并启动应用 @@ -191,16 +195,9 @@ public class DeployServiceImpl implements DeployService { private void backupApp(ExecuteShellUtil executeShellUtil, String ip, String fileSavePath, String appName, String backupPath, Long id) { String deployDate = DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN); StringBuilder sb = new StringBuilder(); - String endsWith = "\\"; - if (!backupPath.endsWith(FILE_SEPARATOR)&&!backupPath.endsWith(endsWith)) { - backupPath += FILE_SEPARATOR; - } backupPath += appName + FILE_SEPARATOR + deployDate + "\n"; sb.append("mkdir -p ").append(backupPath); sb.append("mv -f ").append(fileSavePath); - if (!fileSavePath.endsWith(FILE_SEPARATOR)) { - sb.append(FILE_SEPARATOR); - } sb.append(appName).append(" ").append(backupPath); log.info("备份应用脚本:" + sb.toString()); executeShellUtil.execute(sb.toString()); @@ -350,10 +347,7 @@ public class DeployServiceImpl implements DeployService { sendMsg("应用信息不存在:" + resources.getAppName(), MsgType.ERROR); throw new BadRequestException("应用信息不存在:" + resources.getAppName()); } - String backupPath = app.getBackupPath(); - if (!backupPath.endsWith(FILE_SEPARATOR)) { - backupPath += FILE_SEPARATOR; - } + String backupPath = app.getBackupPath()+FILE_SEPARATOR; backupPath += resources.getAppName() + FILE_SEPARATOR + deployDate; //这个是服务器部署路径 String deployPath = app.getDeployPath(); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ScpClientUtil.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ScpClientUtil.java index 0348790a..238b7c10 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ScpClientUtil.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ScpClientUtil.java @@ -31,18 +31,18 @@ public class ScpClientUtil { static private ScpClientUtil instance; - static synchronized public ScpClientUtil getInstance(String ip, int port, String username, String passward) { + static synchronized public ScpClientUtil getInstance(String ip, int port, String username, String password) { if (instance == null) { - instance = new ScpClientUtil(ip, port, username, passward); + instance = new ScpClientUtil(ip, port, username, password); } return instance; } - public ScpClientUtil(String ip, int port, String username, String passward) { + public ScpClientUtil(String ip, int port, String username, String password) { this.ip = ip; this.port = port; this.username = username; - this.password = passward; + this.password = password; } public void getFile(String remoteFile, String localTargetDirectory) {