package com.webchat.common.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: 程序员王七七 https://www.coderutil.com 网站作者
 * @Date: 2021-7-24 0024 21:53
 * @Description: 无描述信息
 */
@Getter
public enum MessageTypeEnum {

    LIKE_ARTICLE(1000, 1001, "文章点赞消息"),
    LIKE_COMMENT(1000, 1002, "评论点赞消息"),
    COMMENT(2000, 2001, "评论消息"),
    REPLY(2000, 2002, "回复消息"),
    SYSTEM(3000, 3001, "系统消息"),
    FOCUS(4000, 4001, "粉丝消息");

    private Integer code1;

    private Integer code2;

    private String desc;

    MessageTypeEnum(Integer code1, Integer code2, String desc) {
        this.code1 = code1;
        this.code2 = code2;
        this.desc = desc;
    }

    public static Integer getCode1ByCode2(Integer code2) {
        for (MessageTypeEnum messageTypeEnum : MessageTypeEnum.values()) {
            if (messageTypeEnum.code2.equals(code2)) {
                return messageTypeEnum.code1;
            }
        }
        return null;
    }

    public static List<Integer> getCode2ListByCode1(Integer code1) {
        List<Integer> code2List = new ArrayList<>();
        for (MessageTypeEnum messageTypeEnum : MessageTypeEnum.values()) {
            if (messageTypeEnum.code1.equals(code1)) {
                code2List.add(messageTypeEnum.code2);
            }
        }
        return code2List;
    }
}
