feat(data): 增加服务平台名称模糊查询功能

- 在 BusDataServiceImpl 中添加服务平台名称查询逻辑
- 在 BusServicePlatformService接口中新增 getListByName 方法
- 在 BusServicePlatformServiceImpl 中实现 getListByName 方法
- 在 BusThirdPlatformService 接口中新增 getListByNameLike 方法
- 在 BusThirdPlatformServiceImpl 中实现 getListByNameLike 方法
- 更新 DataMenuQueryDto,添加服务平台名称查询参数
- 优化查询 SQL,支持服务平台 ID 多对多查询
dev
10396 2025-08-21 16:25:52 +08:00
parent 015343fc62
commit 137e08b1d5
7 changed files with 74 additions and 4 deletions

View File

@ -50,8 +50,12 @@ public class DataMenuQueryDto extends PageDto {
/** /**
* id * id
*/ */
@ApiModelProperty(value = "服务平台ids")
private List<Integer> servicePlatformIds;
@ApiModelProperty(value = "服务平台id") @ApiModelProperty(value = "服务平台id")
private Integer servicePlatformId; private Integer servicePlatformId;
@ApiModelProperty(value = "服务平台名称")
private String servicePlatformName;
/** /**
* (1.,2.,3.,4.,5.) * (1.,2.,3.,4.,5.)

View File

@ -6,6 +6,7 @@ import com.zcloud.modules.corp.dto.req.ServicePlatformQueryDto;
import com.zcloud.modules.corp.dto.req.ServicePlatformReqDto; import com.zcloud.modules.corp.dto.req.ServicePlatformReqDto;
import com.zcloud.modules.corp.dto.res.ServicePlatformResDto; import com.zcloud.modules.corp.dto.res.ServicePlatformResDto;
import com.zcloud.modules.corp.entity.BusServicePlatformEntity; import com.zcloud.modules.corp.entity.BusServicePlatformEntity;
import com.zcloud.modules.corp.entity.BusThirdPlatformEntity;
import java.util.List; import java.util.List;
@ -28,5 +29,7 @@ public interface BusServicePlatformService extends IService<BusServicePlatformEn
void deleteById(ServicePlatformReqDto req); void deleteById(ServicePlatformReqDto req);
List<ServicePlatformResDto> listAll(); List<ServicePlatformResDto> listAll();
List<BusServicePlatformEntity> getListByName(String servicePlatformName);
} }

View File

@ -34,5 +34,7 @@ public interface BusThirdPlatformService extends IService<BusThirdPlatformEntity
List<BusThirdPlatformEntity> getListByName(String thirdPlatformName); List<BusThirdPlatformEntity> getListByName(String thirdPlatformName);
List<BusThirdPlatformEntity> getListByIdList(List<Integer> idList); List<BusThirdPlatformEntity> getListByIdList(List<Integer> idList);
List<BusThirdPlatformEntity> getListByNameLike(String fuzzyName);
} }

View File

@ -24,6 +24,7 @@ import com.zcloud.modules.corp.service.BusServicePlatformService;
import com.zcloud.modules.corp.service.BusServiceThirdRelationService; import com.zcloud.modules.corp.service.BusServiceThirdRelationService;
import com.zcloud.modules.corp.service.BusThirdPlatformService; import com.zcloud.modules.corp.service.BusThirdPlatformService;
import com.zcloud.modules.data.aop.AesEncryptionUtilss; import com.zcloud.modules.data.aop.AesEncryptionUtilss;
import com.zcloud.modules.data.enums.data.DataIsDeleteEnum;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -152,5 +153,15 @@ public class BusServicePlatformServiceImpl extends ServiceImpl<BusServicePlatfor
return dtoList; return dtoList;
} }
@Override
public List<BusServicePlatformEntity> getListByName(String servicePlatformName) {
LambdaQueryWrapper<BusServicePlatformEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.like(BusServicePlatformEntity::getServiceName, servicePlatformName)
.eq(BusServicePlatformEntity::getPlatformStatus, PlatformStatusEnum.NORMAL.getCode())
.eq(BusServicePlatformEntity::getIsDelete, DataIsDeleteEnum.NO.getCode());
return list(wrapper);
}
} }

View File

@ -53,6 +53,13 @@ public class BusThirdPlatformServiceImpl extends ServiceImpl<BusThirdPlatformDao
this.dictionariesService = dictionariesService; this.dictionariesService = dictionariesService;
} }
@Override
public List<BusThirdPlatformEntity> getListByNameLike(String fuzzyName) {
LambdaQueryWrapper<BusThirdPlatformEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.like(BusThirdPlatformEntity::getPlatformName, fuzzyName);
return baseMapper.selectList(wrapper);
}
@Override @Override
public PageUtils queryPage(ThirdPlatformQueryDto req) { public PageUtils queryPage(ThirdPlatformQueryDto req) {
Page<BusThirdPlatformEntity> page = new Page<>(req.getCurPage(), req.getLimit()); Page<BusThirdPlatformEntity> page = new Page<>(req.getCurPage(), req.getLimit());

View File

@ -76,6 +76,9 @@ public class BusDataServiceImpl implements BusDataService {
List<BusCompanyInfoEntity> companyList = null; List<BusCompanyInfoEntity> companyList = null;
if (StringUtils.isNotEmpty(req.getCompanyName())) { if (StringUtils.isNotEmpty(req.getCompanyName())) {
companyList = companyInfoService.getListByName(req.getCompanyName()); companyList = companyInfoService.getListByName(req.getCompanyName());
if (CollUtil.isEmpty(companyList)) {
return new PageUtils(null, 0, req.getLimit(), req.getCurPage());
}
if (CollectionUtils.isNotEmpty(companyList)) { if (CollectionUtils.isNotEmpty(companyList)) {
List<Integer> companyIds = companyList.stream().map(BusCompanyInfoEntity::getId).collect(Collectors.toList()); List<Integer> companyIds = companyList.stream().map(BusCompanyInfoEntity::getId).collect(Collectors.toList());
req.setCompanyIds(companyIds); req.setCompanyIds(companyIds);
@ -85,12 +88,29 @@ public class BusDataServiceImpl implements BusDataService {
List<BusThirdPlatformEntity> thirdList = null; List<BusThirdPlatformEntity> thirdList = null;
if (StringUtils.isNotEmpty(req.getThirdPlatformName())) { if (StringUtils.isNotEmpty(req.getThirdPlatformName())) {
thirdList = thirdPlatformService.getListByName(req.getThirdPlatformName()); thirdList = thirdPlatformService.getListByName(req.getThirdPlatformName());
// 如果没有查询到结果,直接返回空结果
if (CollUtil.isEmpty(thirdList)) {
return new PageUtils(null, 0, req.getLimit(), req.getCurPage());
}
if (CollUtil.isNotEmpty(thirdList)) { if (CollUtil.isNotEmpty(thirdList)) {
List<Integer> thirdIds = thirdList.stream().map(BusThirdPlatformEntity::getId).collect(Collectors.toList()); List<Integer> thirdIds = thirdList.stream().map(BusThirdPlatformEntity::getId).collect(Collectors.toList());
req.setThirdPlatformIds(thirdIds); req.setThirdPlatformIds(thirdIds);
} }
} }
List<BusServicePlatformEntity> servicePlatformList = null;
if (StringUtils.isNotEmpty(req.getServicePlatformName())) {
servicePlatformList = servicePlatformService.getListByName(req.getServicePlatformName());
// 如果没有查询到结果,直接返回空结果
if (CollUtil.isEmpty(servicePlatformList)) {
return new PageUtils(null, 0, req.getLimit(), req.getCurPage());
}
if (CollUtil.isNotEmpty(servicePlatformList)) {
List<Integer> serviceIds = servicePlatformList.stream().map(BusServicePlatformEntity::getId).collect(Collectors.toList());
req.setServicePlatformIds(serviceIds);
}
}
int total = busDataDao.selectCount(req, businessDataTypeEnum.getTableName()); int total = busDataDao.selectCount(req, businessDataTypeEnum.getTableName());
if (total <= 0) { if (total <= 0) {
return new PageUtils(null, total, req.getLimit(), req.getCurPage()); return new PageUtils(null, total, req.getLimit(), req.getCurPage());
@ -129,9 +149,12 @@ public class BusDataServiceImpl implements BusDataService {
resDto.setThirdPlatformName(thirdInfo.getPlatformName()); resDto.setThirdPlatformName(thirdInfo.getPlatformName());
})); }));
} }
List<Integer> serviceIdList;
if(CollectionUtils.isNotEmpty(servicePlatformList)){
List<Integer> serviceIdList = result.stream().map(DataMenuResDto::getServicePlatformId).collect(Collectors.toList()); serviceIdList = servicePlatformList.stream().map(BusServicePlatformEntity::getId).collect(Collectors.toList());
}else {
serviceIdList = result.stream().map(DataMenuResDto::getServicePlatformId).collect(Collectors.toList());
}
if (CollectionUtils.isNotEmpty(serviceIdList)) { if (CollectionUtils.isNotEmpty(serviceIdList)) {
LambdaQueryWrapper<BusServicePlatformEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<BusServicePlatformEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.in(BusServicePlatformEntity::getId, serviceIdList); wrapper.in(BusServicePlatformEntity::getId, serviceIdList);

View File

@ -132,7 +132,27 @@
) )
</otherwise> </otherwise>
</choose> </choose>
<choose>
<!-- companyIds 为 null查询所有不加任何条件 -->
<when test="req.servicePlatformIds == null">
<!-- 不加过滤条件 -->
</when>
<!-- companyIds 为空集合,查不到 -->
<when test="req.servicePlatformIds != null and req.servicePlatformIds.size() == 0">
AND a.service_platform_id = -1
</when>
<!-- companyIds 有内容时 -->
<otherwise>
AND EXISTS (
SELECT 1 FROM (
<foreach collection="req.servicePlatformIds" item="servicePlatformId" index="index" separator="UNION ALL">
SELECT #{servicePlatformId} as service_platform_id
</foreach>
) tmp
WHERE tmp.service_platform_id = a.service_platform_id
)
</otherwise>
</choose>
</where> </where>
</sql> </sql>