package org.eco.web.service;


import org.eco.common.core.exception.BusinessException;
import org.eco.web.domain.vo.LoginVo;
import org.eco.common.core.utils.SpringUtils;
import org.eco.system.domain.SysClient;

/**
 * 授权策略
 *
 * @author wgk
 */
public interface IAuthStrategy {

    String BASE_NAME = "AuthStrategy";

    /**
     * 登录
     */
    static LoginVo login(String body, SysClient client, String grantType) {
        // 授权类型和客户端id
        String beanName = grantType + BASE_NAME;
        if (!SpringUtils.containsBean(beanName)) {
            throw new BusinessException("授权类型不正确!");
        }
        IAuthStrategy instance = SpringUtils.getBean(beanName);
        return instance.login(body, client);
    }

    /**
     * 登录
     */
    LoginVo login(String body, SysClient client);

}
