package com.bootdo.common.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 第三方sso参数配置
 *
 * @author Mr.xiBel
 */
@Component
@ConfigurationProperties(prefix = "third-part-sso")
public class ThirdPartSsoConfig {

	/**
	 * 开关
	 */
	private Boolean switchFlag;

	/**
	 * 是否直接获取用户名 将跳过通过token再次去获取用户详情
	 * 不获取用户详情时, 直接使用获取token信息中的user_info
	 */
	private Boolean directlyUsername;

	/**
	 * 客户端的id 提前配置与配置一致
	 */
	private String clientId;

	/**
	 * 客户端秘钥,提前配置与配置一致
	 */
	private String clientSecret;

	/**
	 * 跳转的目标的url,提前配置,与配置一致
	 */
	private String systemRedirectUrl;

	/**
	 * 第三方系统sso地址
	 */
	private String ssoRedirectUrl;

	/**
	 * 4.2 根据code获取token地址
	 */
	private String tokenUrl;

	/**
	 * 4.3 根据token获取用户详情地址
	 */
	private String userUrl;

	/**
	 * 登出地址
	 */
	private String LoginoutUrl;

	/**
	 * 推送过来的用户默认的部门id
	 */
	private Long pushDeptId;


	public String getLoginoutUrl() {
		return LoginoutUrl;
	}

	public void setLoginoutUrl(String loginoutUrl) {
		LoginoutUrl = loginoutUrl;
	}

	public Boolean getSwitchFlag() {
		return switchFlag;
	}

	public void setSwitchFlag(Boolean switchFlag) {
		this.switchFlag = switchFlag;
	}

	public String getClientId() {
		return clientId;
	}

	public void setClientId(String clientId) {
		this.clientId = clientId;
	}

	public String getClientSecret() {
		return clientSecret;
	}

	public void setClientSecret(String clientSecret) {
		this.clientSecret = clientSecret;
	}

	public String getSystemRedirectUrl() {
		return systemRedirectUrl;
	}

	public void setSystemRedirectUrl(String systemRedirectUrl) {
		this.systemRedirectUrl = systemRedirectUrl;
	}

	public String getTokenUrl() {
		return tokenUrl;
	}

	/**
	 * 获取完整 TokenUrl
	 *
	 * @param code
	 * @return
	 */
	public String getTokenUrl(String code) {
		return String.format(tokenUrl, clientId, clientSecret, systemRedirectUrl, code);
	}

	public void setTokenUrl(String tokenUrl) {
		this.tokenUrl = tokenUrl;
	}

	public String getUserUrl() {
		return userUrl;
	}

	public void setUserUrl(String userUrl) {
		this.userUrl = userUrl;
	}

	public Boolean getDirectlyUsername() {
		return directlyUsername;
	}

	public void setDirectlyUsername(Boolean directlyUsername) {
		this.directlyUsername = directlyUsername;
	}

	public String getSsoRedirectUrl() {
		return ssoRedirectUrl;
	}

	public void setSsoRedirectUrl(String ssoRedirectUrl) {
		this.ssoRedirectUrl = ssoRedirectUrl;
	}

	public Long getPushDeptId() {
		return pushDeptId;
	}

	public void setPushDeptId(Long pushDeptId) {
		this.pushDeptId = pushDeptId;
	}
}
