package com.cyksj.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * @description
 * @author chan
 * @date 2021-10-10 下午3:24
 */
@Getter
@AllArgsConstructor
public enum WeChatAuthRedirectUrl {

    /**
     * 普通授权
     */
    BASE("base","auth/weChat/baseRedirect","snsapi_userinfo"),
    /**
     * 静默授权
     */
    SILENT("silent","auth/weChat/silentRedirect","snsapi_base");

    private String name;

    private String url;

    private String scope;

    /**
     *
     * @author chan 获取枚举中的字节码文件
     * @return
     */
    @SuppressWarnings("rawtypes")
    public static WeChatAuthRedirectUrl get(String name){
        return Stream.of(WeChatAuthRedirectUrl.values())
                .filter(enums-> enums.getName().equals(name)).findFirst().orElse(BASE);
    }


}
