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


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yc.ship.module.product.controller.admin.voyagestockdistributeNew.vo.VoyageStockDistributeNewDetailReqVO;
import com.yc.ship.module.product.controller.app.voyage.vo.AppCanSelectRoomReqVO;
import com.yc.ship.module.product.dal.dataobject.voyagestockdistribute.VoyageStockDistributeRoomDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 航次库存分配 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface VoyageStockDistributeRoomMapper extends BaseMapperX<VoyageStockDistributeRoomDO> {


    default List<VoyageStockDistributeRoomDO> selectListByVoyageId(Long voyageId, Integer  type) {
        return selectList(new LambdaQueryWrapperX<VoyageStockDistributeRoomDO>()
                .eq(VoyageStockDistributeRoomDO::getVoyageId, voyageId)
                .eq(VoyageStockDistributeRoomDO::getType, type));
    }

    default void deleteByVoyageId(Long voyageId, Integer  type) {
        delete(new LambdaQueryWrapperX<VoyageStockDistributeRoomDO>()
                .eq(VoyageStockDistributeRoomDO::getVoyageId, voyageId)
                .eq(VoyageStockDistributeRoomDO::getType, type));
    }

    List<VoyageStockDistributeRoomDO> selectListByRoomModelIdAndFloor(@Param("objectId") Long objectId, @Param("voyageId") Long voyageId, @Param("roomModelIdFloorList") List<String> roomModelIdFloorList);

    default List<VoyageStockDistributeRoomDO> selectListByVoyageIdAndObjectId(VoyageStockDistributeNewDetailReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<VoyageStockDistributeRoomDO>()
                .eq(VoyageStockDistributeRoomDO::getVoyageId, reqVO.getVoyageId())
                .eqIfPresent(VoyageStockDistributeRoomDO::getObjectId, reqVO.getObjectId())
                .eqIfPresent(VoyageStockDistributeRoomDO::getDistributorId, reqVO.getDistributorId())
                .eq(VoyageStockDistributeRoomDO::getType, reqVO.getType()));
    }

    List<VoyageStockDistributeRoomDO> selectAppCanSelectRoomList(@Param("reqVO") AppCanSelectRoomReqVO reqVO);
}