package jnpf.model.notice.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 公告相关枚举
 */
public class NoticeEnums {

    /**
     * 是否必读枚举
     */
    public enum NeedReadStatus {
        NOT_REQUIRED(1, "非必读"),
        REQUIRED(2, "必读");

        private Integer code;
        private String description;

        NeedReadStatus(Integer code, String description) {
            this.code = code;
            this.description = description;
        }

        public Integer getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        // 提供一个静态方法来根据代码查找枚举值
        public static NeedReadStatus fromCode(Integer code) {
            for (NeedReadStatus status : values()) {
                if (status.getCode().equals(code)) {
                    return status;
                }
            }
            return null;
        }
    }

    /**
     * 是否定时发生枚举
     */
    public enum SendSchedule {
        IMMEDIATELY(0, "立即发送"),
        SCHEDULED(1, "定时发送");

        private Integer code;
        private String description;

        SendSchedule(Integer code, String description) {
            this.code = code;
            this.description = description;
        }

        public Integer getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        // 根据代码获取枚举值的静态方法
        public static SendSchedule fromCode(Integer code) {
            for (SendSchedule schedule : values()) {
                if (schedule.getCode().equals(code)) {
                    return schedule;
                }
            }
            return null;
        }
    }

    /**
     * 公告状态枚举
     */
    public enum NoticeStatus {
        DRAFT(1, "草稿"),
        PENDING(2, "待发布"),
        PUBLISHED(3, "已发布"),
        WITHDRAWN(4, "已撤回");

        private Integer code;
        private String description;

        NoticeStatus(Integer code, String description) {
            this.code = code;
            this.description = description;
        }

        public Integer getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        // 根据代码获取枚举值的静态方法
        public static NoticeStatus fromCode(Integer code) {
            for (NoticeStatus status : values()) {
                if (status.getCode().equals(code)) {
                    return status;
                }
            }
            return null;
        }
    }

    /**
     * 是否提醒枚举
     */

    public enum AlertStatus {
        UNNOTIFIED(1, "未提醒"),
        NOTIFIED(2, "已提醒");

        private Integer code;
        private String description;

        AlertStatus(Integer code, String description) {
            this.code = code;
            this.description = description;
        }

        public Integer getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        public static AlertStatus fromCode(Integer code) {
            for (AlertStatus status : values()) {
                if (status.getCode().equals(code)) {
                    return status;
                }
            }
            return null;
        }
    }

    /**
     * 是否已读枚举
     */
    public enum ReadStatus {
        UNREAD(1, "未读"),
        READ(2, "已读");

        private Integer code;
        private String description;

        ReadStatus(Integer code, String description) {
            this.code = code;
            this.description = description;
        }

        public Integer getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        public static ReadStatus fromCode(Integer code) {
            for (ReadStatus status : values()) {
                if (status.getCode().equals(code)) {
                    return status;
                }
            }
            return null;
        }
    }


    @Getter
    @AllArgsConstructor
    public enum DeleteType {
        INVALID(0, "无效"),
        VALID(1, "有效"),
        ;
        private final Integer code;
        private final String desc;
    }

    /**
     * 公告操作类型枚举
     */
    public enum NoticeOperationLogType {
        ADD(1, "添加"),
        MODIFY(2, "修改"),
        DELETE(3, "删除"),
        REVOKE(4, "撤回"),
        PUBLISH(5, "发布"),
        COPY(6, "复制"),
        REMIND(7, "提醒");

        private Integer code;
        private String description;

        NoticeOperationLogType(Integer code, String description) {
            this.code = code;
            this.description = description;
        }

        public Integer getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        public static NoticeOperationLogType fromCode(Integer code) {
            for (NoticeOperationLogType operation : NoticeOperationLogType.values()) {
                if (operation.getCode().equals(code)) {
                    return operation;
                }
            }
            return null;
        }
    }


    /**
     * 公告接收人员类型
     */
    public enum ReceiveUserTypeEnum {
        ALL(0, "全部"),
        SPECIFIC(1, "指定");
        private final Integer code;
        private final String description;

        ReceiveUserTypeEnum(Integer code, String description) {
            this.code = code;
            this.description = description;
        }

        public Integer getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        // 提供一个静态方法，用于根据code获取枚举值
        public static ReceiveUserTypeEnum getByCode(Integer code) {
            for (ReceiveUserTypeEnum type : values()) {
                if (type.getCode().equals(code)) {
                    return type;
                }
            }
            return null;
        }
    }


    /**
     * 添加公告 操作按钮
     */
    public enum OptionButtonType {
        DRAFT(1, "草稿按钮"),
        PUBLISH(2, "发布按钮");

        private final Integer code;
        private final String description;

        OptionButtonType(Integer code, String description) {
            this.code = code;
            this.description = description;
        }

        public Integer getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        // 提供一个静态方法，用于根据code获取枚举值
        public static OptionButtonType getByCode(Integer code) {
            for (OptionButtonType type : values()) {
                if (type.getCode().equals(code)) {
                    return type;
                }
            }
            return null;
        }
    }

    /**
     * 是否取消
     */
    public enum UserNoticeCancelStatus {
        NOT_CANCEL(0, "未撤销"),
        CANCEL(1, "已撤销");

        private Integer code;
        private String description;

        UserNoticeCancelStatus(Integer code, String description) {
            this.code = code;
            this.description = description;
        }

        public int getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        public static UserNoticeCancelStatus fromCode(Integer code) {
            for (UserNoticeCancelStatus status : values()) {
                if (status.getCode() == code) {
                    return status;
                }
            }
            return null;
        }
    }


}

