|  |  | 
 |  |  | import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
 |  |  | import com.baomidou.mybatisplus.extension.api.R; | 
 |  |  | import com.doumee.config.shiro.ShiroToken; | 
 |  |  | import com.doumee.core.constants.ResponseStatus; | 
 |  |  | import com.doumee.core.exception.BusinessException; | 
 |  |  | 
 |  |  |         } | 
 |  |  |         // 校验用户名和密码 | 
 |  |  |         Subject subject = SecurityUtils.getSubject(); | 
 |  |  |         ShiroToken token = new ShiroToken(dto.getUsername(), dto.getPassword(),true,type); | 
 |  |  |         ShiroToken token = new ShiroToken(dto.getUsername(), dto.getPassword(),true,type,null); | 
 |  |  |         try { | 
 |  |  |             subject.login(token); | 
 |  |  |             loginLog.setUserId(((LoginUserInfo)subject.getPrincipal()).getId()); | 
 |  |  | 
 |  |  |         } | 
 |  |  |         // 校验用户名和密码 | 
 |  |  |         Subject subject = SecurityUtils.getSubject(); | 
 |  |  |         ShiroToken token = new ShiroToken(dto.getPhone(), null,false,type); | 
 |  |  |         ShiroToken token = new ShiroToken(dto.getPhone(), null,false,type,null); | 
 |  |  |         try { | 
 |  |  |             subject.login(token); | 
 |  |  |             loginLog.setUserId(((LoginUserInfo)subject.getPrincipal()).getId()); | 
 |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public String switchCompany (LoginUserInfo loginUserInfo,Integer companyId, HttpServletRequest request) { | 
 |  |  |         SystemLoginLog loginLog = new SystemLoginLog(); | 
 |  |  |         loginLog.setLoginUsername(loginUserInfo.getMobile()); | 
 |  |  |         loginLog.setLoginTime(new Date()); | 
 |  |  |         loginLog.setSystemVersion(systemVersion); | 
 |  |  |         loginLog.setIp(Utils.User_Client.getIP(request)); | 
 |  |  |         loginLog.setLocation(Utils.Location.getLocationString(loginLog.getIp())); | 
 |  |  |         loginLog.setPlatform(Utils.User_Client.getPlatform(request)); | 
 |  |  |         loginLog.setClientInfo(Utils.User_Client.getBrowser(request)); | 
 |  |  |         loginLog.setOsInfo(Utils.User_Client.getOS(request)); | 
 |  |  |         loginLog.setServerIp(Utils.Server.getIP()); | 
 |  |  |  | 
 |  |  |         // 校验用户名和密码 | 
 |  |  |         Subject subject = SecurityUtils.getSubject(); | 
 |  |  |         ShiroToken token = new ShiroToken(loginUserInfo.getMobile(), null,false,loginUserInfo.getType(),companyId); | 
 |  |  |         try { | 
 |  |  |             subject.login(token); | 
 |  |  |             loginLog.setUserId(((LoginUserInfo)subject.getPrincipal()).getId()); | 
 |  |  |             loginLog.setSuccess(Boolean.TRUE); | 
 |  |  |             systemLoginLogService.create(loginLog); | 
 |  |  |             return (String)subject.getSession().getId(); | 
 |  |  |         } catch (AuthenticationException e) { | 
 |  |  |             log.error(ResponseStatus.ACCOUNT_INCORRECT.getMessage(), e); | 
 |  |  |             loginLog.setReason(e.getMessage().length() > 200 ? (e.getMessage().substring(0, 190) + "...") : e.getMessage()); | 
 |  |  |             loginLog.setSuccess(Boolean.FALSE); | 
 |  |  |             systemLoginLogService.create(loginLog); | 
 |  |  |             throw new BusinessException(ResponseStatus.ACCOUNT_INCORRECT.getCode(), Objects.isNull(e.getCause())?ResponseStatus.ACCOUNT_INCORRECT.getMessage():e.getCause().getMessage()); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  | } |