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

import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yc.ship.module.product.dal.dataobject.priceroommodel.PriceRoomModelDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 价格模板中房型加价设置 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface PriceRoomModelMapper extends BaseMapperX<PriceRoomModelDO> {

    default List<PriceRoomModelDO> selectListByObjectId(Long objectId) {
        return selectList(new LambdaQueryWrapperX<PriceRoomModelDO>()
                .eqIfPresent(PriceRoomModelDO::getObjectId, objectId));
    }

    default void deleteByObjectId(Long objectId) {
        delete(new LambdaQueryWrapperX<PriceRoomModelDO>()
                .eqIfPresent(PriceRoomModelDO::getObjectId, objectId));
    }

    default PriceRoomModelDO selectListByObjectIdAndRoomModelId(Long id, Long roomModelId) {
        return selectOne(new LambdaQueryWrapperX<PriceRoomModelDO>()
                .eqIfPresent(PriceRoomModelDO::getObjectId, id)
                .eqIfPresent(PriceRoomModelDO::getRoomModelId, roomModelId)
                .last("limit 1"));
    }
}