# CompRoomComplimentaryController.java

    package cloud.wconnect.frontoffice.controller.comproom;

    import cloud.wconnect.commonlib.annotation.ApiId;
    import cloud.wconnect.commonlib.component.SessionContext;
    import cloud.wconnect.commonlib.cons.*;
    import cloud.wconnect.commonlib.exception.BadRequestException;
    import cloud.wconnect.commonlib.pojo.dto.ListPagedDTO;
    import cloud.wconnect.frontoffice.entity.comproom.CompRoomComplimentary;
    import cloud.wconnect.frontoffice.pojo.query.comproom.CompRoomComplimentaryQuery;
    import cloud.wconnect.frontoffice.service.comproom.ICompRoomComplimentaryService;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.*;

    import jakarta.validation.Valid;
    import java.text.MessageFormat;
    import java.util.*;

    /**
     * Comp Room功能 Guests In-House Complimentary报告 控制层
     *
     * @author lichen
     * @date 2023/8/7
     */
    @RestController
    @RequestMapping("/comp-room/guests-in-house-complimentary")
    public class CompRoomComplimentaryController {

        @Autowired
        private SessionContext sessionContext;
        @Autowired
        private ICompRoomComplimentaryService compRoomComplimentaryService;

        /**
         * 查询Guests In-House Complimentary报告的数据
         *
         * @param property 资产标识
         * @param query    查询对象
         * @return cloud.wconnect.commonlib.pojo.dto.ListPagedDTO<cloud.wconnect.frontoffice.entity.comproom.CompRoomComplimentary>
         * @author lichen
         * @date 2024/1/5
         */
        @ApiId(1015)
        @GetMapping
        public ListPagedDTO<CompRoomComplimentary> list(String property, @Valid CompRoomComplimentaryQuery query) {
            boolean isQueryCheckInDate = Objects.nonNull(query.getCheckInDateEnd()) && Objects.nonNull(query.getCheckInDateBegin());
            if(isQueryCheckInDate && query.getCheckInDateEnd() < query.getCheckInDateBegin()){
                throw new BadRequestException(CommonErrorI18nConstant.CHECK_IN_DATE_CANNOT_GREATER_THAN_CHECK_OUT_DATE,
                        BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getCode(),
                        MessageFormat.format("The end time must be greater than or equal to the start time, endTime:{0}, startTime:{1}",
                                query.getCheckInDateEnd(), query.getCheckInDateBegin()));
            }
            int propertyId = sessionContext.getPropertyId(property);

            return compRoomComplimentaryService.pageList(propertyId, query);
        }

    }