# UpdateRateDTO.java

    package cloud.wconnect.rateshop.pojo.dto.revenue;

    import com.google.common.collect.Lists;
    import lombok.Data;
    import lombok.ToString;
    import org.apache.commons.lang3.StringUtils;
    import org.hibernate.validator.constraints.Range;

    import jakarta.validation.constraints.NotBlank;
    import jakarta.validation.constraints.NotNull;
    import jakarta.validation.constraints.Pattern;
    import java.util.ArrayList;
    import java.util.Objects;

    /**
     * DTO: Update Rate
     *
     * @author: yyt
     * 2024-03-26
     */
    @Data
    @ToString
    public class UpdateRateDTO {

        /**
         * 酒店标识
         */
        @NotBlank(message = "the hotelSymbol must not be blank")
        private String hotelSymbol;

        /**
         * 平台 id
         */
        private Integer platformId;

        /**
         * 数据日期（YYYY-MM-DD）
         */
        @NotBlank(message = "the checkInDate must not be blank")
        @Pattern(regexp = "\\d{4}-\\d{2}-\\d{2}", message = "the checkInDate format error, right format is [YYYY-MM-DD]")
        private String checkInDate;

        /**
         * 房价
         */
        private String price;

        /**
         * 房价类型1-早鸟价 2-BAR房价
         */
        @NotNull(message = "The rateType cannot be null")
        @Range(min = 1, max = 2, message = "The rateType must between in [1:early bird rate 2:best available rate]")
        private Integer rateType;

        /**
         * 生成唯一key
         *
         * @return java.lang.String
         * @author lichen
         * @date 2025/1/3
         */
        public String generateKey() {
            //价格
            String priceStr = "";
            if (StringUtils.isNotBlank(price)) {
                priceStr = price;
            }

            //平台
            String platformIdStr = "";
            if (Objects.nonNull(platformId)) {
                platformIdStr = platformId.toString();
            }
            //集合
            ArrayList<String> list = Lists.newArrayList(hotelSymbol, platformIdStr, checkInDate, priceStr, rateType.toString());
            return StringUtils.join(list, "_");
        }

    }