package cn.iocoder.yudao.module.energy.dal.mysql.config;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.energy.controller.admin.config.vo.EnergyStationConfigPageReqVO;
import cn.iocoder.yudao.module.energy.dal.dataobject.config.EnergyStationConfigDO;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface EnergyStationConfigMapper extends BaseMapperX<EnergyStationConfigDO> {

    default EnergyStationConfigDO selectByStationId(Long stationId) {
        return selectOne(EnergyStationConfigDO::getStationId, stationId);
    }

    default PageResult<EnergyStationConfigDO> selectPage(EnergyStationConfigPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EnergyStationConfigDO>()
                .eqIfPresent(EnergyStationConfigDO::getStationId, reqVO.getStationId())
                .eqIfPresent(EnergyStationConfigDO::getAutoDeduct, reqVO.getAutoDeduct())
                .eqIfPresent(EnergyStationConfigDO::getCooperationType, reqVO.getCooperationType())
                .orderByDesc(EnergyStationConfigDO::getId));
    }

}
