|  |  | 
 |  |  | @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 ; | 
 |  |  | 
 |  |  |         if(vo.orgTag == null || vo.orgTag.trim().length() == 0){ | 
 |  |  |             return BaseResponseUtils.buildErrorMsg("未选择组织单位"); | 
 |  |  |         } | 
 |  |  |         if(vo.token == null || vo.token.trim().length() == 0){ | 
 |  |  |             return BaseResponseUtils.buildErrorMsg("无token"); | 
 |  |  |         } | 
 |  |  |         if(vo.code == null || vo.code.trim().length() == 0){ | 
 |  |  |             return BaseResponseUtils.buildErrorMsg("请输入验证码"); | 
 |  |  |         } | 
 |  |  |         //把组织单位标签作为数据源名称 | 
 |  |  |         DataSourceContext.set(vo.orgTag); | 
 |  |  |  | 
 |  |  |         // 从数据库获取验证码 | 
 |  |  |         Map map = sv.getCodeByToken(vo.token); | 
 |  |  |         Long expiration = Long.parseLong(map.get("expiration").toString()); | 
 |  |  |         Long currentTimestamp = System.currentTimeMillis(); | 
 |  |  |         if(currentTimestamp > expiration) { | 
 |  |  |             return BaseResponseUtils.buildErrorMsg("验证码已超时"); | 
 |  |  |         } | 
 |  |  |         String localCode = map.get("code").toString(); | 
 |  |  |         if(!vo.code.equals(localCode)) { | 
 |  |  |             return BaseResponseUtils.buildErrorMsg("验证码错误"); | 
 |  |  |         if(vo.token != null && vo.token.trim().length() > 0) { | 
 |  |  |             // 从session中获取验证码 | 
 |  |  |             //HttpSession session = (HttpSession) request.getSession(); | 
 |  |  |             //String localCode = session.getAttribute(token).toString(); | 
 |  |  |             // 从数据库获取验证码 | 
 |  |  |             Map map = sv.getCodeByToken(vo.token); | 
 |  |  |             Long expiration = Long.parseLong(map.get("expiration").toString()); | 
 |  |  |             Long currentTimestamp = System.currentTimeMillis(); | 
 |  |  |             if(currentTimestamp > expiration) { | 
 |  |  |                 return BaseResponseUtils.buildErrorMsg("验证码已超时"); | 
 |  |  |             } | 
 |  |  |             String localCode = map.get("code").toString(); | 
 |  |  |             if(!vo.code.equals(localCode)) { | 
 |  |  |                 return BaseResponseUtils.buildErrorMsg("验证码错误"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if(!sv.existPhone(vo.phone)){ | 
 |  |  | 
 |  |  |     @Hidden | 
 |  |  |     @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() ; | 
 |  |  |             Org.OrgVo orgVo = Org.OrgList.get(0) ; | 
 |  |  |             userPo.orgTag = orgVo.tag ; | 
 |  |  |         }else{ | 
 |  |  |             userPo = this.sv.getByUuid(token) ; | 
 |  |  |         } | 
 |  |  |         SsoVo vo = new SsoVo(); | 
 |  |  |         if(userPo != null){ | 
 |  |  |             vo.dataSourceName = userPo.orgTag ; |