@Test public void testLogin() throws Exception { }
@Override public CommonResult login(LoginParam loginParam, HttpServletRequest request) { String pwd = SHAUtils.encodeData(loginParam.getPassword()); loginParam.setPassword(pwd); User user = userMapper.userAuthentication(loginParam.getUserId(), loginParam.getPassword()); JSONObject result = new JSONObject(); if(user != null){ result.put("userId", user.getId()); result.put("userName", user.getName()); result.put("avatar", user.getAvatar()); List<Role> roles = roleMapper.listRole(loginParam.getUserId()); result.put("roles", roles); String token = JwtUtil.getToken(user.getId().toString()); result.put("web_token", "Bearer:" + token); System.out.println(); hospitalLogger.info("登录成功: " + loginParam.getUserId() + " with token: " + token); loginLog.run(loginParam, request); return CommonResult.success(result); } else{ hospitalLogger.info("登录失败: " + loginParam.getUserId()); return CommonResult.fail(E_601); } }
OauthServiceImpl implements OauthService { @Override public CommonResult login(LoginParam loginParam, HttpServletRequest request) { String pwd = SHAUtils.encodeData(loginParam.getPassword()); loginParam.setPassword(pwd); User user = userMapper.userAuthentication(loginParam.getUserId(), loginParam.getPassword()); JSONObject result = new JSONObject(); if(user != null){ result.put("userId", user.getId()); result.put("userName", user.getName()); result.put("avatar", user.getAvatar()); List<Role> roles = roleMapper.listRole(loginParam.getUserId()); result.put("roles", roles); String token = JwtUtil.getToken(user.getId().toString()); result.put("web_token", "Bearer:" + token); System.out.println(); hospitalLogger.info("登录成功: " + loginParam.getUserId() + " with token: " + token); loginLog.run(loginParam, request); return CommonResult.success(result); } else{ hospitalLogger.info("登录失败: " + loginParam.getUserId()); return CommonResult.fail(E_601); } } }
OauthServiceImpl implements OauthService { @Override public CommonResult login(LoginParam loginParam, HttpServletRequest request) { String pwd = SHAUtils.encodeData(loginParam.getPassword()); loginParam.setPassword(pwd); User user = userMapper.userAuthentication(loginParam.getUserId(), loginParam.getPassword()); JSONObject result = new JSONObject(); if(user != null){ result.put("userId", user.getId()); result.put("userName", user.getName()); result.put("avatar", user.getAvatar()); List<Role> roles = roleMapper.listRole(loginParam.getUserId()); result.put("roles", roles); String token = JwtUtil.getToken(user.getId().toString()); result.put("web_token", "Bearer:" + token); System.out.println(); hospitalLogger.info("登录成功: " + loginParam.getUserId() + " with token: " + token); loginLog.run(loginParam, request); return CommonResult.success(result); } else{ hospitalLogger.info("登录失败: " + loginParam.getUserId()); return CommonResult.fail(E_601); } }  }
OauthServiceImpl implements OauthService { @Override public CommonResult login(LoginParam loginParam, HttpServletRequest request) { String pwd = SHAUtils.encodeData(loginParam.getPassword()); loginParam.setPassword(pwd); User user = userMapper.userAuthentication(loginParam.getUserId(), loginParam.getPassword()); JSONObject result = new JSONObject(); if(user != null){ result.put("userId", user.getId()); result.put("userName", user.getName()); result.put("avatar", user.getAvatar()); List<Role> roles = roleMapper.listRole(loginParam.getUserId()); result.put("roles", roles); String token = JwtUtil.getToken(user.getId().toString()); result.put("web_token", "Bearer:" + token); System.out.println(); hospitalLogger.info("登录成功: " + loginParam.getUserId() + " with token: " + token); loginLog.run(loginParam, request); return CommonResult.success(result); } else{ hospitalLogger.info("登录失败: " + loginParam.getUserId()); return CommonResult.fail(E_601); } }  @Override CommonResult login(LoginParam loginParam, HttpServletRequest request); }
OauthServiceImpl implements OauthService { @Override public CommonResult login(LoginParam loginParam, HttpServletRequest request) { String pwd = SHAUtils.encodeData(loginParam.getPassword()); loginParam.setPassword(pwd); User user = userMapper.userAuthentication(loginParam.getUserId(), loginParam.getPassword()); JSONObject result = new JSONObject(); if(user != null){ result.put("userId", user.getId()); result.put("userName", user.getName()); result.put("avatar", user.getAvatar()); List<Role> roles = roleMapper.listRole(loginParam.getUserId()); result.put("roles", roles); String token = JwtUtil.getToken(user.getId().toString()); result.put("web_token", "Bearer:" + token); System.out.println(); hospitalLogger.info("登录成功: " + loginParam.getUserId() + " with token: " + token); loginLog.run(loginParam, request); return CommonResult.success(result); } else{ hospitalLogger.info("登录失败: " + loginParam.getUserId()); return CommonResult.fail(E_601); } }  @Override CommonResult login(LoginParam loginParam, HttpServletRequest request);  }