Files
sa-token/sa-token-demo/sa-token-demo-sso1/src/main/java/com/pj/sso/SsoController.java

35 lines
902 B
Java
Raw Normal View History

2021-06-29 23:32:35 +08:00
package com.pj.sso;
2021-02-08 19:23:37 +08:00
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import cn.dev33.satoken.stp.StpUtil;
2021-08-26 23:17:39 +08:00
import cn.dev33.satoken.util.SaResult;
2021-02-08 19:23:37 +08:00
/**
* 测试: 同域单点登录
* @author kong
*/
@RestController
@RequestMapping("/sso/")
2021-06-29 23:32:35 +08:00
public class SsoController {
2021-08-26 23:17:39 +08:00
2021-02-08 19:23:37 +08:00
// 测试:进行登录
@RequestMapping("doLogin")
2021-08-26 23:17:39 +08:00
public SaResult doLogin(@RequestParam(defaultValue = "10001") String id) {
2021-02-08 19:23:37 +08:00
System.out.println("---------------- 进行登录 ");
2021-06-16 16:24:39 +08:00
StpUtil.login(id);
2021-08-26 23:17:39 +08:00
return SaResult.ok("登录成功: " + id);
2021-02-08 19:23:37 +08:00
}
// 测试:是否登录
@RequestMapping("isLogin")
2021-08-26 23:17:39 +08:00
public SaResult isLogin() {
2021-02-08 19:23:37 +08:00
System.out.println("---------------- 是否登录 ");
boolean isLogin = StpUtil.isLogin();
2021-08-26 23:17:39 +08:00
return SaResult.ok("是否登录: " + isLogin);
2021-02-08 19:23:37 +08:00
}
}