# RateShopHotelInfoConfigController.java

    package cloud.wconnect.rateshop.controller.rateshop;

    import cloud.wconnect.commonlib.annotation.ApiId;
    import cloud.wconnect.commonlib.component.SessionContext;
    import cloud.wconnect.commonlib.cons.BaseErrorCodeEnum;
    import cloud.wconnect.commonlib.cons.CommonErrorI18nConstant;
    import cloud.wconnect.commonlib.exception.BadRequestException;
    import cloud.wconnect.commonlib.util.I18nMessageUtils;
    import cloud.wconnect.rateshop.pojo.dto.revenue.HotelDTO;
    import cloud.wconnect.rateshop.service.rateshop.IPropertyHotelService;
    import jakarta.validation.Valid;
    import org.apache.commons.collections.CollectionUtils;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.*;

    import java.util.Collections;
    import java.util.List;
    import java.util.Map;

    /**
     * 控制车：Hotel Info Config
     *
     * @author: yyt
     * 2024-04-09
     */
    @RestController
    @RequestMapping("/rate-shop")
    public class RateShopHotelInfoConfigController {

        @Autowired
        private SessionContext sessionContext;
        @Autowired
        private IPropertyHotelService propertyHotelService;
        @Autowired
        private I18nMessageUtils i18nMessageUtils;

        /**
         * 获取酒店信息设置
         *
         * @param property 资产标识
         * @return java.util.List<cloud.wconnect.rateshop.pojo.dto.revenue.HotelDTO>
         * @author lichen
         * @date 2025/5/16
         */
        @ApiId(1513)
        @GetMapping("/hotel-info-config")
        public List<HotelDTO> list(String property) {
            int propertyId = sessionContext.getPropertyId(property);
            return propertyHotelService.listHotelDTOByPropertyId(propertyId);
        }

        /**
         * 编辑酒店信息设置
         *
         * @param property 资产标识
         * @param hotels   酒店信息设置
         * @return java.util.Map
         * @author lichen
         * @date 2025/5/16
         */
        @ApiId(1514)
        @PutMapping("/hotel-info-config")
        public Map update(String property, @RequestBody @Valid List<HotelDTO> hotels) {
            if (CollectionUtils.isEmpty(hotels)) {
                throw new BadRequestException(CommonErrorI18nConstant.CANNOT_EMPTY,
                        i18nMessageUtils.getErrorParamMapNotNeedTranslate("hotels"),
                        BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getCode(), "the hotels must not be empty");
            }

            // 检查 hotel 是否属于当前资产
            int propertyId = sessionContext.getPropertyId(property);
            propertyHotelService.checkAffiliation(hotels.stream().map(HotelDTO::getHotelId).toList(), propertyId);

            propertyHotelService.update(propertyId, hotels);

            return Collections.emptyMap();
        }

    }