ThirdPartyInfoServiceImpl.java 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package com.zsElectric.boot.business.service.impl;
  2. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  3. import com.zsElectric.boot.business.mapper.ThirdPartyInfoMapper;
  4. import com.zsElectric.boot.business.model.entity.ThirdPartyInfo;
  5. import com.zsElectric.boot.business.model.form.ThirdPartyInfoForm;
  6. import com.zsElectric.boot.business.model.query.ThirdPartyInfoQuery;
  7. import com.zsElectric.boot.business.model.vo.PartyStationInfoVO;
  8. import com.zsElectric.boot.business.model.vo.ThirdPartyInfoVO;
  9. import com.zsElectric.boot.business.service.ThirdPartyInfoService;
  10. import lombok.RequiredArgsConstructor;
  11. import lombok.extern.slf4j.Slf4j;
  12. import org.springframework.beans.BeanUtils;
  13. import org.springframework.stereotype.Service;
  14. import java.util.List;
  15. import java.util.stream.Collectors;
  16. /**
  17. * 第三方对接信息服务实现
  18. *
  19. * @author system
  20. * @since 2025-12-15
  21. */
  22. @Slf4j
  23. @Service
  24. @RequiredArgsConstructor
  25. public class ThirdPartyInfoServiceImpl implements ThirdPartyInfoService {
  26. private final ThirdPartyInfoMapper thirdPartyInfoMapper;
  27. @Override
  28. public Page<ThirdPartyInfoVO> getThirdPartyInfoPage(ThirdPartyInfoQuery queryParams) {
  29. // 构建分页
  30. Page<ThirdPartyInfoVO> page = new Page<>(queryParams.getPageNum(), queryParams.getPageSize());
  31. // 调用Mapper分页查询
  32. return thirdPartyInfoMapper.selectThirdPartyInfoPage(page, queryParams);
  33. }
  34. @Override
  35. public ThirdPartyInfoVO getThirdPartyInfoById(Long id) {
  36. ThirdPartyInfo entity = thirdPartyInfoMapper.selectById(id);
  37. if (entity == null) {
  38. return null;
  39. }
  40. ThirdPartyInfoVO vo = new ThirdPartyInfoVO();
  41. BeanUtils.copyProperties(entity, vo);
  42. return vo;
  43. }
  44. @Override
  45. public boolean addThirdPartyInfo(ThirdPartyInfoForm form) {
  46. ThirdPartyInfo entity = new ThirdPartyInfo();
  47. BeanUtils.copyProperties(form, entity);
  48. return thirdPartyInfoMapper.insert(entity) > 0;
  49. }
  50. @Override
  51. public boolean updateThirdPartyInfo(ThirdPartyInfoForm form) {
  52. if (form.getId() == null) {
  53. throw new IllegalArgumentException("ID不能为空");
  54. }
  55. ThirdPartyInfo entity = new ThirdPartyInfo();
  56. BeanUtils.copyProperties(form, entity);
  57. return thirdPartyInfoMapper.updateById(entity) > 0;
  58. }
  59. @Override
  60. public boolean deleteThirdPartyInfo(Long id) {
  61. return thirdPartyInfoMapper.deleteById(id) > 0;
  62. }
  63. @Override
  64. public List<PartyStationInfoVO> getPartyStationInfoList() {
  65. List<ThirdPartyInfo> thirdPartyInfos = thirdPartyInfoMapper.selectList(null);
  66. // 转换为VO列表
  67. return thirdPartyInfos.stream()
  68. .map(info -> {
  69. PartyStationInfoVO vo = new PartyStationInfoVO();
  70. vo.setId(info.getId());
  71. vo.setStationName(info.getEcName());
  72. return vo;
  73. })
  74. .collect(Collectors.toList());
  75. }
  76. }