package com.taais.web.service;


import com.taais.common.core.exception.ServiceException;
import com.taais.common.core.utils.SpringUtils;
import com.taais.system.domain.SysClient;
import com.taais.web.domain.vo.LoginVo;

/**
 * 授权策略
 *
 * @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 ServiceException("授权类型不正确!");
        }
        IAuthStrategy instance = SpringUtils.getBean(beanName);
        return instance.login(body, client);
    }

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

}
