package com.yc.ship.module.product.dal.mysql.pricevoyage;


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.product.controller.app.voyage.vo.AppRoomModelPriceRespVO;
import com.yc.ship.module.product.controller.app.voyage.vo.AppVoyageCalendarPriceReqVO;
import com.yc.ship.module.product.controller.app.voyage.vo.AppVoyageCalendarPriceRespVO;
import com.yc.ship.module.product.controller.app.voyage.vo.AppVoyageRespVO;
import com.yc.ship.module.product.dal.dataobject.pricevoyage.PriceVoyageDO;
import org.apache.ibatis.annotations.Mapper;
import com.yc.ship.module.product.controller.admin.pricevoyage.vo.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 航次价格 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface PriceVoyageMapper extends BaseMapperX<PriceVoyageDO> {

    default PageResult<PriceVoyageDO> selectPage(PriceVoyagePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PriceVoyageDO>()
                .likeIfPresent(PriceVoyageDO::getName, reqVO.getName())
                .eqIfPresent(PriceVoyageDO::getShipId, reqVO.getShipId())
                .eqIfPresent(PriceVoyageDO::getRouteId, reqVO.getRouteId())
                .eqIfPresent(PriceVoyageDO::getTemplateId, reqVO.getTemplateId())
                .eqIfPresent(PriceVoyageDO::getVoyageId, reqVO.getVoyageId())
                .eqIfPresent(PriceVoyageDO::getPriceMode, reqVO.getPriceMode())
                .betweenIfPresent(PriceVoyageDO::getValidateTime, reqVO.getValidateTime())
                .eqIfPresent(PriceVoyageDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(PriceVoyageDO::getCreateTime, reqVO.getCreateTime())
                .inIfPresent(PriceVoyageDO::getVoyageId, reqVO.getVoyageIds())
                .orderByDesc(PriceVoyageDO::getId));
    }

    default PriceVoyageDO selectByVoyageId(Long voyageId) {
        return selectOne(PriceVoyageDO::getVoyageId, voyageId);
    }

    default void deleteByVoyageId(Long voyageId) {
        delete(PriceVoyageDO::getVoyageId, voyageId);
    }

    List<AppVoyageCalendarPriceRespVO> selectListCalendarPrice(@Param("reqVO") AppVoyageCalendarPriceReqVO reqVO);

    List<AppRoomModelPriceRespVO> selectRoomModelListByVoyageId(@Param("voyageId") Long voyageId);
}