package com.yc.ship.module.resource.dal.mysql.port;

import java.util.*;

import com.yc.ship.framework.common.enums.CommonStatusEnum;
import com.yc.ship.framework.common.pojo.PageResult;
import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
import com.yc.ship.module.resource.dal.dataobject.port.ResourcePortDO;
import org.apache.ibatis.annotations.Mapper;
import com.yc.ship.module.resource.controller.admin.port.vo.*;

/**
 * 资源管理-口岸管理 Mapper
 *
 * @author lfy
 */
@Mapper
public interface ResourcePortMapper extends BaseMapperX<ResourcePortDO> {

    default PageResult<ResourcePortDO> selectPage(ResourcePortPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ResourcePortDO>()
                .likeIfPresent(ResourcePortDO::getName, reqVO.getName())
                .eqIfPresent(ResourcePortDO::getAddress, reqVO.getAddress())
                .eqIfPresent(ResourcePortDO::getProvinceId, reqVO.getProvinceId())
                .likeIfPresent(ResourcePortDO::getProvinceName, reqVO.getProvinceName())
                .eqIfPresent(ResourcePortDO::getRemark, reqVO.getRemark())
                .eqIfPresent(ResourcePortDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ResourcePortDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ResourcePortDO::getId));
    }

    default List<ResourcePortDO> selectEnableList() {
        return selectList(new LambdaQueryWrapperX<ResourcePortDO>()
                .eq(ResourcePortDO::getStatus, CommonStatusEnum.ENABLE.getStatus()));
    }
}