登录接口返回用户ID信息
- 在 LoginDto 中添加构造函数,包含用户ID参数 - 在 AuthController 中返回用户ID - 在 LoginBo 中添加用户ID字段
This commit is contained in:
parent
41697a508e
commit
ed9b38c123
|
@ -52,6 +52,11 @@ public class LoginBo extends BaseBo<LoginDto> {
|
|||
@ApiModelProperty("姓名")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
public UserInfoBo() {
|
||||
}
|
||||
|
||||
|
|
|
@ -470,7 +470,7 @@ public class AuthController extends DefaultBaseController {
|
|||
String token = userTokenResolver.getToken();
|
||||
ApplicationUtil.publishEvent(new LoginEvent(this, SecurityUtil.getCurrentUser(), token));
|
||||
|
||||
LoginDto dto = new LoginDto(token, user.getName(), user.getPermissions());
|
||||
LoginDto dto = new LoginDto(token, user.getName(), user.getPermissions(), user.getId());
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,17 @@ public class LoginDto implements BaseDto, Serializable {
|
|||
this.setUser(userInfo);
|
||||
}
|
||||
|
||||
public LoginDto(String token, String name, Set<String> roles, String userId) {
|
||||
|
||||
this.token = token;
|
||||
this.setRoles(roles);
|
||||
|
||||
UserInfoDto userInfo = new UserInfoDto();
|
||||
userInfo.setName(name);
|
||||
userInfo.setUserId(userId);
|
||||
this.setUser(userInfo);
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class UserInfoDto implements BaseDto, Serializable {
|
||||
|
||||
|
@ -49,5 +60,10 @@ public class LoginDto implements BaseDto, Serializable {
|
|||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String userId;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue