linwe
2024-08-07 06df33f156924c564c17b11fdb96c5bb298a810d
src/main/java/org/springblade/modules/house/service/impl/UserHouseLabelServiceImpl.java
@@ -18,7 +18,10 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.logging.log4j.util.Strings;
import org.springblade.common.utils.SpringUtils;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.modules.house.dto.UserHouseLabelDTO;
import org.springblade.modules.house.entity.UserHouseLabelEntity;
@@ -26,13 +29,16 @@
import org.springblade.modules.house.mapper.UserHouseLabelMapper;
import org.springblade.modules.house.service.IUserHouseLabelService;
import org.springblade.modules.house.vo.HouseholdLabelVO;
import org.springblade.modules.house.vo.UserHouseLabelVO;
import org.springblade.modules.label.entity.LabelEntity;
import org.springblade.modules.label.service.ILabelService;
import org.springblade.modules.label.service.impl.LabelServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
 * 住户-标签 服务实现类
@@ -61,8 +67,10 @@
   @Override
   public boolean saveOrUpdateHouseholdLabel(UserHouseLabelEntity householdLabel) {
      // 查询标签名称
      LabelEntity labelEntity = labelService.getById(householdLabel.getLabelId());
      householdLabel.setLabelName(labelEntity.getLabelName());
      if (!Strings.isBlank(householdLabel.getLabelName())) {
         LabelEntity labelEntity = labelService.getById(householdLabel.getLabelId());
         householdLabel.setLabelName(labelEntity.getLabelName());
      }
      // 判断同一个住户同一个标签是否已存在,已存在则更新,不存在则新增
      QueryWrapper<UserHouseLabelEntity> queryWrapper = new QueryWrapper<>();
      queryWrapper.eq("household_id", householdLabel.getHouseholdId())
@@ -74,7 +82,7 @@
         return updateById(householdLabel);
      }
      // 插入
      return save(householdLabel);
      return saveOrUpdate(householdLabel);
   }
   @Override
@@ -94,6 +102,21 @@
   @Override
   public IPage<HouseholdLabelVO> statisticalLabels(IPage<HouseholdLabelVO> page, HouseholdLabelVO householdLabel) {
      return page.setRecords(baseMapper.statisticalLabels(page, householdLabel));
   }
   @Override
   public IPage<HouseholdLabelVO> orgStatisticalLabels(IPage<HouseholdLabelVO> page, HouseholdLabelVO householdLabel) {
      return page.setRecords(baseMapper.orgStatisticalLabels(page, householdLabel));
   }
   @Override
   public IPage<HouseholdLabelVO> unitedFrontStatisticalLabels(IPage<HouseholdLabelVO> page, HouseholdLabelVO householdLabel) {
      return page.setRecords(baseMapper.unitedFrontStatisticalLabels(page, householdLabel));
   }
   @Override
   public IPage<HouseholdLabelVO> followStatisticalLabels(IPage<HouseholdLabelVO> page, HouseholdLabelVO householdLabel) {
      return page.setRecords(baseMapper.followStatisticalLabels(page, householdLabel));
   }
   @Override
@@ -123,4 +146,19 @@
      // 插入
      return save(userHouseLabelEntity);
   }
   /**
    * 查询对应的label集合信息
    * @param labelName
    * @return
    */
   @Override
   public List<UserHouseLabelEntity> getLabelList(String labelName) {
      return baseMapper.getLabelList(labelName);
   }
   @Override
   public List<UserHouseLabelEntity> getUserHouseLabelList(UserHouseLabelVO userHouseLabelVO) {
      return baseMapper.getUserHouseLabelList(userHouseLabelVO);
   }
}