mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-02 20:08:40 +08:00
项目文件管理调整为支持清空当前目录
This commit is contained in:
parent
e64f3bb19a
commit
a4c382f68c
@ -15,6 +15,7 @@
|
||||
4. 【server】节点升级中远程下载插件包存储路径更改,并优化更新包后页面显示问题(感谢@hu丶向...🤡)
|
||||
5. 脚本模版新增描述字段(感谢@ʟᴊx💎💎)
|
||||
6. 在线升级取消重复 jar 包判断,改为自动重命名(感谢@大土豆)
|
||||
7. 项目文件管理调整为支持清空当前目录(感谢@ʟᴊx💎💎)
|
||||
|
||||
------
|
||||
|
||||
|
@ -288,9 +288,14 @@ public class ProjectFileControl extends BaseAgentController {
|
||||
@RequestMapping(value = "deleteFile", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String deleteFile(String filename, String type, String levelName) {
|
||||
NodeProjectInfoModel pim = getProjectInfoModel();
|
||||
File file;
|
||||
if (StrUtil.isEmpty(levelName)) {
|
||||
file = FileUtil.file(pim.allLib());
|
||||
} else {
|
||||
file = FileUtil.file(pim.allLib(), levelName);
|
||||
}
|
||||
if ("clear".equalsIgnoreCase(type)) {
|
||||
// 清空文件
|
||||
File file = new File(pim.allLib());
|
||||
if (FileUtil.clean(file)) {
|
||||
return JsonMessage.getString(200, "清除成功");
|
||||
}
|
||||
@ -300,13 +305,8 @@ public class ProjectFileControl extends BaseAgentController {
|
||||
} else {
|
||||
// 删除文件
|
||||
Assert.hasText(filename, "请选择要删除的文件");
|
||||
file = FileUtil.file(file, filename);
|
||||
|
||||
File file;
|
||||
if (StrUtil.isEmpty(levelName)) {
|
||||
file = FileUtil.file(pim.allLib(), filename);
|
||||
} else {
|
||||
file = FileUtil.file(pim.allLib(), levelName, filename);
|
||||
}
|
||||
if (file.exists()) {
|
||||
if (FileUtil.del(file)) {
|
||||
return JsonMessage.getString(200, "删除成功");
|
||||
|
@ -25,6 +25,7 @@ package io.jpom.service.h2db;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.PageUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@ -38,6 +39,7 @@ import cn.jiangzeyin.common.DefaultSystemLog;
|
||||
import io.jpom.model.PageResultDto;
|
||||
import io.jpom.system.JpomRuntimeException;
|
||||
import io.jpom.system.db.DbConfig;
|
||||
import org.h2.jdbc.JdbcSQLNonTransientException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.sql.SQLException;
|
||||
@ -119,8 +121,8 @@ public abstract class BaseDbCommonService<T> {
|
||||
try {
|
||||
Entity entity = this.dataBeanToEntity(t);
|
||||
db.insert(entity);
|
||||
} catch (SQLException e) {
|
||||
throw new JpomRuntimeException("数据库异常", e);
|
||||
} catch (Exception e) {
|
||||
throw warpException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,8 +145,8 @@ public abstract class BaseDbCommonService<T> {
|
||||
try {
|
||||
List<Entity> entities = t.stream().map(this::dataBeanToEntity).collect(Collectors.toList());
|
||||
db.insert(entities);
|
||||
} catch (SQLException e) {
|
||||
throw new JpomRuntimeException("数据库异常", e);
|
||||
} catch (Exception e) {
|
||||
throw warpException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,8 +181,8 @@ public abstract class BaseDbCommonService<T> {
|
||||
entity.setTableName(tableName);
|
||||
try {
|
||||
return db.insert(entity);
|
||||
} catch (SQLException e) {
|
||||
throw new JpomRuntimeException("数据库异常", e);
|
||||
} catch (Exception e) {
|
||||
throw warpException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,8 +218,8 @@ public abstract class BaseDbCommonService<T> {
|
||||
where.setTableName(tableName);
|
||||
try {
|
||||
return db.update(entity, where);
|
||||
} catch (SQLException e) {
|
||||
throw new JpomRuntimeException("数据库异常", e);
|
||||
} catch (Exception e) {
|
||||
throw warpException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,8 +268,8 @@ public abstract class BaseDbCommonService<T> {
|
||||
Entity entity;
|
||||
try {
|
||||
entity = db.get(where);
|
||||
} catch (SQLException e) {
|
||||
throw new JpomRuntimeException("数据库异常", e);
|
||||
} catch (Exception e) {
|
||||
throw warpException(e);
|
||||
}
|
||||
T entityToBean = this.entityToBean(entity, this.tClass);
|
||||
if (fill) {
|
||||
@ -369,8 +371,8 @@ public abstract class BaseDbCommonService<T> {
|
||||
db.setWrapper((Character) null);
|
||||
try {
|
||||
return db.del(where);
|
||||
} catch (SQLException e) {
|
||||
throw new JpomRuntimeException("数据库异常", e);
|
||||
} catch (Exception e) {
|
||||
throw warpException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -413,8 +415,8 @@ public abstract class BaseDbCommonService<T> {
|
||||
db.setWrapper((Character) null);
|
||||
try {
|
||||
return db.count(where);
|
||||
} catch (SQLException e) {
|
||||
throw new JpomRuntimeException("数据库异常", e);
|
||||
} catch (Exception e) {
|
||||
throw warpException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -446,8 +448,8 @@ public abstract class BaseDbCommonService<T> {
|
||||
db.setWrapper((Character) null);
|
||||
try {
|
||||
return db.find(where);
|
||||
} catch (SQLException e) {
|
||||
throw new JpomRuntimeException("数据库异常", e);
|
||||
} catch (Exception e) {
|
||||
throw warpException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -531,8 +533,8 @@ public abstract class BaseDbCommonService<T> {
|
||||
}
|
||||
try {
|
||||
return Db.use().query(sql, params);
|
||||
} catch (SQLException e) {
|
||||
throw new JpomRuntimeException("数据库异常", e);
|
||||
} catch (Exception e) {
|
||||
throw warpException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -551,8 +553,8 @@ public abstract class BaseDbCommonService<T> {
|
||||
}
|
||||
try {
|
||||
return Db.use().execute(sql, params);
|
||||
} catch (SQLException e) {
|
||||
throw new JpomRuntimeException("数据库异常", e);
|
||||
} catch (Exception e) {
|
||||
throw warpException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -620,4 +622,16 @@ public abstract class BaseDbCommonService<T> {
|
||||
*/
|
||||
protected void fillSelectResult(T data) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 包裹异常
|
||||
*
|
||||
* @param e 异常
|
||||
*/
|
||||
protected JpomRuntimeException warpException(Exception e) {
|
||||
if (ExceptionUtil.isCausedBy(e, JdbcSQLNonTransientException.class)) {
|
||||
return new JpomRuntimeException("数据库异常,可能数据库文件已经损坏,需要重新初始化:" + e.getMessage(), e);
|
||||
}
|
||||
return new JpomRuntimeException("数据库异常", e);
|
||||
}
|
||||
}
|
||||
|
@ -33,3 +33,6 @@ ALTER TABLE SCRIPT_EXECUTE_LOG
|
||||
|
||||
ALTER TABLE NODE_INFO
|
||||
ADD IF NOT EXISTS `group` VARCHAR(50) comment '分组名称';
|
||||
|
||||
ALTER TABLE SCRIPT_INFO
|
||||
ADD IF NOT EXISTS description varchar(255) comment '描述';
|
||||
|
@ -42,12 +42,12 @@
|
||||
</span>
|
||||
</a-timeline-item>
|
||||
</a-timeline>
|
||||
<a-spin v-if="!temp.debug" :spinning="spinning">
|
||||
<a-upload :file-list="fileList" :remove="handleRemove" :before-upload="beforeUpload" accept=".jar,.zip">
|
||||
<a-button><a-icon type="upload" />选择升级文件</a-button>
|
||||
</a-upload>
|
||||
<a-button type="primary" class="upload-btn" :disabled="fileList.length === 0" @click="startUpload">上传升级文件</a-button>
|
||||
</a-spin>
|
||||
|
||||
<a-upload :file-list="fileList" :remove="handleRemove" :before-upload="beforeUpload" accept=".jar,.zip">
|
||||
<a-button><a-icon type="upload" />选择升级文件</a-button>
|
||||
</a-upload>
|
||||
<a-button type="primary" class="upload-btn" :disabled="fileList.length === 0" @click="startUpload">上传升级文件</a-button>
|
||||
|
||||
<a-divider dashed />
|
||||
<markdown-it-vue class="md-body" :content="changelog" :options="markdownOptions" />
|
||||
</div>
|
||||
@ -73,7 +73,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
temp: {},
|
||||
spinning: false,
|
||||
|
||||
checkCount: 0,
|
||||
fileList: [],
|
||||
timer: null,
|
||||
@ -139,7 +139,6 @@ export default {
|
||||
},
|
||||
// 开始上传文件
|
||||
startUpload() {
|
||||
this.spinning = true;
|
||||
const formData = new FormData();
|
||||
formData.append("file", this.fileList[0]);
|
||||
formData.append("nodeId", this.nodeId);
|
||||
@ -152,7 +151,6 @@ export default {
|
||||
|
||||
this.startCheckUpgradeStatus(res.msg);
|
||||
}
|
||||
this.spinning = false;
|
||||
});
|
||||
this.fileList = [];
|
||||
},
|
||||
@ -237,8 +235,7 @@ export default {
|
||||
okText: "确认",
|
||||
cancelText: "取消",
|
||||
onOk: () => {
|
||||
// 重新发布
|
||||
this.spinning = true;
|
||||
//
|
||||
remoteUpgrade(this.nodeId).then((res) => {
|
||||
if (res.code === 200) {
|
||||
this.$notification.success({
|
||||
@ -247,7 +244,6 @@ export default {
|
||||
|
||||
this.startCheckUpgradeStatus(res.msg);
|
||||
}
|
||||
this.spinning = false;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
@ -36,12 +36,12 @@
|
||||
<a-tooltip slot="fileSize" slot-scope="text" placement="topLeft" :title="text">
|
||||
<span>{{ text }}</span>
|
||||
</a-tooltip>
|
||||
<template slot="operation" v-if="!record.isDirectory" slot-scope="text, record">
|
||||
<template slot="operation" slot-scope="text, record">
|
||||
<a-space>
|
||||
<a-tooltip title="需要到 节点管理中的系统管理的白名单配置中配置允许编辑的文件后缀">
|
||||
<a-tooltip v-if="!record.isDirectory" title="需要到 节点管理中的系统管理的白名单配置中配置允许编辑的文件后缀">
|
||||
<a-button type="primary" :disabled="!record.textFileEdit" @click="handleEditFile(record)">编辑</a-button>
|
||||
</a-tooltip>
|
||||
<a-button type="primary" @click="handleDownload(record)">下载</a-button>
|
||||
<a-button v-if="!record.isDirectory" type="primary" @click="handleDownload(record)">下载</a-button>
|
||||
<a-button type="danger" @click="handleDelete(record)">删除</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
@ -508,9 +508,10 @@ export default {
|
||||
},
|
||||
// 清空文件
|
||||
clearFile() {
|
||||
const msg = this.uploadPath ? "真的要清空 【" + this.uploadPath + "】目录和文件么?" : "真的要清空项目目录和文件么?";
|
||||
this.$confirm({
|
||||
title: "系统提示",
|
||||
content: "真的要清空项目目录和文件么?",
|
||||
content: msg,
|
||||
okText: "确认",
|
||||
cancelText: "取消",
|
||||
onOk: () => {
|
||||
@ -519,6 +520,7 @@ export default {
|
||||
nodeId: this.nodeId,
|
||||
id: this.projectId,
|
||||
type: "clear",
|
||||
levelName: this.uploadPath,
|
||||
};
|
||||
// 删除
|
||||
deleteProjectFile(params).then((res) => {
|
||||
@ -557,9 +559,10 @@ export default {
|
||||
},
|
||||
// 删除
|
||||
handleDelete(record) {
|
||||
const msg = record.isDirectory ? "真的要删除【" + record.filename + "】文件夹么?" : "真的要删除【" + record.filename + "】文件么?";
|
||||
this.$confirm({
|
||||
title: "系统提示",
|
||||
content: "真的要删除文件么?",
|
||||
content: msg,
|
||||
okText: "确认",
|
||||
cancelText: "取消",
|
||||
onOk: () => {
|
||||
|
@ -302,11 +302,19 @@ export default {
|
||||
});
|
||||
},
|
||||
updateNode() {
|
||||
this.sendMsg("updateNode", {
|
||||
ids: this.tableSelections,
|
||||
protocol: this.temp.protocol,
|
||||
this.$confirm({
|
||||
title: "系统提示",
|
||||
content: "确认要升级到最新版本吗?,升级前请阅读更新日志里面的说明和注意事项并且请注意备份数据防止数据丢失!!",
|
||||
okText: "确认",
|
||||
cancelText: "取消",
|
||||
onOk: () => {
|
||||
this.sendMsg("updateNode", {
|
||||
ids: this.tableSelections,
|
||||
protocol: this.temp.protocol,
|
||||
});
|
||||
this.tableSelections = [];
|
||||
},
|
||||
});
|
||||
this.tableSelections = [];
|
||||
},
|
||||
updateNodeResult(data, nodeId) {
|
||||
const { completeSize, size } = data;
|
||||
@ -341,13 +349,21 @@ export default {
|
||||
},
|
||||
// 下载远程最新文件
|
||||
downloadRemoteEvent() {
|
||||
downloadRemote().then((res) => {
|
||||
if (res.code === 200) {
|
||||
this.$notification.success({ message: res.msg });
|
||||
this.refresh();
|
||||
} else {
|
||||
//this.$notification.error({ message: res.msg });
|
||||
}
|
||||
this.$confirm({
|
||||
title: "系统提示",
|
||||
content: "确认要下载最新版本吗?,下载前请阅读更新日志里面的说明和注意事项并且请注意备份数据防止数据丢失!!",
|
||||
okText: "确认",
|
||||
cancelText: "取消",
|
||||
onOk: () => {
|
||||
downloadRemote().then((res) => {
|
||||
if (res.code === 200) {
|
||||
this.$notification.success({ message: res.msg });
|
||||
this.refresh();
|
||||
} else {
|
||||
//this.$notification.error({ message: res.msg });
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
// 分页、排序、筛选变化时触发
|
||||
|
Loading…
Reference in New Issue
Block a user