| | |
| | | @Service |
| | | public class GdFlyerServiceImpl extends BaseServiceImpl<GdFlyerMapper, GdFlyerEntity> implements IGdFlyerService { |
| | | |
| | | /** |
| | | * 分页查询飞手信息列表 |
| | | * @param page 分页对象 |
| | | * @param gdFlyer 查询参数 |
| | | * @return 分页结果 |
| | | */ |
| | | @Override |
| | | public IPage<GdFlyerVO> selectGdFlyerPage(IPage<GdFlyerVO> page, GdFlyerPageParam gdFlyer) { |
| | | return page.setRecords(baseMapper.selectGdFlyerPage(page, gdFlyer)); |
| | | // 步骤1:执行数据库查询获取飞手列表 |
| | | List<GdFlyerVO> gdFlyerVOS = baseMapper.selectGdFlyerPage(page, gdFlyer); |
| | | |
| | | // 步骤2:判断是否有擅长任务类型的查询条件 |
| | | if (StringUtil.isNotBlank(gdFlyer.getSkilledTaskType())) { |
| | | // 步骤3:获取查询的任务类型 |
| | | String searchTaskType = gdFlyer.getSkilledTaskType(); |
| | | |
| | | // 步骤4:对结果进行排序,匹配的记录排在前面 |
| | | gdFlyerVOS.sort((vo1, vo2) -> { |
| | | // 步骤5:检查记录1是否包含查询的任务类型 |
| | | boolean match1 = containsTaskType(vo1.getSkilledTaskType(), searchTaskType); |
| | | // 步骤6:检查记录2是否包含查询的任务类型 |
| | | boolean match2 = containsTaskType(vo2.getSkilledTaskType(), searchTaskType); |
| | | // 步骤7:匹配的记录排在前面(降序排列) |
| | | return Boolean.compare(match2, match1); |
| | | }); |
| | | } |
| | | |
| | | return page.setRecords(gdFlyerVOS); |
| | | } |
| | | |
| | | /** |
| | | * 检查任务类型列表中是否包含指定的任务类型 |
| | | * @param skilledTaskTypes 擅长的任务类型列表(二维数组) |
| | | * @param searchTaskType 要搜索的任务类型 |
| | | * @return 包含返回true,否则返回false |
| | | */ |
| | | private boolean containsTaskType(List<List<String>> skilledTaskTypes, String searchTaskType) { |
| | | // 步骤1:校验参数有效性 |
| | | if (skilledTaskTypes == null || StringUtil.isBlank(searchTaskType)) { |
| | | return false; |
| | | } |
| | | // 步骤2:遍历二维数组,检查是否包含目标任务类型 |
| | | return skilledTaskTypes.stream() |
| | | .anyMatch(innerList -> innerList != null && innerList.contains(searchTaskType)); |
| | | } |
| | | |
| | | |