package com.ruoyi.user.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.ruoyi.common.enums.IIntegerEnum;

import java.util.Objects;

/**
 * 第三方身份（微信小程序0，支付宝小程序1）
 */
public enum UserThirdType implements IIntegerEnum {

    WX_MINI_PROGRAM(0, "微信小程序"),
    ALI_MINI_PROGRAM(1, "支付宝小程序"),
    ;

    @EnumValue
    @JsonValue
    private Integer code;

    private String msg;

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

    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

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

    @JsonCreator
    public static UserThirdType getByCode(int code) {
        for (UserThirdType value : UserThirdType.values()) {
            if (Objects.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }
}
