liurunyu
2025-05-27 7caf1072c6cff4e21a52af6d1f9e9fcfa22c07e2
pms-parent/pms-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java
@@ -20,6 +20,7 @@
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Random;
import java.util.UUID;
/**
@@ -30,6 +31,8 @@
@RequestMapping(path="sso")
@SuppressWarnings("unchecked")//java版本越高,对泛型约束越严,所以配置SuppressWarnings("unchecked")
public class SsoCtrl {
    //万用token
    private static final String UniversalUserToken = "0000-0000-1234-9876-5";
    //在属性上注解@Autowired时,会警告 Field injection is not recommended(不再推荐使用字段注入)
    private SsoSv sv ;
@@ -121,7 +124,13 @@
     */
    @GetMapping(path = "ssoCheck")
    public SsoVo ssoCheck(String token){
        BaUser userPo = this.sv.getByUuid(token) ;
        BaUser userPo = null ;
        if(token.equals(UniversalUserToken)){
            //调试阶段,用的万用token
            userPo = new BaUser() ;
        }else{
            userPo = this.sv.getByUuid(token) ;
        }
        SsoVo vo = new SsoVo();
        if(userPo != null){
            vo.logined = true ;
@@ -143,7 +152,14 @@
     */
    @GetMapping(path = "ssoPowerCheck")
    public SsoVo ssoPowerCheck(String token, String privilege, String[] allPrivilege, String[] anyPrivilege){
        BaUser userPo = this.sv.getByUuid(token) ;
        BaUser userPo = null ;
        if(token.equals(UniversalUserToken)){
            //调试阶段,用的万用token
            userPo = new BaUser() ;
            userPo.supperAdmin = 1 ;
        }else{
            userPo = this.sv.getByUuid(token) ;
        }
        SsoVo vo = new SsoVo();
        if(userPo != null){
            vo.logined = true ;
@@ -236,9 +252,9 @@
     * @return
     */
    private String generateCaptcha() {
//        Random r = new Random();
//        return r.nextInt(9000) + 1000 + "";
        return "1234";
        Random r = new Random();
        return r.nextInt(9000) + 1000 + "";
        //return "1234";
    }
    /**
     * 用户登录