Skip to content

Commit

Permalink
feat: add api to see my page
Browse files Browse the repository at this point in the history
  • Loading branch information
aiaiaiai1 committed Jul 21, 2024
1 parent f1ac034 commit b22e007
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/gymmi/controller/MyPageController.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,13 @@ public ResponseEntity<Void> editMyPage(
return ResponseEntity.ok().build();
}

@GetMapping("/my")
public ResponseEntity<Void> seeMyPage(
@Logined User user
) {
myPageService.getMyInfo(user);
return ResponseEntity.ok().build();
}


}
9 changes: 9 additions & 0 deletions src/main/java/gymmi/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,13 @@ public String getProfileImageName() {
}
return profileImage.getStoredName();
}

public String getLoginId() {
return loginId;
}

public String getEmail() {
return email;
}

}
21 changes: 21 additions & 0 deletions src/main/java/gymmi/response/MyPageResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package gymmi.response;

import lombok.Builder;
import lombok.Getter;

@Getter
public class MyPageResponse {

private final String profileImage;
private final String nickname;
private final String loginId;
private final String email;

@Builder
public MyPageResponse(String profileImage, String nickname, String loginId, String email) {
this.profileImage = profileImage;
this.nickname = nickname;
this.loginId = loginId;
this.email = email;
}
}
10 changes: 10 additions & 0 deletions src/main/java/gymmi/service/MyPageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import gymmi.repository.ProfileImageRepository;
import gymmi.repository.UserRepository;
import gymmi.request.EditingMyPageRequest;
import gymmi.response.MyPageResponse;
import gymmi.response.ProfileImageResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -53,5 +54,14 @@ public void editMyPage(User loginedUser, EditingMyPageRequest request) {
}
loginedUser.changeNickname(request.getNickname());
}

public MyPageResponse getMyInfo(User loginedUser) {
return MyPageResponse.builder()
.nickname(loginedUser.getNickname())
.email(loginedUser.getEmail())
.loginId(loginedUser.getLoginId())
.profileImage(loginedUser.getProfileImageName())
.build();
}
}

0 comments on commit b22e007

Please sign in to comment.