package com.cool.store.enums;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author wxp
 * @FileName: UserPlatformTypeEnum
 * @Description: 用户平台类型
 * @date 2023-06-13 17:12
 */
public enum UserPlatformTypeEnum {

    WECHAT("wechat", "微信"),
    DOUYIN("douyin", "抖音"),
    WEIBO("weibo", "微博");

    private String code;

    private String msg;

    protected static final Map<String, UserPlatformTypeEnum> map = Arrays.stream(values()).collect(
            Collectors.toMap(UserPlatformTypeEnum::getCode, Function.identity()));

    UserPlatformTypeEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public static UserPlatformTypeEnum getByCode(String code) {
        return map.get(code);
    }
}
