| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package com.zsElectric.boot.charging.service.impl;
- import cn.hutool.core.util.StrUtil;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.zsElectric.boot.charging.entity.ThirdPartyStationInfo;
- import com.zsElectric.boot.charging.mapper.ThirdPartyStationInfoMapper;
- import com.zsElectric.boot.charging.model.query.ThirdPartyStationInfoQuery;
- import com.zsElectric.boot.charging.model.vo.ThirdPartyStationInfoVO;
- import com.zsElectric.boot.charging.service.ThirdPartyStationInfoService;
- import lombok.RequiredArgsConstructor;
- import org.springframework.beans.BeanUtils;
- import org.springframework.stereotype.Service;
- /**
- * 第三方充电站信息服务实现
- *
- * @author system
- * @since 2025-12-11
- */
- @Service
- @RequiredArgsConstructor
- public class ThirdPartyStationInfoServiceImpl implements ThirdPartyStationInfoService {
- private final ThirdPartyStationInfoMapper stationInfoMapper;
- @Override
- public IPage<ThirdPartyStationInfoVO> getStationInfoPage(ThirdPartyStationInfoQuery queryParams) {
- // 构建分页
- Page<ThirdPartyStationInfo> page = new Page<>(queryParams.getPageNum(), queryParams.getPageSize());
- // 构建查询条件
- LambdaQueryWrapper<ThirdPartyStationInfo> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(StrUtil.isNotBlank(queryParams.getStationId()), ThirdPartyStationInfo::getStationId, queryParams.getStationId())
- .like(StrUtil.isNotBlank(queryParams.getStationName()), ThirdPartyStationInfo::getStationName, queryParams.getStationName())
- .eq(StrUtil.isNotBlank(queryParams.getAreaCode()), ThirdPartyStationInfo::getAreaCode, queryParams.getAreaCode())
- .eq(StrUtil.isNotBlank(queryParams.getEquipmentOwnerId()), ThirdPartyStationInfo::getEquipmentOwnerId, queryParams.getEquipmentOwnerId())
- .eq(queryParams.getStationStatus() != null && queryParams.getStationStatus() != 0, ThirdPartyStationInfo::getStationStatus, queryParams.getStationStatus())
- .eq(queryParams.getStationType() != null && queryParams.getStationType() != 0, ThirdPartyStationInfo::getStationType, queryParams.getStationType())
- .eq(StrUtil.isNotBlank(queryParams.getServiceTel()), ThirdPartyStationInfo::getServiceTel, queryParams.getServiceTel())
- .orderByDesc(ThirdPartyStationInfo::getUpdateTime);
- // 查询
- Page<ThirdPartyStationInfo> stationPage = stationInfoMapper.selectPage(page, queryWrapper);
- // 实体转换
- Page<ThirdPartyStationInfoVO> voPage = new Page<>(stationPage.getCurrent(), stationPage.getSize(), stationPage.getTotal());
- voPage.setRecords(stationPage.getRecords().stream().map(entity -> {
- ThirdPartyStationInfoVO vo = new ThirdPartyStationInfoVO();
- BeanUtils.copyProperties(entity, vo);
- return vo;
- }).toList());
- return voPage;
- }
- }
|