feat(auth): add user profile to auth token response

- Add jwt configuration in application.yaml
- Include user profile information in authentication response
- Implement user profile response DTO with role mapping
- Fix typo in UserProfileService interface and implementation class names
- Add pagination support for user list endpoint
- Configure MyBatis Plus interceptor for MariaDB
- Add MyBatis Plus JSQLParser dependency
- Implement page-based user retrieval with role information
- Remove obsolete MyBatis configuration class
- Update controller to use paginated user data
- Replace manual user conversion with constructor mapping
- Rename UserProfileServcie to UserProfileService consistently
This commit is contained in:
Chaos
2025-11-24 17:10:01 +08:00
parent ec49ea8e25
commit a5a23a6b52
12 changed files with 121 additions and 48 deletions

View File

@@ -3,8 +3,8 @@ package cn.nopj.chaos_api.dto.response;
import lombok.Data;
@Data
public class AuthTokenResponse {
private String tokenHead;
private String token;
private UserProfileResponse userProfile;
}

View File

@@ -1,5 +1,6 @@
package cn.nopj.chaos_api.dto.response;
import cn.nopj.chaos_api.domain.entity.User;
import lombok.Data;
import java.util.List;
@@ -10,4 +11,16 @@ public class UserProfileResponse {
private String username;
private String nickname;
private List<RoleResponse> roles;
public UserProfileResponse(User user) {
this.id = user.getId();
this.username = user.getUsername();
this.nickname = user.getNickname();
this.roles = user.getRoles().stream().map(role -> {
RoleResponse roleResponse = new RoleResponse();
roleResponse.setId(role.getId());
roleResponse.setName(role.getName());
return roleResponse;
}).toList();
}
}