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

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

/**
 * 资源管理-航线行程详细 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface ResourceRouteTripDetailMapper extends BaseMapperX<ResourceRouteTripDetailDO> {

    default PageResult<ResourceRouteTripDetailDO> selectPage(ResourceRouteTripDetailPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ResourceRouteTripDetailDO>()
                .eqIfPresent(ResourceRouteTripDetailDO::getRouteId, reqVO.getRouteId())
                .eqIfPresent(ResourceRouteTripDetailDO::getTripId, reqVO.getTripId())
                .betweenIfPresent(ResourceRouteTripDetailDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(ResourceRouteTripDetailDO::getEndTime, reqVO.getEmdTime())
                .eqIfPresent(ResourceRouteTripDetailDO::getContent, reqVO.getContent())
                .eqIfPresent(ResourceRouteTripDetailDO::getSort, reqVO.getSort())
                .eqIfPresent(ResourceRouteTripDetailDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ResourceRouteTripDetailDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ResourceRouteTripDetailDO::getId));
    }

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

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