CompanyMemberMappingServiceImpl.java
4.03 KB
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
97
98
99
100
101
102
103
104
package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.subsidy.common.exception.HttpException;
import com.subsidy.dto.company.AttendMembersDTO;
import com.subsidy.dto.company.GetCompanyMembersDTO;
import com.subsidy.dto.company.InviteMemberDTO;
import com.subsidy.dto.member.CancerMemberDTO;
import com.subsidy.dto.member.DepartMembersDTO;
import com.subsidy.mapper.MemberDepartmentMappingMapper;
import com.subsidy.mapper.MemberMapper;
import com.subsidy.model.CompanyMemberMappingDO;
import com.subsidy.mapper.CompanyMemberMappingMapper;
import com.subsidy.model.MemberDO;
import com.subsidy.model.MemberDepartmentMappingDO;
import com.subsidy.service.CompanyMemberMappingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils;
import com.subsidy.util.excel.ExcelUtil;
import com.subsidy.vo.company.GetCompanyMembersVO;
import com.subsidy.vo.company.MemberCompanyVO;
import com.subsidy.vo.member.AttendMembersVO;
import com.subsidy.vo.member.DepartMembersVO;
import com.subsidy.vo.member.MemberAttendInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 公司人员映射表 服务实现类
* </p>
*
* @author Tuyp
* @since 2024-01-11
*/
@Service
public class CompanyMemberMappingServiceImpl extends ServiceImpl<CompanyMemberMappingMapper, CompanyMemberMappingDO> implements CompanyMemberMappingService {
@Autowired
private MemberDepartmentMappingMapper memberDepartmentMappingMapper;
@Autowired
private MemberMapper memberMapper;
public String inviteMember(InviteMemberDTO inviteMemberDTO) {
MemberDO memberDO = memberMapper.selectOne(new QueryWrapper<MemberDO>()
.lambda()
.eq(MemberDO::getUserName, inviteMemberDTO.getUserName())
.eq(MemberDO::getIdCard, inviteMemberDTO.getIdCard()));
if (null == memberDO) {
throw new HttpException(10011);
}
Integer count = this.baseMapper.selectCount(new QueryWrapper<CompanyMemberMappingDO>()
.lambda()
.eq(CompanyMemberMappingDO::getMemberId, memberDO.getId())
.eq(CompanyMemberMappingDO::getMemberStatus, 1));
if (count > 0) {
throw new HttpException(10028);
}
CompanyMemberMappingDO companyMemberMappingDO = new CompanyMemberMappingDO();
companyMemberMappingDO.setCompanyId(inviteMemberDTO.getCompanyId());
companyMemberMappingDO.setMemberId(memberDO.getId());
companyMemberMappingDO.setMemberStatus(1);
this.baseMapper.insert(companyMemberMappingDO);
MemberDepartmentMappingDO memberDepartmentMappingDO = new MemberDepartmentMappingDO();
memberDepartmentMappingDO.setDepartmentId(inviteMemberDTO.getDepartmentId());
memberDepartmentMappingDO.setMemberId(memberDO.getId());
memberDepartmentMappingDO.setMemberStatus(1);
memberDepartmentMappingMapper.insert(memberDepartmentMappingDO);
return ConstantUtils.ADD_SUCCESS;
}
public String cancerMember(CancerMemberDTO cancerMemberDTO) {
List<Long> members = cancerMemberDTO.getMemberIds();
for (Long memberId : members) {
CompanyMemberMappingDO companyMemberMappingDO1 = this.baseMapper.selectOne(new QueryWrapper<CompanyMemberMappingDO>()
.lambda()
.eq(CompanyMemberMappingDO::getCompanyId, cancerMemberDTO.getCompanyId())
.eq(CompanyMemberMappingDO::getMemberId, memberId)
.eq(CompanyMemberMappingDO::getMemberStatus, 1));
companyMemberMappingDO1.setMemberStatus(0);
this.baseMapper.updateById(companyMemberMappingDO1);
memberDepartmentMappingMapper.cancelMember(memberId);
}
return ConstantUtils.DELETE_SUCCESS;
}
}