package com.webchat.common.constants;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * @Author 程序员七七
 * @webSite https://www.coderutil.com
 * @Date 2022/11/13 00:49
 * @description
 */
public class MessageConstants {

    /**
     * 系统发送的消息，系统用户
     */
    public static final String FROM_SYSTEM = "SYSTEM";

    /**
     * 消息分类
     */
    @Getter
    @AllArgsConstructor
    public enum CategoryEnum {

        SYSTEM("系统消息"),

        COMMENT_REPLY("评论与回复"),

        LIKE_COLLECT("点赞与收藏"),

        FOCUS("粉丝关注");

        private String categoryName;

        public String getCategory() {
            return this.name();
        }
    }

    public static String getCategoryName(String category) {
        if (StringUtils.isBlank(category)) {
            return "";
        }
        for (CategoryEnum categoryEnum : CategoryEnum.values()) {
            if (categoryEnum.getCategory().equals(category)) {
                return categoryEnum.getCategoryName();
            }
        }
        return "";
    }

    /**
     * 消息类型
     */
    @Getter
    @AllArgsConstructor
    public enum TypeEnum {

        LIKE("点赞"),

        LIKE_COMMENT("点赞"),

        COLLECT("收藏"),

        COMMENT("评论消息"),

        REPLY("回复消息"),

        OTHER("其他");

        private String typeName;

        public String getType() {
            return this.name();
        }
    }

    public static String getTypeName(String type) {
        if (StringUtils.isBlank(type)) {
            return "";
        }
        for (TypeEnum typeEnum : TypeEnum.values()) {
            if (typeEnum.getType().equals(type)) {
                return typeEnum.getTypeName();
            }
        }
        return "";
    }
}
