# HotelServiceImpl.java

    package cloud.wconnect.rateshop.service.rateshop.impl;

    import cloud.wconnect.commonlib.cons.BaseErrorCodeEnum;
    import cloud.wconnect.commonlib.cons.CommonErrorI18nConstant;
    import cloud.wconnect.commonlib.exception.BadRequestException;
    import cloud.wconnect.rateshop.cons.rateshop.RateShopErrorI18nConstant;
    import cloud.wconnect.rateshop.entity.rateshop.Hotel;
    import cloud.wconnect.rateshop.mapper.rateshop.HotelMapper;
    import cloud.wconnect.rateshop.service.rateshop.IHotelService;
    import com.baomidou.dynamic.datasource.annotation.DS;
    import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
    import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
    import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
    import org.springframework.stereotype.Service;

    import java.util.Collection;
    import java.util.Collections;
    import java.util.List;
    import java.util.Objects;

    /**
     * <p>
     * 酒店 服务实现类
     * </p>
     *
     * @author lichen
     * @since 2023-06-07
     */
    @DS("rate_shop")
    @Service
    public class HotelServiceImpl extends ServiceImpl<HotelMapper, Hotel> implements IHotelService {

        /**
         * 校验目标酒店是否存在 且 状态正常
         *
         * @param symbol 酒店标识
         * @return Hotel 酒店信息
         * @author lichen
         * @date 2023/6/9
         */
        @Override
        public Hotel checkHotel(String symbol) {
            Hotel hotel = getOne(new LambdaQueryWrapper<Hotel>().eq(Hotel::getSymbol, symbol));
            if(Objects.isNull(hotel)){
                throw new BadRequestException(CommonErrorI18nConstant.DATA_NOT_FOUND,
                        BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getCode(),
                        "The hotel is not found; symbol: " + symbol);
            }
            if(!hotel.getState()){
                throw new BadRequestException(RateShopErrorI18nConstant.HOTEL_STATUS_NOT_NORMAL,
                        BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getCode(),
                        "The hotel state is inactive; symbol: " + symbol);
            }
            return hotel;
        }

        /**
         * 根据酒店标识查询酒店
         *
         * @param symbols 酒店标识
         * @return 酒店
         * @author yyt
         * @date 2024/3/27
         **/
        @Override
        public List<Hotel> listEffectiveBySymbols(Collection<String> symbols) {
            return list(new QueryWrapper<Hotel>().lambda().in(Hotel::getSymbol, symbols)
                    .eq(Hotel::getState, true));
        }

    }