package com.zd.common.core.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zd.common.core.valid.ValidEunm;

import java.util.Arrays;

/**
 * 用户消信息发送方式
 *
 * @Author: zhoupan
 * @Date: 2021/09/03/8:52
 * @Description:
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum UserMessageSendModeEnum implements ValidEunm, BaseEnum<Integer> {

    SMS_MINIPROGRAM(0, "短信+小程序"),
    SMS(1, "短信"),
    MINIPROGRAM(2, "小程序"),
    ;

    private Integer code;
    private String name;

    UserMessageSendModeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static UserMessageSendModeEnum getByCode(Integer code) {
        return Arrays.stream(UserMessageSendModeEnum.values()).filter(a -> a.code.equals(code)).findFirst().orElse(null);
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    @Override
    public String codes() {
        return this.code.toString();
    }

    @Override
    public Integer getDictKey() {
        return code;
    }
}
