package cn.ey.biz.module.system.dal.mapper.engagement.scope;

import cn.ey.biz.framework.mybatis.core.mapper.BaseMapperX;
import cn.ey.biz.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ey.biz.module.system.api.engagement.scope.dto.OpprScopeConfigReqDTO;
import cn.ey.biz.module.system.controller.engagement.scope.vo.OpprScopeConfigReqVO;
import cn.ey.biz.module.system.dal.dataobject.engagement.scope.SystemOpprScopeConfigDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;

@Mapper
public interface OpprScopeConfigMapper extends BaseMapperX<SystemOpprScopeConfigDO> {

    default List<SystemOpprScopeConfigDO> selectList(OpprScopeConfigReqVO opprScopeConfigReqVO) {
        return selectList(new LambdaQueryWrapperX<SystemOpprScopeConfigDO>()
                .eqIfPresent(SystemOpprScopeConfigDO::getServiceLine, opprScopeConfigReqVO.getServiceLine())
                .eqIfPresent(SystemOpprScopeConfigDO::getSubServiceLine, opprScopeConfigReqVO.getSubServiceLine())
                .eqIfPresent(SystemOpprScopeConfigDO::getCompetency, opprScopeConfigReqVO.getCompetency())
                .orderByDesc(SystemOpprScopeConfigDO::getId));
    }

    default List<SystemOpprScopeConfigDO> selectList(OpprScopeConfigReqDTO opprScopeConfigReqDTO) {
        return selectList(new LambdaQueryWrapperX<SystemOpprScopeConfigDO>()
                .eqIfPresent(SystemOpprScopeConfigDO::getManagementRegion, opprScopeConfigReqDTO.getManagementRegion())
                .eqIfPresent(SystemOpprScopeConfigDO::getServiceLine, opprScopeConfigReqDTO.getServiceLine())
                .eqIfPresent(SystemOpprScopeConfigDO::getSubServiceLine, opprScopeConfigReqDTO.getSubServiceLine())
                .eqIfPresent(SystemOpprScopeConfigDO::getCompetency, opprScopeConfigReqDTO.getCompetency())
                .orderByDesc(SystemOpprScopeConfigDO::getId));
    }

}
