refactor: 规范化代码.

This commit is contained in:
lijiahang
2023-11-14 19:28:51 +08:00
parent d4c21a2324
commit 34ea140004
14 changed files with 148 additions and 60 deletions

View File

@@ -256,18 +256,27 @@ public class DataGroupRelServiceImpl implements DataGroupRelService {
if (Strings.isBlank(type) || Lists.isEmpty(relIdList)) {
return 0;
}
// 查询 group
List<Long> groupIdList = dataGroupRelDAO.of()
// 查询需要删除的数据
List<DataGroupRelDO> rows = dataGroupRelDAO.of()
.createWrapper()
.eq(DataGroupRelDO::getType, type)
.in(DataGroupRelDO::getRelId, relIdList)
.then()
.stream()
.list();
if (rows.isEmpty()) {
return 0;
}
// 需要删除的 id
List<Long> idList = rows.stream()
.map(DataGroupRelDO::getId)
.collect(Collectors.toList());
// 需要删除的 groupId
List<Long> groupIdList = rows.stream()
.map(DataGroupRelDO::getGroupId)
.distinct()
.collect(Collectors.toList());
// 删除数据库
int effect = dataGroupRelDAO.deleteBatchIds(relIdList);
int effect = dataGroupRelDAO.deleteBatchIds(idList);
// 删除缓存
this.deleteCache(type, groupIdList);
return effect;