Blame view

CompanyMemberMappingServiceImpl.java 4.03 KB
涂亚平 committed
1 2 3 4 5
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;
6
import com.subsidy.common.exception.HttpException;
涂亚平 committed
7
import com.subsidy.dto.company.AttendMembersDTO;
涂亚平 committed
8
import com.subsidy.dto.company.GetCompanyMembersDTO;
9
import com.subsidy.dto.company.InviteMemberDTO;
涂亚平 committed
10 11 12
import com.subsidy.dto.member.CancerMemberDTO;
import com.subsidy.dto.member.DepartMembersDTO;
import com.subsidy.mapper.MemberDepartmentMappingMapper;
13
import com.subsidy.mapper.MemberMapper;
涂亚平 committed
14 15
import com.subsidy.model.CompanyMemberMappingDO;
import com.subsidy.mapper.CompanyMemberMappingMapper;
16 17
import com.subsidy.model.MemberDO;
import com.subsidy.model.MemberDepartmentMappingDO;
涂亚平 committed
18 19 20 21
import com.subsidy.service.CompanyMemberMappingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils;
import com.subsidy.util.excel.ExcelUtil;
涂亚平 committed
22 23
import com.subsidy.vo.company.GetCompanyMembersVO;
import com.subsidy.vo.company.MemberCompanyVO;
涂亚平 committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
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;

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
    @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;
    }

涂亚平 committed
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
    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;
    }

涂亚平 committed
103

涂亚平 committed
104
}