# RoomTypeEnum.java

    package cloud.wconnect.rateshop.cons.budgetdatabase;

    import lombok.AllArgsConstructor;
    import lombok.Getter;

    import java.util.Map;

    /**
     * @author: yyt
     * 2025-08-14
     */
    @AllArgsConstructor
    @Getter
    public enum RoomTypeEnum {

        // 注意：增加类型时，需要修改 DESC_BY_CODE，i18nDescByDesc，ROW_ID_BY_CODE，同时需要改导出模板
        // 1.transient，2.group，3.contract, 0.total
        TRANSIENT(1, "transient", "subtotal-transient", -1),
        GROUP(2, "group", "subtotal-group", -2),
        CONTRACT(3, "contract", "subtotal-contract", -3),
        TOTAL(0, "total", "budget-database.total", 0);

        private final Integer code;
        private final String desc;
        private final String i18nDesc;
        private final Integer rowId;
        public static final Map<Integer, String> DESC_BY_CODE = Map.of(TRANSIENT.getCode(), TRANSIENT.getDesc(),
                GROUP.getCode(), GROUP.getDesc(), CONTRACT.getCode(), CONTRACT.getDesc(),
                TOTAL.getCode(), TOTAL.getDesc());
        // 不可使用 final，因为国际化翻译后，值会改变
        public static Map<String, String> i18nDescByDesc = Map.of(TRANSIENT.getDesc(), TRANSIENT.getI18nDesc(),
                GROUP.getDesc(), GROUP.getI18nDesc(), CONTRACT.getDesc(), CONTRACT.getI18nDesc(),
                TOTAL.getDesc(), TOTAL.getI18nDesc());
        public static final Map<Integer, Integer> ROW_ID_BY_CODE = Map.of(TRANSIENT.getCode(), TRANSIENT.getRowId(),
                GROUP.getCode(), GROUP.getRowId(), CONTRACT.getCode(), CONTRACT.getRowId(),
                TOTAL.getCode(), TOTAL.getRowId());

        public static String getDesc(Integer code) {
            return DESC_BY_CODE.get(code);
        }

        public static String getI18nDesc(String desc) {
            return i18nDescByDesc.get(desc);
        }

        public static Integer getRowId(Integer type) {
            return ROW_ID_BY_CODE.get(type);
        }

    }