fix 构建历史新增批量删除

This commit is contained in:
bwcx_jzy 2022-05-06 21:07:35 +08:00
parent 366130ee1b
commit 6066100e19
No known key found for this signature in database
GPG Key ID: 5E48E9372088B9E5
3 changed files with 56 additions and 7 deletions

View File

@ -11,6 +11,7 @@
1. 修复上传文件限制大小异常拦截不生效的问题(感谢@
2. 新增配置前端消息弹窗位置属性 `jpom.notificationPlacement` (感谢[@Eibons](https://gitee.com/eibons) [Gitee issues I53V8B](https://gitee.com/dromara/Jpom/issues/I53V8B)
3. 构建历史新增批量删除
------

View File

@ -23,6 +23,7 @@
package io.jpom.controller.build;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil;
import cn.jiangzeyin.common.JsonMessage;
import cn.jiangzeyin.common.validator.ValidatorConfig;
@ -44,6 +45,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.io.File;
import java.util.List;
import java.util.Objects;
/**
@ -126,17 +128,23 @@ public class BuildInfoHistoryController extends BaseServerController {
}
/**
* 构建
* 删除构建历史支持批量删除用逗号分隔
*
* @param logId id
* @return json
*/
@RequestMapping(value = "/build/history/delete_log.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.DEL)
public String delete(@ValidatorConfig(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "没有数据")) String logId) {
BuildHistoryLog buildHistoryLog = dbBuildHistoryLogService.getByKey(logId, getRequest());
public JsonMessage<String> delete(@ValidatorConfig(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "没有数据")) String logId) {
List<String> strings = StrUtil.splitTrim(logId, StrUtil.COMMA);
for (String itemId : strings) {
BuildHistoryLog buildHistoryLog = dbBuildHistoryLogService.getByKey(itemId, getRequest());
Objects.requireNonNull(buildHistoryLog);
JsonMessage<String> jsonMessage = dbBuildHistoryLogService.deleteLogAndFile(buildHistoryLog);
return jsonMessage.toString();
if (jsonMessage.getCode() != 200) {
return jsonMessage;
}
}
return new JsonMessage<>(200, "删除成功");
}
}

View File

@ -11,8 +11,9 @@
:columns="columns"
:pagination="this.listQuery.total / this.listQuery.limit > 1 ? (this, pagination) : false"
bordered
:rowKey="(record, index) => index"
rowKey="id"
@change="change"
:row-selection="rowSelection"
>
<template slot="title">
<a-space>
@ -29,6 +30,7 @@
<a-tooltip title="按住 Ctr 或者 Alt/Option 键点击按钮快速回到第一页">
<a-button type="primary" :loading="loading" @click="loadData">搜索</a-button>
</a-tooltip>
<a-button type="danger" :disabled="!tableSelections || tableSelections.length <= 0" @click="handleBatchDelete"> 批量删除 </a-button>
<a-tooltip>
<template slot="title">
<div>构建历史是用于记录每次构建的信息,可以保留构建产物信息,构建日志同时还可以快速回滚发布</div>
@ -132,6 +134,7 @@ export default {
statusMap: statusMap,
temp: {},
buildLogVisible: false,
tableSelections: [],
columns: [
{ title: "构建名称", dataIndex: "buildName", /*width: 120,*/ ellipsis: true, scopedSlots: { customRender: "tooltip" } },
{ title: "构建 ID", dataIndex: "buildNumberId", width: 90, align: "center", ellipsis: true, scopedSlots: { customRender: "buildNumberId" } },
@ -173,6 +176,12 @@ export default {
},
};
},
rowSelection() {
return {
onChange: this.tableSelectionChange,
selectedRowKeys: this.tableSelections,
};
},
},
created() {
this.loadBuildList();
@ -272,6 +281,33 @@ export default {
},
});
},
//
handleBatchDelete() {
if (!this.tableSelections || this.tableSelections.length <= 0) {
this.$notification.warning({
message: "没有选择任何数据",
});
return;
}
this.$confirm({
title: "系统提示",
content: "真的要删除这些构建历史记录么?",
okText: "确认",
cancelText: "取消",
onOk: () => {
//
deleteBuildHistory(this.tableSelections.join(",")).then((res) => {
if (res.code === 200) {
this.$notification.success({
message: res.msg,
});
this.tableSelections = [];
this.loadData();
}
});
},
});
},
//
handleBuildLog(record) {
this.temp = {
@ -284,6 +320,10 @@ export default {
closeBuildLogModel() {
this.loadData();
},
//
tableSelectionChange(selectedRowKeys) {
this.tableSelections = selectedRowKeys;
},
},
};
</script>