# RevenueHotelInfoConfigController.java

    package cloud.wconnect.rateshop.controller.revenue;

    import cloud.wconnect.commonlib.annotation.ApiId;
    import cloud.wconnect.commonlib.component.SessionContext;
    import cloud.wconnect.commonlib.cons.BaseErrorCodeEnum;
    import cloud.wconnect.commonlib.exception.BadRequestException;
    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("/revenue")
    public class RevenueHotelInfoConfigController {

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

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

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

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

            propertyHotelService.update(propertyId, hotels);

            return Collections.emptyMap();
        }

    }