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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ningdatech.carapi.common.aop.BuildChildrenRegionEntity;
import com.ningdatech.carapi.company.entity.NdCompanyProductManage;
import com.ningdatech.carapi.company.entity.dto.ResProductManageDTO;
import com.ningdatech.carapi.company.entity.po.CompanyProductPO;
import com.ningdatech.carapi.company.mapper.NdCompanyProductManageMapper;
import com.ningdatech.carapi.company.service.INdCompanyProductManageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.carapi.datascope.aop.XmlDataScope;
import lombok.RequiredArgsConstructor;
import org.springframework.aop.framework.AopContext;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 公司生产管理 服务实现类
 * </p>
 *
 * @author liushuai
 * @since 2022-10-10
 */
@Service
@RequiredArgsConstructor
public class NdCompanyProductManageServiceImpl extends ServiceImpl<NdCompanyProductManageMapper, NdCompanyProductManage> implements INdCompanyProductManageService {
    private final NdCompanyProductManageMapper ndCompanyProductManageMapper;

    @Override
    public Page<ResProductManageDTO> manageList(String companyName, Long regionId, int pageNum, int pageSize) {
        NdCompanyProductManageServiceImpl context = (NdCompanyProductManageServiceImpl)AopContext.currentProxy();
        return context.searchList(new Page<>(pageNum, pageSize),
                new CompanyProductPO(regionId, null, companyName, null));
    }

    @XmlDataScope(entityIndex = 1)
    @BuildChildrenRegionEntity(entityIndex = 1)
    public Page<ResProductManageDTO> searchList(Page<ResProductManageDTO> page,CompanyProductPO po){
        return ndCompanyProductManageMapper.manageList(page,po);
    }
}
