优化主机删除逻辑.

This commit is contained in:
lijiahangmax
2024-08-29 00:33:13 +08:00
parent d2949c11f3
commit d7b747eac4
2 changed files with 4 additions and 11 deletions

View File

@@ -31,7 +31,7 @@ public class HostOperatorType extends InitializingOperatorTypes {
return new OperatorType[]{
new OperatorType(L, CREATE, "创建主机 <sb>${name}</sb>"),
new OperatorType(L, UPDATE, "修改主机 <sb>${name}</sb>"),
new OperatorType(H, DELETE, "删除主机 <sb>${name}</sb>"),
new OperatorType(H, DELETE, "删除主机 <sb>${count}</sb>"),
new OperatorType(M, UPDATE_STATUS, "修改主机状态 <sb>${name}</sb> - <sb>${status}</sb>"),
new OperatorType(M, UPDATE_CONFIG, "修改主机配置 <sb>${name}</sb>"),
};

View File

@@ -279,17 +279,10 @@ public class HostServiceImpl implements HostService {
@Override
public Integer deleteHostByIdList(List<Long> idList) {
log.info("HostService-deleteHostByIdList idList: {}", idList);
// 查询
List<HostDO> hosts = hostDAO.selectBaseByIdList(idList);
Valid.notEmpty(hosts, ErrorMessage.HOST_ABSENT);
// 添加日志参数
String name = hosts.stream()
.map(HostDO::getName)
.collect(Collectors.joining(Const.COMMA));
OperatorLogs.add(OperatorLogs.NAME, name);
OperatorLogs.add(OperatorLogs.COUNT, hosts.size());
// 删除
int effect = hostDAO.deleteBatchIds(hosts);
int effect = hostDAO.deleteBatchIds(idList);
// 添加日志参数
OperatorLogs.add(OperatorLogs.COUNT, idList.size());
log.info("HostService-deleteHostByIdList effect: {}", effect);
// 删除缓存
this.clearCache();