mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-09 08:57:16 +08:00
refactor: 使用 CollUtils 替代部分 Stream 操作,提高代码的可读性,减少代码行数(缺点:方法写起来不如流式代码舒爽)
This commit is contained in:
@@ -57,6 +57,7 @@ import top.continew.starter.core.autoconfigure.application.ApplicationProperties
|
||||
import top.continew.starter.core.constant.StringConstants;
|
||||
import top.continew.starter.core.enums.BaseEnum;
|
||||
import top.continew.starter.core.exception.BusinessException;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
import top.continew.starter.core.util.validation.CheckUtils;
|
||||
import top.continew.starter.data.enums.DatabaseType;
|
||||
import top.continew.starter.data.util.MetaUtils;
|
||||
@@ -296,9 +297,8 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
InnerGenConfigDO innerGenConfig = new InnerGenConfigDO(genConfig);
|
||||
List<String> imports = new ArrayList<>();
|
||||
// 处理枚举字段
|
||||
List<FieldConfigDO> fieldConfigRecords = fieldConfigList.stream()
|
||||
.map(s -> convertToFieldConfigDO(s, imports))
|
||||
.toList();
|
||||
List<FieldConfigDO> fieldConfigRecords = CollUtils
|
||||
.mapToList(fieldConfigList, s -> convertToFieldConfigDO(s, imports));
|
||||
innerGenConfig.setImports(imports);
|
||||
|
||||
// 渲染代码
|
||||
|
@@ -35,6 +35,7 @@ import top.continew.admin.system.mapper.user.UserMapper;
|
||||
import top.continew.admin.system.mapper.user.UserPasswordHistoryMapper;
|
||||
import top.continew.admin.system.mapper.user.UserSocialMapper;
|
||||
import top.continew.admin.system.model.entity.DeptDO;
|
||||
import top.continew.admin.system.model.entity.FileDO;
|
||||
import top.continew.admin.system.model.entity.MenuDO;
|
||||
import top.continew.admin.system.model.entity.RoleDO;
|
||||
import top.continew.admin.system.model.entity.user.UserDO;
|
||||
@@ -47,6 +48,7 @@ import top.continew.admin.tenant.model.entity.TenantDO;
|
||||
import top.continew.admin.tenant.model.req.TenantReq;
|
||||
import top.continew.admin.tenant.service.PackageMenuService;
|
||||
import top.continew.starter.cache.redisson.util.RedisUtils;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
import top.continew.starter.core.util.ExceptionUtils;
|
||||
import top.continew.starter.core.util.validation.ValidationUtils;
|
||||
import top.continew.starter.extension.crud.model.entity.BaseIdDO;
|
||||
@@ -121,7 +123,7 @@ public class TenantDataHandlerForSystem implements TenantDataHandler {
|
||||
// 部门清除
|
||||
deptMapper.delete(dw);
|
||||
// 文件清除
|
||||
List<Long> fileIds = fileService.list().stream().map(BaseIdDO::getId).toList();
|
||||
List<Long> fileIds = CollUtils.mapToList(fileService.list(), FileDO::getId);
|
||||
if (!fileIds.isEmpty()) {
|
||||
fileService.delete(fileIds);
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import top.continew.admin.tenant.mapper.PackageMenuMapper;
|
||||
import top.continew.admin.tenant.model.entity.PackageMenuDO;
|
||||
import top.continew.admin.tenant.service.PackageMenuService;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -55,7 +56,7 @@ public class PackageMenuServiceImpl implements PackageMenuService {
|
||||
// 删除原有关联
|
||||
baseMapper.lambdaUpdate().eq(PackageMenuDO::getPackageId, packageId).remove();
|
||||
// 保存最新关联
|
||||
List<PackageMenuDO> newList = menuIds.stream().map(menuId -> new PackageMenuDO(packageId, menuId)).toList();
|
||||
List<PackageMenuDO> newList = CollUtils.mapToList(menuIds, menuId -> new PackageMenuDO(packageId, menuId));
|
||||
return baseMapper.insertBatch(newList);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user