Blame view

ServiceCompanyMappingServiceImpl.java 3.06 KB
涂亚平 committed
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
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.GetServiceCompaniesDTO;
import com.subsidy.dto.service.CancelAuthDTO;
import com.subsidy.dto.service.GetServiceCompaniesVO;
import com.subsidy.dto.service.ServiceCompaniesVO;
import com.subsidy.model.ServiceCompanyMappingDO;
import com.subsidy.mapper.ServiceCompanyMappingMapper;
import com.subsidy.service.ServiceCompanyMappingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 业务公司 映射表 服务实现类
 * </p>
 *
 * @author Tuyp
 * @since 2024-01-11
 */
@Service
public class ServiceCompanyMappingServiceImpl extends ServiceImpl<ServiceCompanyMappingMapper, ServiceCompanyMappingDO> implements ServiceCompanyMappingService {


    public IPage<GetServiceCompaniesVO> getServiceCompanies(GetServiceCompaniesDTO getServiceCompaniesDTO) {
        Page pager = new Page(getServiceCompaniesDTO.getPageNum(), getServiceCompaniesDTO.getPageSize());
        return this.baseMapper.getServiceCompanies(pager, getServiceCompaniesDTO.getServiceId(), getServiceCompaniesDTO.getCompanyName(), getServiceCompaniesDTO.getAuthStatus());
    }

    @Transactional(rollbackFor = Exception.class)
    public String cancelAuth(CancelAuthDTO cancelAuthDTO) {
        List<Long> companyIds = cancelAuthDTO.getCompanyIds();
        for (Long companyId : companyIds) {
            this.baseMapper.delete(new QueryWrapper<ServiceCompanyMappingDO>()
                    .lambda()
                    .eq(ServiceCompanyMappingDO::getCompanyId, companyId)
                    .eq(ServiceCompanyMappingDO::getServiceId, cancelAuthDTO.getServiceId()));
        }
        return ConstantUtils.DELETE_SUCCESS;
    }

    @Transactional(rollbackFor = Exception.class)
    public String addAuth(CancelAuthDTO cancelAuthDTO) {
        List<Long> companyIds = cancelAuthDTO.getCompanyIds();
        for (Long companyId : companyIds) {
            this.baseMapper.delete(new QueryWrapper<ServiceCompanyMappingDO>()
            .lambda()
            .eq(ServiceCompanyMappingDO::getCompanyId,companyId)
            .eq(ServiceCompanyMappingDO::getServiceId,cancelAuthDTO.getServiceId()));
            ServiceCompanyMappingDO serviceCompanyMappingDO = new ServiceCompanyMappingDO();
            serviceCompanyMappingDO.setCompanyId(companyId);
            serviceCompanyMappingDO.setServiceId(cancelAuthDTO.getServiceId());
            this.baseMapper.insert(serviceCompanyMappingDO);
        }
        return ConstantUtils.ADD_SUCCESS;
    }

    public List<ServiceCompaniesVO> serviceCompanies(GetServiceCompaniesDTO getServiceCompaniesDTO) {
        return this.baseMapper.serviceCompanies(getServiceCompaniesDTO.getServiceId(),getServiceCompaniesDTO.getCompanyName());
    }


}