Skip to content

Commit

Permalink
Merge pull request #95 from KNU-HAEDAL/chore/user
Browse files Browse the repository at this point in the history
[Chore]: 내정보 조회에 role 추가, 랭킹에 이메일노출 제거
  • Loading branch information
bayy1216 authored Sep 13, 2024
2 parents 037aa31 + 530bac8 commit 9afc209
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ public class AuthRes {
public record LoginResponse(
String accessToken,
String refreshToken,
UserRes.UserInfo userInfo
UserRes.UserMyInfo userInfo
) {
public static LoginResponse from(JwtToken jwtToken, UserModel.Main userMain) {
var userInfo = UserRes.UserInfo.from(userMain);
var userInfo = UserRes.UserMyInfo.from(userMain);
return LoginResponse.builder()
.accessToken(jwtToken.getAccessToken())
.refreshToken(jwtToken.getRefreshToken())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public class UserController {

@Operation(summary = "내 정보 조회", description = "내 정보를 조회한다.")
@GetMapping("/api/user")
public ApiResponse<UserRes.UserInfo> getUserInfo(
public ApiResponse<UserRes.UserMyInfo> getUserInfo(
@AuthenticationPrincipal JwtUser jwtUser
) {
var userModel = userService.getUserModel(jwtUser.getId());
return ApiResponse.success(UserRes.UserInfo.from(userModel));
return ApiResponse.success(UserRes.UserMyInfo.from(userModel));
}

@Operation(summary = "내 정보 수정", description = "내 정보를 수정한다.")
Expand Down Expand Up @@ -58,11 +58,11 @@ public ApiResponse<UserRes.Streak> getStreak(

@Operation(summary = "유저 랭킹 페이징", description = "전체 유저 랭킹을 조회 페이징")
@GetMapping("/api/users/ranking")
public ApiResponse<PagingResponse<UserRes.UserInfo>> getUsersRanking(
public ApiResponse<PagingResponse<UserRes.User>> getUsersRanking(
@Valid PagingRequest request
) {
var userModelPage = userService.getUserPagingByRanking(request.toPageable());
var response = PagingResponse.from(userModelPage, UserRes.UserInfo::from);
var response = PagingResponse.from(userModelPage, UserRes.User::from);
return ApiResponse.success(response);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.haedal.zzansuni.user.controller;

import lombok.Builder;
import org.haedal.zzansuni.global.security.Role;
import org.haedal.zzansuni.user.domain.TierSystem;
import org.haedal.zzansuni.user.domain.UserModel;

Expand All @@ -9,21 +10,23 @@

public class UserRes {
@Builder
public record UserInfo(
public record UserMyInfo(
Long id,
String nickname,
String profileImageUrl,
String email,
TierInfo tierInfo
TierInfo tierInfo,
Role role
) {
public static UserInfo from(UserModel.Main userMain) {
public static UserMyInfo from(UserModel.Main userMain) {
var tierInfo = TierInfo.from(userMain.exp());
return UserInfo.builder()
return UserMyInfo.builder()
.id(userMain.id())
.nickname(userMain.nickname())
.profileImageUrl(userMain.profileImageUrl())
.email(userMain.email())
.tierInfo(tierInfo)
.role(userMain.role())
.build();
}
}
Expand Down

0 comments on commit 9afc209

Please sign in to comment.