登录接口返回用户ID信息

- 在 LoginDto 中添加构造函数,包含用户ID参数
- 在 AuthController 中返回用户ID
- 在 LoginBo 中添加用户ID字段
This commit is contained in:
lijiaqi 2024-10-12 15:18:39 +08:00
parent 41697a508e
commit ed9b38c123
3 changed files with 22 additions and 1 deletions

View File

@ -52,6 +52,11 @@ public class LoginBo extends BaseBo<LoginDto> {
@ApiModelProperty("姓名") @ApiModelProperty("姓名")
private String name; private String name;
/**
* 用户ID
*/
private String userId;
public UserInfoBo() { public UserInfoBo() {
} }

View File

@ -470,7 +470,7 @@ public class AuthController extends DefaultBaseController {
String token = userTokenResolver.getToken(); String token = userTokenResolver.getToken();
ApplicationUtil.publishEvent(new LoginEvent(this, SecurityUtil.getCurrentUser(), token)); 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; return dto;
} }

View File

@ -40,6 +40,17 @@ public class LoginDto implements BaseDto, Serializable {
this.setUser(userInfo); 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 @Data
public static class UserInfoDto implements BaseDto, Serializable { public static class UserInfoDto implements BaseDto, Serializable {
@ -49,5 +60,10 @@ public class LoginDto implements BaseDto, Serializable {
* 姓名 * 姓名
*/ */
private String name; private String name;
/**
* 用户ID
*/
private String userId;
} }
} }