mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-08 12:57:13 +08:00
refactor: 使用 CollUtils 替代部分 Stream 操作,提高代码的可读性,减少代码行数(缺点:方法写起来不如流式代码舒爽)
This commit is contained in:
@@ -34,6 +34,10 @@ public class AuthConfiguration {
|
||||
*/
|
||||
@Bean
|
||||
public GroupedOpenApi authApi() {
|
||||
return GroupedOpenApi.builder().group("auth").displayName("系统认证").pathsToMatch("/auth/**", "/monitor/online/**").build();
|
||||
return GroupedOpenApi.builder()
|
||||
.group("auth")
|
||||
.displayName("系统认证")
|
||||
.pathsToMatch("/auth/**", "/monitor/online/**")
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ import top.continew.admin.system.mapper.StorageMapper;
|
||||
import top.continew.admin.system.model.entity.FileDO;
|
||||
import top.continew.admin.system.model.entity.StorageDO;
|
||||
import top.continew.starter.core.constant.StringConstants;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
import top.continew.starter.core.util.URLUtils;
|
||||
|
||||
import java.util.List;
|
||||
@@ -128,7 +129,7 @@ public class FileRecorderImpl implements FileRecorder {
|
||||
return list.get(0);
|
||||
}
|
||||
// 结合存储配置进行匹配
|
||||
List<StorageDO> storageList = storageMapper.selectByIds(list.stream().map(FileDO::getStorageId).toList());
|
||||
List<StorageDO> storageList = storageMapper.selectByIds(CollUtils.mapToList(list, FileDO::getStorageId));
|
||||
Map<Long, StorageDO> storageMap = storageList.stream()
|
||||
.collect(Collectors.toMap(StorageDO::getId, storage -> storage));
|
||||
return list.stream().filter(file -> {
|
||||
|
@@ -27,6 +27,7 @@ import top.continew.admin.common.enums.DisEnableStatusEnum;
|
||||
import top.continew.admin.system.model.query.SmsConfigQuery;
|
||||
import top.continew.admin.system.model.resp.SmsConfigResp;
|
||||
import top.continew.admin.system.service.SmsConfigService;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -61,6 +62,6 @@ public class SmsReadConfigDatabaseImpl implements SmsReadConfig {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return List.of();
|
||||
}
|
||||
return list.stream().map(SmsConfigUtil::from).toList();
|
||||
return CollUtils.mapToList(list, SmsConfigUtil::from);
|
||||
}
|
||||
}
|
@@ -48,6 +48,7 @@ import top.continew.admin.system.service.UserService;
|
||||
import top.continew.admin.system.service.UserSocialService;
|
||||
import top.continew.starter.cache.redisson.util.RedisUtils;
|
||||
import top.continew.starter.core.exception.BadRequestException;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
import top.continew.starter.core.util.ExceptionUtils;
|
||||
import top.continew.starter.core.util.validation.ValidationUtils;
|
||||
|
||||
@@ -131,13 +132,13 @@ public class UserProfileController {
|
||||
@GetMapping("/social")
|
||||
public List<UserSocialBindResp> listSocialBind() {
|
||||
List<UserSocialDO> userSocialList = userSocialService.listByUserId(UserContextHolder.getUserId());
|
||||
return userSocialList.stream().map(userSocial -> {
|
||||
return CollUtils.mapToList(userSocialList, userSocial -> {
|
||||
String source = userSocial.getSource();
|
||||
UserSocialBindResp userSocialBind = new UserSocialBindResp();
|
||||
userSocialBind.setSource(source);
|
||||
userSocialBind.setDescription(SocialSourceEnum.valueOf(source).getDescription());
|
||||
return userSocialBind;
|
||||
}).toList();
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "绑定三方账号", description = "绑定三方账号")
|
||||
|
@@ -37,6 +37,7 @@ import top.continew.admin.system.model.resp.dashboard.DashboardOverviewCommonRes
|
||||
import top.continew.admin.system.service.DashboardService;
|
||||
import top.continew.admin.system.service.NoticeService;
|
||||
import top.continew.starter.core.constant.StringConstants;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
@@ -95,10 +96,10 @@ public class DashboardServiceImpl implements DashboardService {
|
||||
// 获取省份数据
|
||||
String chinaJson = IoUtil.readUtf8(new ClassPathResource("china.json").getInputStream());
|
||||
JSONArray jsonArr = JSONUtil.parseObj(chinaJson).getJSONArray("children");
|
||||
List<String> provinceList = jsonArr.stream().map(item -> {
|
||||
List<String> provinceList = CollUtils.mapToList(jsonArr, item -> {
|
||||
JSONObject itemJsonObj = JSONUtil.parseObj(item);
|
||||
return "%s:%s".formatted(itemJsonObj.getStr("name"), itemJsonObj.getStr("fullname"));
|
||||
}).toList();
|
||||
});
|
||||
// 汇总各省份访问数据
|
||||
for (String province : provinceList) {
|
||||
String[] split = province.split(StringConstants.COLON);
|
||||
@@ -124,10 +125,9 @@ public class DashboardServiceImpl implements DashboardService {
|
||||
.stream()
|
||||
.map(date -> date.toString(DatePattern.NORM_DATE_FORMAT))
|
||||
.toList();
|
||||
Collection<String> missings = CollUtil.disjunction(all, list.stream()
|
||||
.map(DashboardAccessTrendResp::getDate)
|
||||
.toList());
|
||||
list.addAll(missings.stream().map(missing -> new DashboardAccessTrendResp(missing, 0L, 0L)).toList());
|
||||
Collection<String> missings = CollUtil.disjunction(all, CollUtils
|
||||
.mapToList(list, DashboardAccessTrendResp::getDate));
|
||||
list.addAll(CollUtils.mapToList(missings, missing -> new DashboardAccessTrendResp(missing, 0L, 0L)));
|
||||
list.sort(Comparator.comparing(DashboardAccessTrendResp::getDate));
|
||||
}
|
||||
return list;
|
||||
@@ -200,10 +200,9 @@ public class DashboardServiceImpl implements DashboardService {
|
||||
* @param list 待填充数据
|
||||
*/
|
||||
private void fillMissingDateData(List<String> all, List<DashboardChartCommonResp> list) {
|
||||
Collection<String> missings = CollUtil.disjunction(all, list.stream()
|
||||
.map(DashboardChartCommonResp::getName)
|
||||
.toList());
|
||||
list.addAll(missings.stream().map(missing -> new DashboardChartCommonResp(missing, 0L)).toList());
|
||||
Collection<String> missings = CollUtil.disjunction(all, CollUtils
|
||||
.mapToList(list, DashboardChartCommonResp::getName));
|
||||
list.addAll(CollUtils.mapToList(missings, missing -> new DashboardChartCommonResp(missing, 0L)));
|
||||
list.sort(Comparator.comparing(DashboardChartCommonResp::getName));
|
||||
}
|
||||
|
||||
|
@@ -26,6 +26,7 @@ import top.continew.admin.system.model.req.DictReq;
|
||||
import top.continew.admin.system.model.resp.DictResp;
|
||||
import top.continew.admin.system.service.DictItemService;
|
||||
import top.continew.admin.system.service.DictService;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
import top.continew.starter.core.util.validation.CheckUtils;
|
||||
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
|
||||
|
||||
@@ -75,7 +76,7 @@ public class DictServiceImpl extends BaseServiceImpl<DictMapper, DictDO, DictRes
|
||||
@Override
|
||||
public List<LabelValueResp> listEnumDict() {
|
||||
List<String> enumDictNameList = dictItemService.listEnumDictNames();
|
||||
return enumDictNameList.stream().map(name -> new LabelValueResp(name, name)).toList();
|
||||
return CollUtils.mapToList(enumDictNameList, name -> new LabelValueResp(name, name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
|
||||
import top.continew.admin.system.mapper.MessageLogMapper;
|
||||
import top.continew.admin.system.model.entity.MessageLogDO;
|
||||
import top.continew.admin.system.service.MessageLogService;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@@ -44,9 +45,8 @@ public class MessageLogServiceImpl implements MessageLogService {
|
||||
if (CollUtil.isEmpty(messageIds)) {
|
||||
return;
|
||||
}
|
||||
List<MessageLogDO> list = messageIds.stream()
|
||||
.map(messageId -> new MessageLogDO(messageId, userId, LocalDateTime.now()))
|
||||
.toList();
|
||||
List<MessageLogDO> list = CollUtils
|
||||
.mapToList(messageIds, messageId -> new MessageLogDO(messageId, userId, LocalDateTime.now()));
|
||||
baseMapper.insert(list);
|
||||
}
|
||||
|
||||
|
@@ -37,6 +37,7 @@ import top.continew.admin.system.model.resp.message.MessageTypeUnreadResp;
|
||||
import top.continew.admin.system.model.resp.message.MessageUnreadResp;
|
||||
import top.continew.admin.system.service.MessageLogService;
|
||||
import top.continew.admin.system.service.MessageService;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
import top.continew.starter.extension.crud.model.query.PageQuery;
|
||||
import top.continew.starter.extension.crud.model.resp.PageResp;
|
||||
import top.continew.starter.messaging.websocket.util.WebSocketUtils;
|
||||
@@ -75,7 +76,7 @@ public class MessageServiceImpl implements MessageService {
|
||||
public void readMessage(List<Long> ids, Long userId) {
|
||||
// 查询当前用户的未读消息
|
||||
List<MessageDO> list = baseMapper.selectUnreadListByUserId(userId);
|
||||
List<Long> unreadIds = list.stream().map(MessageDO::getId).toList();
|
||||
List<Long> unreadIds = CollUtils.mapToList(list, MessageDO::getId);
|
||||
messageLogService.addWithUserId(CollUtil.isNotEmpty(ids)
|
||||
? CollUtil.intersection(unreadIds, ids).stream().toList()
|
||||
: unreadIds, userId);
|
||||
|
@@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import top.continew.admin.system.mapper.NoticeLogMapper;
|
||||
import top.continew.admin.system.model.entity.NoticeLogDO;
|
||||
import top.continew.admin.system.service.NoticeLogService;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
@@ -57,7 +58,7 @@ public class NoticeLogServiceImpl implements NoticeLogService {
|
||||
}
|
||||
// 新增没有关联的
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
List<NoticeLogDO> list = subtract.stream().map(userId -> new NoticeLogDO(noticeId, userId, now)).toList();
|
||||
List<NoticeLogDO> list = CollUtils.mapToList(subtract, userId -> new NoticeLogDO(noticeId, userId, now));
|
||||
return baseMapper.insertBatch(list);
|
||||
}
|
||||
|
||||
|
@@ -37,6 +37,7 @@ import top.continew.admin.system.model.resp.OptionResp;
|
||||
import top.continew.admin.system.service.OptionService;
|
||||
import top.continew.starter.cache.redisson.util.RedisUtils;
|
||||
import top.continew.starter.core.constant.StringConstants;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
import top.continew.starter.core.util.validation.CheckUtils;
|
||||
import top.continew.starter.core.util.validation.ValidationUtils;
|
||||
import top.continew.starter.data.util.QueryWrapperHelper;
|
||||
@@ -75,7 +76,7 @@ public class OptionServiceImpl implements OptionService {
|
||||
@Override
|
||||
public void update(List<OptionReq> options) {
|
||||
// 非空校验
|
||||
List<Long> idList = options.stream().map(OptionReq::getId).toList();
|
||||
List<Long> idList = CollUtils.mapToList(options, OptionReq::getId);
|
||||
List<OptionDO> optionList = baseMapper.selectByIds(idList);
|
||||
Map<String, OptionDO> optionMap = optionList.stream()
|
||||
.collect(Collectors.toMap(OptionDO::getCode, Function.identity(), (existing, replacement) -> existing));
|
||||
|
@@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import top.continew.admin.system.mapper.RoleDeptMapper;
|
||||
import top.continew.admin.system.model.entity.RoleDeptDO;
|
||||
import top.continew.admin.system.service.RoleDeptService;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -55,7 +56,7 @@ public class RoleDeptServiceImpl implements RoleDeptService {
|
||||
// 删除原有关联
|
||||
baseMapper.lambdaUpdate().eq(RoleDeptDO::getRoleId, roleId).remove();
|
||||
// 保存最新关联
|
||||
List<RoleDeptDO> roleDeptList = deptIds.stream().map(deptId -> new RoleDeptDO(roleId, deptId)).toList();
|
||||
List<RoleDeptDO> roleDeptList = CollUtils.mapToList(deptIds, deptId -> new RoleDeptDO(roleId, deptId));
|
||||
return baseMapper.insertBatch(roleDeptList);
|
||||
}
|
||||
|
||||
|
@@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import top.continew.admin.system.mapper.RoleMenuMapper;
|
||||
import top.continew.admin.system.model.entity.RoleMenuDO;
|
||||
import top.continew.admin.system.service.RoleMenuService;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
import top.continew.starter.data.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -58,7 +59,7 @@ public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenuDO>
|
||||
// 删除原有关联
|
||||
baseMapper.lambdaUpdate().eq(RoleMenuDO::getRoleId, roleId).remove();
|
||||
// 保存最新关联
|
||||
List<RoleMenuDO> roleMenuList = menuIds.stream().map(menuId -> new RoleMenuDO(roleId, menuId)).toList();
|
||||
List<RoleMenuDO> roleMenuList = CollUtils.mapToList(menuIds, menuId -> new RoleMenuDO(roleId, menuId));
|
||||
return baseMapper.insertBatch(roleMenuList);
|
||||
}
|
||||
|
||||
|
@@ -39,13 +39,13 @@ import top.continew.admin.system.model.resp.MenuResp;
|
||||
import top.continew.admin.system.model.resp.role.RoleDetailResp;
|
||||
import top.continew.admin.system.model.resp.role.RoleResp;
|
||||
import top.continew.admin.system.service.*;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
import top.continew.starter.core.util.validation.CheckUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 角色业务实现
|
||||
@@ -150,7 +150,7 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleRes
|
||||
if (obj instanceof RoleDetailResp detail) {
|
||||
Long roleId = detail.getId();
|
||||
List<MenuResp> list = menuService.listByRoleId(roleId);
|
||||
List<Long> menuIds = list.stream().map(MenuResp::getId).toList();
|
||||
List<Long> menuIds = CollUtils.mapToList(list, MenuResp::getId);
|
||||
detail.setMenuIds(menuIds);
|
||||
}
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleRes
|
||||
return Collections.emptySet();
|
||||
}
|
||||
List<RoleDO> roleList = baseMapper.lambdaQuery().select(RoleDO::getCode).in(RoleDO::getId, roleIdList).list();
|
||||
return roleList.stream().map(RoleDO::getCode).collect(Collectors.toSet());
|
||||
return CollUtils.mapToSet(roleList, RoleDO::getCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -185,9 +185,7 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleRes
|
||||
.select(RoleDO::getId, RoleDO::getCode, RoleDO::getDataScope)
|
||||
.in(RoleDO::getId, roleIdList)
|
||||
.list();
|
||||
return roleList.stream()
|
||||
.map(r -> new RoleContext(r.getId(), r.getCode(), r.getDataScope()))
|
||||
.collect(Collectors.toSet());
|
||||
return CollUtils.mapToSet(roleList, r -> new RoleContext(r.getId(), r.getCode(), r.getDataScope()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -25,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import top.continew.admin.system.mapper.user.UserPasswordHistoryMapper;
|
||||
import top.continew.admin.system.model.entity.user.UserPasswordHistoryDO;
|
||||
import top.continew.admin.system.service.UserPasswordHistoryService;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -73,7 +74,7 @@ public class UserPasswordHistoryServiceImpl implements UserPasswordHistoryServic
|
||||
return false;
|
||||
}
|
||||
// 校验是否重复使用历史密码
|
||||
List<String> passwordList = list.stream().map(UserPasswordHistoryDO::getPassword).toList();
|
||||
List<String> passwordList = CollUtils.mapToList(list, UserPasswordHistoryDO::getPassword);
|
||||
return passwordList.stream().anyMatch(p -> passwordEncoder.matches(password, p));
|
||||
}
|
||||
}
|
@@ -31,6 +31,7 @@ import top.continew.admin.system.model.entity.UserRoleDO;
|
||||
import top.continew.admin.system.model.query.RoleUserQuery;
|
||||
import top.continew.admin.system.model.resp.role.RoleUserResp;
|
||||
import top.continew.admin.system.service.UserRoleService;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
import top.continew.starter.core.util.validation.CheckUtils;
|
||||
import top.continew.starter.data.util.QueryWrapperHelper;
|
||||
import top.continew.starter.extension.crud.model.query.PageQuery;
|
||||
@@ -85,13 +86,13 @@ public class UserRoleServiceImpl implements UserRoleService {
|
||||
// 删除原有关联
|
||||
baseMapper.lambdaUpdate().eq(UserRoleDO::getUserId, userId).remove();
|
||||
// 保存最新关联
|
||||
List<UserRoleDO> userRoleList = roleIds.stream().map(roleId -> new UserRoleDO(userId, roleId)).toList();
|
||||
List<UserRoleDO> userRoleList = CollUtils.mapToList(roleIds, roleId -> new UserRoleDO(userId, roleId));
|
||||
return baseMapper.insertBatch(userRoleList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean assignRoleToUsers(Long roleId, List<Long> userIds) {
|
||||
List<UserRoleDO> userRoleList = userIds.stream().map(userId -> new UserRoleDO(userId, roleId)).toList();
|
||||
List<UserRoleDO> userRoleList = CollUtils.mapToList(userIds, userId -> new UserRoleDO(userId, roleId));
|
||||
return baseMapper.insertBatch(userRoleList);
|
||||
}
|
||||
|
||||
|
@@ -80,6 +80,7 @@ import top.continew.admin.system.service.*;
|
||||
import top.continew.starter.cache.redisson.util.RedisUtils;
|
||||
import top.continew.starter.core.constant.StringConstants;
|
||||
import top.continew.starter.core.exception.BusinessException;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
import top.continew.starter.core.util.FileUploadUtils;
|
||||
import top.continew.starter.core.util.validation.CheckUtils;
|
||||
import top.continew.starter.extension.crud.model.query.PageQuery;
|
||||
@@ -202,7 +203,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
||||
.select(UserDO::getId, UserDO::getNickname, UserDO::getIsSystem)
|
||||
.in(UserDO::getId, ids)
|
||||
.list();
|
||||
List<Long> idList = list.stream().map(UserDO::getId).toList();
|
||||
List<Long> idList = CollUtils.mapToList(list, UserDO::getId);
|
||||
Collection<Long> subtractIds = CollUtil.subtract(ids, idList);
|
||||
CheckUtils.throwIfNotEmpty(subtractIds, "所选用户 [{}] 不存在", CollUtil.join(subtractIds, StringConstants.COMMA));
|
||||
Optional<UserDO> isSystemData = list.stream().filter(UserDO::getIsSystem).findFirst();
|
||||
@@ -278,7 +279,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
||||
int existRoleCount = roleService.countByNames(roleNames);
|
||||
CheckUtils.throwIf(existRoleCount < roleNames.size(), "存在无效角色,请检查数据");
|
||||
// 校验是否存在无效部门
|
||||
List<String> deptNames = validRowList.stream().map(UserImportRowReq::getDeptName).distinct().toList();
|
||||
List<String> deptNames = CollUtils.mapToList(validRowList, UserImportRowReq::getDeptName);
|
||||
int existDeptCount = deptService.countByNames(deptNames);
|
||||
CheckUtils.throwIf(existDeptCount < deptNames.size(), "存在无效部门,请检查数据");
|
||||
|
||||
@@ -316,11 +317,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
||||
// 已存在数据查询
|
||||
List<String> existEmails = listExistByField(importUserList, UserImportRowReq::getEmail, UserDO::getEmail);
|
||||
List<String> existPhones = listExistByField(importUserList, UserImportRowReq::getPhone, UserDO::getPhone);
|
||||
List<UserDO> existUserList = listByUsernames(importUserList.stream()
|
||||
.map(UserImportRowReq::getUsername)
|
||||
.filter(Objects::nonNull)
|
||||
.toList());
|
||||
List<String> existUsernames = existUserList.stream().map(UserDO::getUsername).toList();
|
||||
List<UserDO> existUserList = listByUsernames(CollUtils
|
||||
.mapToList(importUserList, UserImportRowReq::getUsername));
|
||||
List<String> existUsernames = CollUtils.mapToList(existUserList, UserDO::getUsername);
|
||||
CheckUtils
|
||||
.throwIf(isExitImportUser(req, importUserList, existUsernames, existEmails, existPhones), "数据不符合导入策略,已退出导入");
|
||||
|
||||
@@ -519,10 +518,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
||||
.between(CollUtil.isNotEmpty(createTimeList), "t1.create_time", CollUtil.getFirst(createTimeList), CollUtil
|
||||
.getLast(createTimeList))
|
||||
.and(deptId != null && !SysConstants.SUPER_DEPT_ID.equals(deptId), q -> {
|
||||
List<Long> deptIdList = deptService.listChildren(deptId)
|
||||
.stream()
|
||||
.map(DeptDO::getId)
|
||||
.collect(Collectors.toList());
|
||||
List<Long> deptIdList = CollUtils.mapToList(deptService.listChildren(deptId), DeptDO::getId);
|
||||
deptIdList.add(deptId);
|
||||
q.in("t1.dept_id", deptIdList);
|
||||
})
|
||||
@@ -543,7 +539,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
||||
}
|
||||
if (CollUtil.isNotEmpty(updateList)) {
|
||||
baseMapper.updateBatchById(updateList);
|
||||
userRoleService.deleteByUserIds(updateList.stream().map(UserDO::getId).toList());
|
||||
userRoleService.deleteByUserIds(CollUtils.mapToList(updateList, UserDO::getId));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(userRoleDOList)) {
|
||||
userRoleService.saveBatch(userRoleDOList);
|
||||
@@ -603,7 +599,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
||||
Function<UserImportRowReq, String> rowField,
|
||||
SFunction<UserDO, ?> dbField,
|
||||
boolean fieldEncrypt) {
|
||||
List<String> fieldValues = userRowList.stream().map(rowField).filter(Objects::nonNull).toList();
|
||||
List<String> fieldValues = CollUtils.mapToList(userRowList, rowField);
|
||||
if (fieldValues.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
@@ -622,14 +618,14 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
||||
private List<String> listExistByField(List<UserImportRowReq> userRowList,
|
||||
Function<UserImportRowReq, String> rowField,
|
||||
SFunction<UserDO, String> dbField) {
|
||||
List<String> fieldValues = userRowList.stream().map(rowField).filter(Objects::nonNull).toList();
|
||||
List<String> fieldValues = CollUtils.mapToList(userRowList, rowField);
|
||||
if (fieldValues.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<UserDO> userDOList = baseMapper.selectList(Wrappers.<UserDO>lambdaQuery()
|
||||
List<UserDO> userList = baseMapper.selectList(Wrappers.<UserDO>lambdaQuery()
|
||||
.in(dbField, SecureUtils.encryptFieldByAes(fieldValues))
|
||||
.select(dbField));
|
||||
return userDOList.stream().map(dbField).filter(Objects::nonNull).toList();
|
||||
return CollUtils.mapToList(userList, dbField);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -25,12 +25,12 @@ import top.continew.admin.system.enums.SocialSourceEnum;
|
||||
import top.continew.admin.system.mapper.user.UserSocialMapper;
|
||||
import top.continew.admin.system.model.entity.user.UserSocialDO;
|
||||
import top.continew.admin.system.service.UserSocialService;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
import top.continew.starter.core.util.validation.CheckUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户社会化关联业务实现
|
||||
@@ -73,7 +73,7 @@ public class UserSocialServiceImpl implements UserSocialService {
|
||||
String source = authUser.getSource();
|
||||
String openId = authUser.getUuid();
|
||||
List<UserSocialDO> userSocialList = this.listByUserId(userId);
|
||||
Set<String> boundSocialSet = userSocialList.stream().map(UserSocialDO::getSource).collect(Collectors.toSet());
|
||||
Set<String> boundSocialSet = CollUtils.mapToSet(userSocialList, UserSocialDO::getSource);
|
||||
String description = SocialSourceEnum.valueOf(source).getDescription();
|
||||
CheckUtils.throwIf(boundSocialSet.contains(source), "您已经绑定过了 [{}] 平台,请先解绑", description);
|
||||
UserSocialDO userSocial = this.getBySourceAndOpenId(source, openId);
|
||||
|
Reference in New Issue
Block a user