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

import java.util.List;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.carapi.common.aop.BuildChildrenRegionWrapper;
import com.ningdatech.carapi.company.entity.CompanySecurityProductExecute;
import com.ningdatech.carapi.company.entity.dto.CompanySecurityProductExecuteParam;
import com.ningdatech.carapi.company.mapper.CompanySecurityProductExecuteFileMapper;
import com.ningdatech.carapi.company.service.ICompanySecurityProductExecuteFileService;
import com.ningdatech.carapi.datascope.aop.LambdaDataScope;
import com.ningdatech.carapi.datascope.contants.LambdaDataScopeTypeEnum;

/**
 * <p>
 * 安全生产制度执行 服务实现类
 * </p>
 *
 * @author CMM
 * @since 2023-05-24
 */
@Service
public class CompanySecurityProductExecuteFileServiceImpl extends ServiceImpl<CompanySecurityProductExecuteFileMapper, CompanySecurityProductExecute> implements ICompanySecurityProductExecuteFileService {

    @Override
    @BuildChildrenRegionWrapper(wrapperIndex = 1,entityIndex = 2)
    @LambdaDataScope(wrapperIndex = 1,type = LambdaDataScopeTypeEnum.ONLY_REGION)
    public Page<CompanySecurityProductExecute> pageDataScope(Page<CompanySecurityProductExecute> page, LambdaQueryWrapper<CompanySecurityProductExecute> wrapper, CompanySecurityProductExecuteParam param) {
        return page(page,wrapper);
    }

    @Override
    @BuildChildrenRegionWrapper
    @LambdaDataScope(type = LambdaDataScopeTypeEnum.ONLY_REGION)
    public List<CompanySecurityProductExecute> dataScopeList(LambdaQueryWrapper<CompanySecurityProductExecute> wrapper, CompanySecurityProductExecuteParam param) {
        return baseMapper.selectList(wrapper);
    }

    @Override
    public void deleteById(Long id) {
        baseMapper.deleteById(id);
    }

    @Override
    public Boolean incrementDownCount(Long id) {
        return baseMapper.incrementDownCount(id) > 0;
    }
}
