linwe
2024-05-29 c10d6358b9f014375a13821465bc978d0c0da22e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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<PartyOrganizationMemberMapper, PartyOrganizationMember> implements IPartyOrganizationMemberService {
 
    @Autowired
    private IUserHouseLabelService userHouseLabelService;
 
    @Autowired
    private ILabelService labelService;
 
    @Override
    public IPage<PartyOrganizationMemberVO> getPage(IPage<PartyOrganizationMemberVO> 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<Long> toLongList) {
 
        //把userhouselabel中的数据删除
        List<PartyOrganizationMember> partyOrganizationMembers = listByIds(toLongList);
 
        //循环删除
        partyOrganizationMembers.forEach(partyOrganizationMember ->{
            userHouseLabelService.removeById(partyOrganizationMember.getUserHouseLabelId());
        });
 
        //删自己
        return removeBatchByIds(toLongList);
    }
 
}