Skip to content

Commit

Permalink
Merge pull request #355 from Team-Sopetit/feature/#354/sohyeon
Browse files Browse the repository at this point in the history
[FEAT] 회원 정보 조회 API
  • Loading branch information
thguss authored Nov 17, 2024
2 parents c83d285 + 8d18aa0 commit b4e3b9b
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/main/java/com/soptie/server/api/controller/MemberApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.soptie.server.api.controller.dto.response.SuccessResponse;
import com.soptie.server.api.controller.dto.response.member.GetHomeInfoResponse;
import com.soptie.server.api.controller.dto.response.member.GiveMemberCottonResponse;
import com.soptie.server.api.controller.dto.response.member.MemberProfileResponse;
import com.soptie.server.api.controller.generic.SuccessMessage;
import com.soptie.server.domain.member.CottonType;
import com.soptie.server.domain.member.MemberService;
Expand Down Expand Up @@ -60,4 +61,13 @@ public SuccessResponse<GetHomeInfoResponse> getMemberHomeInfo(Principal principa
val response = memberService.getMemberHomeInfo(memberId);
return SuccessResponse.success(SuccessMessage.GET_MEMBER_HOME.getMessage(), response);
}

@ResponseStatus(HttpStatus.OK)
@GetMapping("/profile")
public SuccessResponse<MemberProfileResponse> getMemberProfile(Principal principal) {
val memberId = Long.parseLong(principal.getName());
val response = memberService.getMemberProfile(memberId);
return SuccessResponse.success(SuccessMessage.GET_MEMBER_PROFILE.getMessage(), response);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.soptie.server.api.controller.dto.response.SuccessResponse;
import com.soptie.server.api.controller.dto.response.member.GetHomeInfoResponse;
import com.soptie.server.api.controller.dto.response.member.GiveMemberCottonResponse;
import com.soptie.server.api.controller.dto.response.member.MemberProfileResponse;
import com.soptie.server.domain.member.CottonType;

import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -20,7 +21,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "members", description = "회원 API")
@Tag(name = "[Member] 회원 API", description = "회원 관련 api 입니다.")
public interface MemberApiDocs {

@Operation(
Expand Down Expand Up @@ -118,4 +119,22 @@ SuccessResponse<GiveMemberCottonResponse> giveCotton(
SuccessResponse<GetHomeInfoResponse> getMemberHomeInfo(
@Parameter(hidden = true) Principal principal
);

@Operation(
summary = "회원 정보 조회",
description = "회원의 정보를 조회합니다.",
responses = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(
responseCode = "4xx",
description = "클라이언트(요청) 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
SuccessResponse<MemberProfileResponse> getMemberProfile(
@Parameter(hidden = true) Principal principal
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.soptie.server.api.controller.dto.response.member;

import java.time.LocalDateTime;

import com.soptie.server.domain.member.Member;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
import lombok.Builder;

@Builder(access = AccessLevel.PRIVATE)
public record MemberProfileResponse(
@Schema(description = "회원가입 일자", example = "2024-08-28T15:34:05.272309")
LocalDateTime createdAt
) {

public static MemberProfileResponse from(Member member) {
return MemberProfileResponse.builder()
.createdAt(member.getCreatedAt())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public enum SuccessMessage {

/* member */
CREATE_MEMBER_PROFILE("회원 프로필 등록 성공"),
GET_MEMBER_PROFILE("회원 프로필 조회 성공"),
GIVE_COTTON("솜뭉치 주기 성공"),
GET_MEMBER_HOME("홈화면 정보 조회 성공"),

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/soptie/server/domain/member/Member.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.soptie.server.domain.member;

import java.time.LocalDateTime;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -13,6 +15,7 @@ public class Member {
private Social socialInfo;
private String refreshToken;
private MemberCotton cottonInfo;
private LocalDateTime createdAt;

public Member(SocialType socialType, String socialId) {
this.socialInfo = new Social(socialType, socialId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.soptie.server.api.controller.dto.request.member.CreateProfileRequest;
import com.soptie.server.api.controller.dto.response.member.GetHomeInfoResponse;
import com.soptie.server.api.controller.dto.response.member.GiveMemberCottonResponse;
import com.soptie.server.api.controller.dto.response.member.MemberProfileResponse;
import com.soptie.server.common.exception.ExceptionCode;
import com.soptie.server.common.exception.SoftieException;
import com.soptie.server.domain.conversation.Conversation;
Expand Down Expand Up @@ -77,4 +78,9 @@ private void createMemberDoll(long memberId, DollType dollType, String name) {
memberDollAdapter.save(new MemberDoll(name, dollType, memberId, doll.getId()));
}
}

public MemberProfileResponse getMemberProfile(long memberId) {
val member = memberAdapter.findById(memberId);
return MemberProfileResponse.from(member);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public Member toDomain() {
.socialInfo(toSocialInfo())
.refreshToken(this.refreshToken)
.cottonInfo(toCottonInfo())
.createdAt(this.createdAt)
.build();
}

Expand Down

0 comments on commit b4e3b9b

Please sign in to comment.