package com.ningdatech.carapi.company.service.impl;

import org.springframework.aop.framework.AopContext;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.carapi.company.entity.CompanyCommonCredit;
import com.ningdatech.carapi.company.mapper.CompanyCommonCreditMapper;
import com.ningdatech.carapi.company.service.ICompanyCommonCreditService;
import com.ningdatech.carapi.datascope.aop.LambdaDataScope;
import com.ningdatech.carapi.datascope.contants.LambdaDataScopeTypeEnum;

/**
 * <p>
 * 企业公共信用信息 服务实现类
 * </p>
 *
 * @author liushuai
 * @since 2022-10-25
 */
@Service
public class CompanyCommonCreditServiceImpl extends ServiceImpl<CompanyCommonCreditMapper, CompanyCommonCredit> implements ICompanyCommonCreditService {

    @Override
    public Page<CompanyCommonCredit> getCompanyBasicCreditDetail(Page<CompanyCommonCredit> page, Long companyId) {
        LambdaQueryWrapper<CompanyCommonCredit> wrapper = Wrappers.lambdaQuery(CompanyCommonCredit.class);
        CompanyCommonCreditServiceImpl context = (CompanyCommonCreditServiceImpl) AopContext.currentProxy();
        context.buildQuery(wrapper, companyId);
        return page(page,wrapper);
    }

    @LambdaDataScope(type = LambdaDataScopeTypeEnum.ALL)
    public void buildQuery(LambdaQueryWrapper<CompanyCommonCredit> wrapper, Long companyId) {
        wrapper.eq(CompanyCommonCredit::getCompanyId,companyId);
    }
}
