package org.springblade.modules.partyOrganization.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.tool.utils.DateUtil; import org.springblade.modules.house.entity.UserHouseLabelEntity; import org.springblade.modules.house.service.IUserHouseLabelService; import org.springblade.modules.label.entity.LabelEntity; import org.springblade.modules.label.service.ILabelService; import org.springblade.modules.partyOrganization.entity.PartyOrganization; import org.springblade.modules.partyOrganization.entity.PartyOrganizationMember; import org.springblade.modules.partyOrganization.mapper.PartyOrganizationMapper; import org.springblade.modules.partyOrganization.mapper.PartyOrganizationMemberMapper; import org.springblade.modules.partyOrganization.service.IPartyOrganizationMemberService; import org.springblade.modules.partyOrganization.service.IPartyOrganizationService; import org.springblade.modules.partyOrganization.vo.PartyOrganizationMemberVO; import org.springblade.modules.partyOrganization.vo.PartyOrganizationVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; @Service @Transactional(rollbackFor = Exception.class) public class PartyOrganizationMemberServiceImpl extends BaseServiceImpl implements IPartyOrganizationMemberService { @Autowired private IUserHouseLabelService userHouseLabelService; @Autowired private ILabelService labelService; @Override public IPage getPage(IPage page, PartyOrganizationMemberVO partyOrganizationMemberVO) { return page.setRecords(baseMapper.getPage(page,partyOrganizationMemberVO)); } @Override public Boolean addVO(PartyOrganizationMemberVO partyOrganizationMember) { UserHouseLabelEntity userHouseLabelEntity = new UserHouseLabelEntity(); userHouseLabelEntity.setHouseCode(partyOrganizationMember.getHouseCode()); userHouseLabelEntity.setLabelId(Long.parseLong(partyOrganizationMember.getPartyMemberType())); userHouseLabelEntity.setColor("green"); userHouseLabelEntity.setLableType(1); userHouseLabelEntity.setHouseholdId(Long.parseLong(partyOrganizationMember.getHouseholdId())); userHouseLabelEntity.setCreateTime(DateUtil.now()); LabelEntity labelDetail = labelService.getById(partyOrganizationMember.getPartyMemberType()); userHouseLabelEntity.setLabelName(labelDetail.getLabelName()); boolean saveUserLabel = userHouseLabelService.save(userHouseLabelEntity); partyOrganizationMember.setUserHouseLabelId(userHouseLabelEntity.getId().toString()); boolean saveMember = save(partyOrganizationMember); return saveUserLabel&&saveMember; } @Override public Boolean editVO(PartyOrganizationMemberVO partyOrganizationMember) { UserHouseLabelEntity userHouseLabelEntity = userHouseLabelService.getById(partyOrganizationMember.getUserHouseLabelId()); //更新userhouselabel标签 LabelEntity labelDetail = labelService.getById(partyOrganizationMember.getPartyMemberType()); userHouseLabelEntity.setLabelName(labelDetail.getLabelName()); userHouseLabelEntity.setLabelId(Long.parseLong(partyOrganizationMember.getPartyMemberType())); boolean updateLabel = userHouseLabelService.updateById(userHouseLabelEntity); //更新党员信息 boolean updateMember = updateById(partyOrganizationMember); return updateLabel&&updateMember; } @Override public Boolean delete(List toLongList) { //把userhouselabel中的数据删除 List partyOrganizationMembers = listByIds(toLongList); //循环删除 partyOrganizationMembers.forEach(partyOrganizationMember ->{ userHouseLabelService.removeById(partyOrganizationMember.getUserHouseLabelId()); }); //删自己 return removeBatchByIds(toLongList); } }