# HkInventoryNotifyConfigTypeEnum.java

    package cloud.wconnect.workperformance.cons.hkinventory;

    import cloud.wconnect.commonlib.cons.BaseErrorCodeEnum;
    import cloud.wconnect.commonlib.exception.BadRequestException;
    import cloud.wconnect.workperformance.cons.FunctionPointEnum;
    import lombok.AllArgsConstructor;
    import lombok.Getter;

    import java.util.Arrays;
    import java.util.Optional;

    /**
     * Housekeeping Inventory通知配置类型
     *
     * @author lichen
     * @date 2025/4/25
     */
    @Getter
    @AllArgsConstructor
    public enum HkInventoryNotifyConfigTypeEnum {

        /**
         * 通知表单填写人员
         */
        NOTIFY_FORM_FILLER(1, "hk-inventory.notify.subject.unpublished"),
        /**
         * 通知管理人员
         */
        NOTIFY_MANAGER(2, "hk-inventory.notify.subject.unpublished");

        /**
         * 通知类型
         */
        private final Integer type;
        /**
         * 默认通知主题的国际化code
         */
        private final String defaultSubjectI18nCode;

        /**
         * 根据类型获取默认主题的国际化code
         *
         * @param type 类型
         * @return java.lang.String
         * @author lichen
         * @date 2025/4/25
         */
        public static String getDefaultSubjectI18nCode(int type) {
            Optional<HkInventoryNotifyConfigTypeEnum> optional = Arrays.stream(HkInventoryNotifyConfigTypeEnum.values())
                    .filter(item -> item.getType() == type).findFirst();
            return optional.isEmpty() ? "" : optional.get().getDefaultSubjectI18nCode();
        }

        /**
         * 根据类型获取功能点枚举
         *
         * @param type 通知类型
         * @return cloud.wconnect.workperformance.cons.FunctionPointEnum
         * @author lichen
         * @date 2025/4/25
         */
        public static FunctionPointEnum getFunctionPointEnum(int type) {
            if (type == NOTIFY_FORM_FILLER.type) {
                return FunctionPointEnum.HOUSEKEEPING_INVENTORY_NOTIFY_FORM_FILLER;
            } else {
                return FunctionPointEnum.HOUSEKEEPING_INVENTORY_NOTIFY_MANAGER;
            }
        }

        /**
         * 校验分类是否合法
         *
         * @param type 分类
         * @return void
         * @author lichen
         * @date 2025/4/27
         */
        public static void checkValid(int type) {
            Optional<HkInventoryNotifyConfigTypeEnum> optional = Arrays.stream(HkInventoryNotifyConfigTypeEnum.values())
                    .filter(item -> item.getType() == type).findFirst();
            if (optional.isEmpty()) {
                throw new BadRequestException(BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getI18nCode(),
                        BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getCode(), "The type must between in [1:notify form filler 2:notify manager]");
            }
        }
    }