feat(data): 增加服务平台名称模糊查询功能
- 在 BusDataServiceImpl 中添加服务平台名称查询逻辑 - 在 BusServicePlatformService接口中新增 getListByName 方法 - 在 BusServicePlatformServiceImpl 中实现 getListByName 方法 - 在 BusThirdPlatformService 接口中新增 getListByNameLike 方法 - 在 BusThirdPlatformServiceImpl 中实现 getListByNameLike 方法 - 更新 DataMenuQueryDto,添加服务平台名称查询参数 - 优化查询 SQL,支持服务平台 ID 多对多查询dev
parent
015343fc62
commit
137e08b1d5
|
@ -50,8 +50,12 @@ public class DataMenuQueryDto extends PageDto {
|
|||
/**
|
||||
* 服务平台id
|
||||
*/
|
||||
@ApiModelProperty(value = "服务平台ids")
|
||||
private List<Integer> servicePlatformIds;
|
||||
@ApiModelProperty(value = "服务平台id")
|
||||
private Integer servicePlatformId;
|
||||
@ApiModelProperty(value = "服务平台名称")
|
||||
private String servicePlatformName;
|
||||
|
||||
/**
|
||||
* 推送状态(1.未推送,2.定时推送,3.推送成功,4.重试中,5.推送失败)
|
||||
|
|
|
@ -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.res.ServicePlatformResDto;
|
||||
import com.zcloud.modules.corp.entity.BusServicePlatformEntity;
|
||||
import com.zcloud.modules.corp.entity.BusThirdPlatformEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -28,5 +29,7 @@ public interface BusServicePlatformService extends IService<BusServicePlatformEn
|
|||
void deleteById(ServicePlatformReqDto req);
|
||||
|
||||
List<ServicePlatformResDto> listAll();
|
||||
|
||||
List<BusServicePlatformEntity> getListByName(String servicePlatformName);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,5 +34,7 @@ public interface BusThirdPlatformService extends IService<BusThirdPlatformEntity
|
|||
List<BusThirdPlatformEntity> getListByName(String thirdPlatformName);
|
||||
|
||||
List<BusThirdPlatformEntity> getListByIdList(List<Integer> idList);
|
||||
|
||||
List<BusThirdPlatformEntity> getListByNameLike(String fuzzyName);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.zcloud.modules.corp.service.BusServicePlatformService;
|
|||
import com.zcloud.modules.corp.service.BusServiceThirdRelationService;
|
||||
import com.zcloud.modules.corp.service.BusThirdPlatformService;
|
||||
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.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -152,5 +153,15 @@ public class BusServicePlatformServiceImpl extends ServiceImpl<BusServicePlatfor
|
|||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,13 @@ public class BusThirdPlatformServiceImpl extends ServiceImpl<BusThirdPlatformDao
|
|||
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
|
||||
public PageUtils queryPage(ThirdPlatformQueryDto req) {
|
||||
Page<BusThirdPlatformEntity> page = new Page<>(req.getCurPage(), req.getLimit());
|
||||
|
|
|
@ -76,6 +76,9 @@ public class BusDataServiceImpl implements BusDataService {
|
|||
List<BusCompanyInfoEntity> companyList = null;
|
||||
if (StringUtils.isNotEmpty(req.getCompanyName())) {
|
||||
companyList = companyInfoService.getListByName(req.getCompanyName());
|
||||
if (CollUtil.isEmpty(companyList)) {
|
||||
return new PageUtils(null, 0, req.getLimit(), req.getCurPage());
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(companyList)) {
|
||||
List<Integer> companyIds = companyList.stream().map(BusCompanyInfoEntity::getId).collect(Collectors.toList());
|
||||
req.setCompanyIds(companyIds);
|
||||
|
@ -85,12 +88,29 @@ public class BusDataServiceImpl implements BusDataService {
|
|||
List<BusThirdPlatformEntity> thirdList = null;
|
||||
if (StringUtils.isNotEmpty(req.getThirdPlatformName())) {
|
||||
thirdList = thirdPlatformService.getListByName(req.getThirdPlatformName());
|
||||
// 如果没有查询到结果,直接返回空结果
|
||||
if (CollUtil.isEmpty(thirdList)) {
|
||||
return new PageUtils(null, 0, req.getLimit(), req.getCurPage());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(thirdList)) {
|
||||
List<Integer> thirdIds = thirdList.stream().map(BusThirdPlatformEntity::getId).collect(Collectors.toList());
|
||||
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());
|
||||
if (total <= 0) {
|
||||
return new PageUtils(null, total, req.getLimit(), req.getCurPage());
|
||||
|
@ -129,9 +149,12 @@ public class BusDataServiceImpl implements BusDataService {
|
|||
resDto.setThirdPlatformName(thirdInfo.getPlatformName());
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
List<Integer> serviceIdList = result.stream().map(DataMenuResDto::getServicePlatformId).collect(Collectors.toList());
|
||||
List<Integer> serviceIdList;
|
||||
if(CollectionUtils.isNotEmpty(servicePlatformList)){
|
||||
serviceIdList = servicePlatformList.stream().map(BusServicePlatformEntity::getId).collect(Collectors.toList());
|
||||
}else {
|
||||
serviceIdList = result.stream().map(DataMenuResDto::getServicePlatformId).collect(Collectors.toList());
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(serviceIdList)) {
|
||||
LambdaQueryWrapper<BusServicePlatformEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(BusServicePlatformEntity::getId, serviceIdList);
|
||||
|
|
|
@ -132,7 +132,27 @@
|
|||
)
|
||||
</otherwise>
|
||||
</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>
|
||||
</sql>
|
||||
|
||||
|
|
Loading…
Reference in New Issue