feat 节点分发支持手动释放删除指定项目

This commit is contained in:
bwcx_jzy 2023-03-16 09:56:40 +08:00
parent 205074e3da
commit 3bd246928b
No known key found for this signature in database
GPG Key ID: 5E48E9372088B9E5
6 changed files with 91 additions and 5 deletions

View File

@ -9,6 +9,7 @@
(感谢 [@大灰灰大](https://gitee.com/linjianhui) [Gitee issues I6N35H](https://gitee.com/dromara/Jpom/issues/I6N35H)
3. 【server】新增 用户支持自定义工作空间名,排序 (感谢@酱总)
4. 【server】新增 节点分发项目支持排序,设置项目启用/禁用状态(感谢@酱总)
5. 【server】新增 节点分发支持手动释放删除指定项目
### 🐞 解决BUG、优化功能

View File

@ -109,6 +109,7 @@ public class EditProjectController extends BaseServerController {
* @return json
*/
@RequestMapping(value = "release-outgiving", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.EDIT)
public JsonMessage<String> releaseOutgiving(String id, HttpServletRequest request) {
NodeModel node = getNode();

View File

@ -298,7 +298,8 @@ public class OutGivingProjectController extends BaseServerController {
}
@PostMapping(value = "cancel", produces = MediaType.APPLICATION_JSON_VALUE)
public JsonMessage<String> cancel(String id) {
@Feature(method = MethodFeature.EXECUTE)
public JsonMessage<String> cancel(@ValidatorItem String id) {
OutGivingModel outGivingModel = this.check(id, (status, outGivingModel1) -> Assert.state(status == OutGivingModel.Status.ING, "当前状态不是分发中"));
OutGivingRun.cancel(outGivingModel.getId());
//
@ -306,6 +307,7 @@ public class OutGivingProjectController extends BaseServerController {
}
@PostMapping(value = "config-project", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.EDIT)
public JsonMessage<String> configProject(@RequestBody JSONObject jsonObject, HttpServletRequest request) {
Assert.notNull(jsonObject, "没有任何信息");
String id = jsonObject.getString("id");
@ -330,4 +332,26 @@ public class OutGivingProjectController extends BaseServerController {
return JsonMessage.success("更新成功");
}
@GetMapping(value = "remove-project", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.DEL)
public JsonMessage<String> removeProject(@ValidatorItem String id,
@ValidatorItem String nodeId,
@ValidatorItem String projectId,
HttpServletRequest request) {
OutGivingModel outGivingModel = outGivingServer.getByKey(id, request);
Assert.notNull(outGivingModel, "没有找到对应的分发项目");
List<OutGivingNodeProject> outGivingNodeProjects = outGivingModel.outGivingNodeProjectList();
Assert.notEmpty(outGivingNodeProjects, "分发信息错误,没有任何项目");
//
Assert.state(outGivingNodeProjects.size() > 1, "当前分发只有一个项目啦,删除整个分发即可");
outGivingNodeProjects = outGivingNodeProjects.stream()
.filter(nodeProject -> !StrUtil.equals(nodeProject.getProjectId(), projectId) || !StrUtil.equals(nodeProject.getNodeId(), nodeId))
.collect(Collectors.toList());
// 更新
OutGivingModel update = new OutGivingModel();
update.setId(outGivingModel.getId());
update.outGivingNodeProjectList(outGivingNodeProjects);
outGivingServer.update(update);
return JsonMessage.success("删除成功");
}
}

View File

@ -224,6 +224,14 @@ export function cancelOutgiving(data) {
});
}
export function removeProject(params) {
return axios({
url: "/outgiving/remove-project",
method: "get",
params: params,
});
}
export function saveDispatchProjectConfig(data) {
return axios({
url: "/outgiving/config-project",

View File

@ -785,6 +785,9 @@
"
/>
</a-col>
<a-col :span="2">
<a-button type="danger" size="small" @click="handleRemoveProject(item)" :disabled="!temp || !temp.dispatchManagerList || temp.dispatchManagerList.length <= 1"> 解绑 </a-button>
</a-col>
<a-col :span="2">
<a-space>
<a-tooltip placement="left" :title="`长按可以拖动排序`" class="move"> <a-icon type="menu" /> </a-tooltip>
@ -823,6 +826,7 @@ import {
cancelOutgiving,
uploadDispatchFileMerge,
saveDispatchProjectConfig,
removeProject,
} from "@/api/dispatch";
import { getNodeListAll, getProjectListAll } from "@/api/node";
import { getProjectData, javaModes, noFileModes, runModeList, getRuningProjectInfo, getProjectGroupAll } from "@/api/node-project";
@ -1800,12 +1804,15 @@ export default {
},
//
handleViewDispatchManager(record) {
getDispatchProject(record.id, true).then((res) => {
this.handleViewDispatchManagerById(record.id);
},
handleViewDispatchManagerById(id) {
getDispatchProject(id, true).then((res) => {
if (res.code === 200) {
this.dispatchManagerList = res.data;
this.temp = {
dispatchManagerList: res.data,
id: record.id,
id: id,
};
this.viewDispatchManager = true;
}
@ -1833,6 +1840,40 @@ export default {
}
});
},
//
handleRemoveProject(item) {
const html =
"<b style='font-size: 20px;'>真的要释放(删除)当前项目么?</b>" +
"<ul style='font-size: 20px;color:red;font-weight: bold;'>" +
"<li>不会真实请求节点删除项目信息</b></li>" +
"<li>一般用于服务器无法连接且已经确定不再使用</li>" +
"<li>如果误操作会产生冗余数据!!!</li>" +
" </ul>";
const h = this.$createElement;
this.$confirm({
title: "危险操作!!!",
content: h("div", null, [h("p", { domProps: { innerHTML: html } }, null)]),
okButtonProps: { props: { type: "danger", size: "small" } },
cancelButtonProps: { props: { type: "primary" } },
okText: "确认",
cancelText: "取消",
onOk: () => {
removeProject({
nodeId: item.nodeId,
projectId: item.projectId,
id: this.temp.id,
}).then((res) => {
if (res.code === 200) {
this.$notification.success({
message: res.msg,
});
this.handleViewDispatchManagerById(this.temp.id);
}
});
},
});
},
},
};
</script>

View File

@ -1149,9 +1149,20 @@ export default {
},
//
handleReleaseOutgiving(project) {
const html =
"<b style='font-size: 20px;'>确定要释放当前项目的分发功能吗?</b>" +
"<ul style='font-size: 20px;color:red;font-weight: bold;'>" +
"<li>请慎重操作,否则会产生冗余数据。</b></li>" +
"<li>一般用于误操作后将本删除转为普通项目再删除项目</li>" +
"<li>如果关联的分发还存在再重新编辑对应分发后当前项目会再次切换为分发项目!!!</li>" +
" </ul>";
const h = this.$createElement;
this.$confirm({
title: "系统提示",
content: "确定要释放当前项目的分发功能吗?请慎重操作,否则会产生冗余数据。如果关联的分发还存在再重新编辑对应分发后当前项目可能再次切换为分发项目",
title: "危险操作!!!",
content: h("div", null, [h("p", { domProps: { innerHTML: html } }, null)]),
okButtonProps: { props: { type: "danger", size: "small" } },
cancelButtonProps: { props: { type: "primary" } },
okText: "确认",
cancelText: "取消",
onOk: () => {