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

import java.util.*;

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

/**
 * 资源管理-航线行程 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface ResourceRouteTripMapper extends BaseMapperX<ResourceRouteTripDO> {

    default PageResult<ResourceRouteTripDO> selectPage(ResourceRouteTripPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ResourceRouteTripDO>()
                .eqIfPresent(ResourceRouteTripDO::getRouteId, reqVO.getRouteId())
                .eqIfPresent(ResourceRouteTripDO::getDayNum, reqVO.getDayNum())
                .likeIfPresent(ResourceRouteTripDO::getName, reqVO.getName())
                .eqIfPresent(ResourceRouteTripDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ResourceRouteTripDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ResourceRouteTripDO::getId));
    }

    default void deleteByRouteId(Long routeId) {
        delete(new LambdaQueryWrapperX<ResourceRouteTripDO>().eq(ResourceRouteTripDO::getRouteId, routeId));
    }

    default List<ResourceRouteTripDO> selectByRouteId(Long routeId) {
        return selectList(new LambdaQueryWrapperX<ResourceRouteTripDO>().eq(ResourceRouteTripDO::getRouteId, routeId));
    }
}