CompanyMemberMappingServiceImpl.java 3.41 KB
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.dto.company.AttendMembersDTO;
import com.subsidy.dto.member.CancerMemberDTO;
import com.subsidy.dto.member.DepartMembersDTO;
import com.subsidy.mapper.MemberDepartmentMappingMapper;
import com.subsidy.model.CompanyMemberMappingDO;
import com.subsidy.mapper.CompanyMemberMappingMapper;
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.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;

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

    public IPage<DepartMembersVO> departMembers(DepartMembersDTO departMembersDTO) {
        Page pager = new Page(departMembersDTO.getPageNum(), departMembersDTO.getPageSize());
        return this.baseMapper.departMembers(pager, departMembersDTO.getCompanyId(), departMembersDTO.getUserName());
    }

    public void exportDepartMembers(DepartMembersDTO departMembersDTO) {
        Page pager = new Page(1, -1);
        IPage<DepartMembersVO> departMembersVOIPage = this.baseMapper.departMembers(pager, departMembersDTO.getCompanyId(), departMembersDTO.getUserName());
        List<DepartMembersVO> departMembersVOS = departMembersVOIPage.getRecords();
        ExcelUtil.writeExcel(departMembersVOS, DepartMembersVO.class);
    }

    public IPage<AttendMembersVO> attendMembers(AttendMembersDTO attendMembersDTO) {
        Page pager = new Page(attendMembersDTO.getPageNum(), attendMembersDTO.getPageSize());
        return this.baseMapper.attendMembers(pager, attendMembersDTO.getCompanyId(), attendMembersDTO.getDepartmentId(), attendMembersDTO.getUserName());
    }

    public List<MemberAttendInfoVO> memberAttendInfo(CompanyMemberMappingDO companyMemberMappingDO) {
        return this.baseMapper.memberAttendInfo(companyMemberMappingDO.getMemberId(),companyMemberMappingDO.getCompanyId());
    }


}