|
|
|
@ -50,18 +50,33 @@ public class UserController {
|
|
|
|
|
@OperateLog(description = "用户登录")
|
|
|
|
|
@ApiOperation(value = "用户登录", httpMethod = "POST")
|
|
|
|
|
@PostMapping("login")
|
|
|
|
|
public ResultEntity<LoginResult> login(@ApiParam("用户名") @RequestParam String username,
|
|
|
|
|
@ApiParam("加密后的密文") @RequestParam String passwordEncode) {
|
|
|
|
|
public ResultEntity<LoginResult> login(@ApiParam("用户名") String username,
|
|
|
|
|
@ApiParam("加密后的密文") String passwordEncode,
|
|
|
|
|
@ApiParam("智云携带的token") String TOKEN) {
|
|
|
|
|
|
|
|
|
|
String password;
|
|
|
|
|
try {
|
|
|
|
|
password = RsaUtil.decryptByPrivateKey(passwordEncode);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new IllegalArgumentException("密码错误");
|
|
|
|
|
JwtUser jwtUser;
|
|
|
|
|
if (!StringUtils.hasText(username) && !StringUtils.hasText(passwordEncode) && !StringUtils.hasText(TOKEN)) {
|
|
|
|
|
throw new IllegalArgumentException("请提供登录凭据");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.hasText(TOKEN)) {
|
|
|
|
|
jwtUser = TokenProvider.getJWTUserByZhiYun(TOKEN);
|
|
|
|
|
if (jwtUser == null) {
|
|
|
|
|
throw new IllegalArgumentException("token无效");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
password = RsaUtil.decryptByPrivateKey(passwordEncode);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new IllegalArgumentException("密码错误");
|
|
|
|
|
}
|
|
|
|
|
String md5Pwd = RsaUtil.calculateMD5(password);
|
|
|
|
|
String hashPwd = RsaUtil.formatHash(md5Pwd);
|
|
|
|
|
jwtUser = TzApi.foreignExchangeTradingLogin(username, hashPwd);
|
|
|
|
|
if (jwtUser == null) {
|
|
|
|
|
throw new IllegalArgumentException("用户名或密码错误");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String md5Pwd = RsaUtil.calculateMD5(password);
|
|
|
|
|
String hashPwd = RsaUtil.formatHash(md5Pwd);
|
|
|
|
|
JwtUser jwtUser = TzApi.foreignExchangeTradingLogin(username, hashPwd);
|
|
|
|
|
jwtUser.setAuthorityCodes(roleAuthorityService.getAuthorityByRoleId(jwtUser.getRoleId()));
|
|
|
|
|
Authentication authentication = new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities());
|
|
|
|
|
SecurityContextHolder.getContext().setAuthentication(authentication);
|
|
|
|
@ -84,7 +99,6 @@ public class UserController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "注销登录", httpMethod = "POST")
|
|
|
|
|
@PostMapping("/logout")
|
|
|
|
|
public ResultEntity logout(HttpServletRequest request) {
|
|
|
|
@ -100,8 +114,7 @@ public class UserController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Permission()
|
|
|
|
|
// @Permission()
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("获取当前在线用户")
|
|
|
|
|
@GetMapping("online-users")
|
|
|
|
|