package org.security.singleSignOn.controller;

import lombok.AllArgsConstructor;
import org.security.singleSignOn.service.SingleSignOnService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author ：wzf
 * @apiNote ：单点登录接入
 * @since ：Created in 2022/11/25 15:05
 */
@Controller
@AllArgsConstructor
public class SingleSignOnController {

	private final SingleSignOnService singleSignOnService;

	/**
	 * 获取code
	 * @return
	 */
	@GetMapping("/auth")
	public String auth() {
		return singleSignOnService.getCode();
	}


	/**
	 *
	 * 集成单点登录
	 */
	@GetMapping("/authorize")
	public String authorize(@RequestParam String code,
							@RequestParam String state) {
		return singleSignOnService.getAimToken(code,state);
	}
}
