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

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.dock.ResourceDockDO;
import org.apache.ibatis.annotations.Mapper;
import com.yc.ship.module.resource.controller.admin.dock.vo.*;

/**
 * 资源管理-口岸码头管理 Mapper
 *
 * @author lfy
 */
@Mapper
public interface ResourceDockMapper extends BaseMapperX<ResourceDockDO> {

    default PageResult<ResourceDockDO> selectPage(ResourceDockPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ResourceDockDO>()
                .likeIfPresent(ResourceDockDO::getName, reqVO.getName())
                .eqIfPresent(ResourceDockDO::getLongitude, reqVO.getLongitude())
                .eqIfPresent(ResourceDockDO::getLatitude, reqVO.getLatitude())
                .eqIfPresent(ResourceDockDO::getProvinceId, reqVO.getProvinceId())
                .likeIfPresent(ResourceDockDO::getProvinceName, reqVO.getProvinceName())
                .eqIfPresent(ResourceDockDO::getCityId, reqVO.getCityId())
                .likeIfPresent(ResourceDockDO::getCityName, reqVO.getCityName())
                .eqIfPresent(ResourceDockDO::getCountyId, reqVO.getCountyId())
                .likeIfPresent(ResourceDockDO::getCountyName, reqVO.getCountyName())
                .eqIfPresent(ResourceDockDO::getAddress, reqVO.getAddress())
                .eqIfPresent(ResourceDockDO::getPortId, reqVO.getPortId())
                .eqIfPresent(ResourceDockDO::getRemark, reqVO.getRemark())
                .eqIfPresent(ResourceDockDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ResourceDockDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ResourceDockDO::getId));
    }

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