| | |
| | | */ |
| | | package org.springblade.modules.house.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.common.node.TreeNode; |
| | | import org.springblade.modules.house.entity.HouseLabelEntity; |
| | | import org.springblade.modules.house.entity.HouseholdLabelEntity; |
| | | import org.springblade.modules.house.vo.HouseholdLabelVO; |
| | | import org.springblade.modules.house.mapper.HouseholdLabelMapper; |
| | | import org.springblade.modules.house.service.IHouseholdLabelService; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.modules.label.entity.LabelEntity; |
| | | import org.springblade.modules.label.service.ILabelService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | |
| | |
| | | @Service |
| | | public class HouseholdLabelServiceImpl extends ServiceImpl<HouseholdLabelMapper, HouseholdLabelEntity> implements IHouseholdLabelService { |
| | | |
| | | |
| | | @Autowired |
| | | private ILabelService labelService; |
| | | |
| | | @Override |
| | | public IPage<HouseholdLabelVO> selectHouseholdLabelPage(IPage<HouseholdLabelVO> page, HouseholdLabelVO householdLabel) { |
| | | return page.setRecords(baseMapper.selectHouseholdLabelPage(page, householdLabel)); |
| | | } |
| | | |
| | | /** |
| | | * 住户-标签 自定义新增或修改 |
| | | * @param householdLabel |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean saveOrUpdateHouseholdLabel(HouseholdLabelEntity householdLabel) { |
| | | // 查询标签名称 |
| | | LabelEntity labelEntity = labelService.getById(householdLabel.getLabelId()); |
| | | householdLabel.setLabelName(labelEntity.getLabelName()); |
| | | // 判断同一个住户同一个标签是否已存在,已存在则更新,不存在则新增 |
| | | QueryWrapper<HouseholdLabelEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("household_id",householdLabel.getHouseholdId()) |
| | | .eq("label_id",householdLabel.getLabelId()); |
| | | HouseholdLabelEntity one = getOne(queryWrapper); |
| | | if (null != one){ |
| | | // 更新 |
| | | return updateById(householdLabel); |
| | | } |
| | | // 插入 |
| | | return save(householdLabel); |
| | | } |
| | | } |