Skip to content

Commit

Permalink
[refactor] #211 - 기존 UserInfoDto랑 겹치는 부분이 발생하여 responseDto 이름 변경
Browse files Browse the repository at this point in the history
- 기존의 UserInfoDto는 나중에 어느 페이지든 접속한 유저의 정보가 필요할 때 사용할 api
- 현재 추가한 api는 유저 페이지 전용 api
  • Loading branch information
khyojun committed Oct 15, 2024
1 parent b5d5d02 commit 9f2c2d5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import gitbal.backend.api.userPage.dto.FriendSuggestDto;
import gitbal.backend.api.userPage.dto.IntroductionResponseDto;
import gitbal.backend.api.userPage.dto.IntroductionupdateRequestDto;
import gitbal.backend.api.userPage.dto.UserInfoResponseDto;
import gitbal.backend.api.userPage.dto.UserPageUserInfoResponseDto;
import gitbal.backend.api.userPage.service.UserPageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
Expand Down Expand Up @@ -91,7 +91,7 @@ public ResponseEntity<String> updateIntroduction(Authentication authentication,
@ApiResponse(responseCode = "200", description = "유저페이지에 필요한 유저 개인 정보 로딩을 성공했습니다."),
@ApiResponse(responseCode = "5xx", description = "유저페이지에 필요한 유저 개인 정보 로딩을 실패했습니다.")
})
public ResponseEntity<UserInfoResponseDto> userInfo(String username){
public ResponseEntity<UserPageUserInfoResponseDto> userInfo(String username){
return ResponseEntity.ok(userPageService.makeUserInfoResponse(username));
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package gitbal.backend.api.userPage.dto;

import gitbal.backend.global.constant.Grade;

public record UserPageUserInfoResponseDto(String username, Grade grade, String profileImg) {

public static UserPageUserInfoResponseDto of(String username, Grade grade, String profileImg) {
return new UserPageUserInfoResponseDto(username, grade, profileImg);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import gitbal.backend.api.userPage.dto.FriendSuggestDto;
import gitbal.backend.api.userPage.dto.IntroductionResponseDto;
import gitbal.backend.api.userPage.dto.IntroductionupdateRequestDto;
import gitbal.backend.api.userPage.dto.UserInfoResponseDto;
import gitbal.backend.api.userPage.dto.UserPageUserInfoResponseDto;
import gitbal.backend.domain.introduction.Introduction;
import gitbal.backend.domain.introduction.application.repository.IntroductionRepository;
import gitbal.backend.domain.region.application.RegionService;
Expand Down Expand Up @@ -116,7 +116,7 @@ private void updateUserRegion(User user, String regionName) {
}

@Transactional(readOnly = true)
public UserInfoResponseDto makeUserInfoResponse(String username) {
public UserPageUserInfoResponseDto makeUserInfoResponse(String username) {
return userService.makeUserInfoResponse(username);
}
}
6 changes: 3 additions & 3 deletions src/main/java/gitbal/backend/domain/user/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import gitbal.backend.api.userPage.dto.UserInfoResponseDto;
import gitbal.backend.api.userPage.dto.UserPageUserInfoResponseDto;
import gitbal.backend.domain.region.Region;
import gitbal.backend.domain.school.School;
import gitbal.backend.global.constant.Grade;
Expand Down Expand Up @@ -237,11 +237,11 @@ public int calculateExp(User findUser) {
}


public UserInfoResponseDto makeUserInfoResponse(String username) {
public UserPageUserInfoResponseDto makeUserInfoResponse(String username) {
User findUser = userRepository.findByNickname(username)
.orElseThrow(NotFoundUserException::new);

return UserInfoResponseDto.of(findUser.getNickname(), findUser.getGrade()
return UserPageUserInfoResponseDto.of(findUser.getNickname(), findUser.getGrade()
,findUser.getProfile_img());
}
}

0 comments on commit 9f2c2d5

Please sign in to comment.