From b78f11b5a54da90f8d1b09930840009b8acbc422 Mon Sep 17 00:00:00 2001 From: yeseul106 <20191037@sungshin.ac.kr> Date: Mon, 8 Jan 2024 03:57:05 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT]=20=EB=A9=A4=EB=B2=84=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?API=20=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/controller/MemberController.java | 31 +++++++++++++++++++ .../response/MemberDetailGetResponseDto.java | 14 +++++++++ .../api/member/service/MemberService.java | 9 ++++++ .../api/member/service/MemberServiceImpl.java | 22 +++++++++++++ .../review/controller/ReviewController.java | 2 +- .../common/response/SuccessStatus.java | 5 +++ 6 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 growthookServer/src/main/java/com/example/growthookserver/api/member/controller/MemberController.java create mode 100644 growthookServer/src/main/java/com/example/growthookserver/api/member/dto/response/MemberDetailGetResponseDto.java create mode 100644 growthookServer/src/main/java/com/example/growthookserver/api/member/service/MemberService.java create mode 100644 growthookServer/src/main/java/com/example/growthookserver/api/member/service/MemberServiceImpl.java diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/member/controller/MemberController.java b/growthookServer/src/main/java/com/example/growthookserver/api/member/controller/MemberController.java new file mode 100644 index 0000000..0cd6ec8 --- /dev/null +++ b/growthookServer/src/main/java/com/example/growthookserver/api/member/controller/MemberController.java @@ -0,0 +1,31 @@ +package com.example.growthookserver.api.member.controller; + +import com.example.growthookserver.api.member.dto.response.MemberDetailGetResponseDto; +import com.example.growthookserver.api.member.service.MemberService; +import com.example.growthookserver.common.response.ApiResponse; +import com.example.growthookserver.common.response.SuccessStatus; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("api/v1") +@Tag(name = "Member - 유저 관련 API", description = "Member API Document") +public class MemberController { + + private final MemberService memberService; + + @GetMapping("/member/{memberId}/profile") + @ResponseStatus(HttpStatus.OK) + @Operation(summary = "MemberProfileGet", description = "멤버 프로필을 조회하는 API입니다.") + public ApiResponse getMemberProfile(@PathVariable("memberId") Long memberId) { + return ApiResponse.success(SuccessStatus.GET_MEMBER_PROFILE, memberService.getMemberProfile(memberId)); + } +} diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/member/dto/response/MemberDetailGetResponseDto.java b/growthookServer/src/main/java/com/example/growthookserver/api/member/dto/response/MemberDetailGetResponseDto.java new file mode 100644 index 0000000..5e413f7 --- /dev/null +++ b/growthookServer/src/main/java/com/example/growthookserver/api/member/dto/response/MemberDetailGetResponseDto.java @@ -0,0 +1,14 @@ +package com.example.growthookserver.api.member.dto.response; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(staticName = "of") +public class MemberDetailGetResponseDto { + private String nickname; + private String email; +} diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/member/service/MemberService.java b/growthookServer/src/main/java/com/example/growthookserver/api/member/service/MemberService.java new file mode 100644 index 0000000..6f282c1 --- /dev/null +++ b/growthookServer/src/main/java/com/example/growthookserver/api/member/service/MemberService.java @@ -0,0 +1,9 @@ +package com.example.growthookserver.api.member.service; + +import com.example.growthookserver.api.member.dto.response.MemberDetailGetResponseDto; + +public interface MemberService { + //* 멤버 프로필 정보 조회 + MemberDetailGetResponseDto getMemberProfile(Long memberId); + +} diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/member/service/MemberServiceImpl.java b/growthookServer/src/main/java/com/example/growthookserver/api/member/service/MemberServiceImpl.java new file mode 100644 index 0000000..a4e2c26 --- /dev/null +++ b/growthookServer/src/main/java/com/example/growthookserver/api/member/service/MemberServiceImpl.java @@ -0,0 +1,22 @@ +package com.example.growthookserver.api.member.service; + +import com.example.growthookserver.api.member.domain.Member; +import com.example.growthookserver.api.member.dto.response.MemberDetailGetResponseDto; +import com.example.growthookserver.api.member.repository.MemberRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class MemberServiceImpl implements MemberService{ + + private final MemberRepository memberRepository; + + @Override + public MemberDetailGetResponseDto getMemberProfile(Long memberId) { + Member member = memberRepository.findMemberByIdOrThrow(memberId); + return MemberDetailGetResponseDto.of(member.getNickname(), member.getEmail()); + } +} diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java b/growthookServer/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java index 8425446..74f34e3 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java @@ -36,7 +36,7 @@ public ApiResponse createReview(@PathVariable("actionPlanId") Long actionPlanId, @GetMapping("actionplan/{actionPlanId}/review") @ResponseStatus(HttpStatus.OK) - @Operation(summary = "ReveiwGet", description = "리뷰 상세 조회 API입니다.") + @Operation(summary = "ReviewGet", description = "리뷰 상세 조회 API입니다.") public ApiResponse getReviewDetail(@PathVariable("actionPlanId") Long actionPlanId) { return ApiResponse.success(SuccessStatus.GET_REVIEW_DETAIL, reviewService.getReviewDetail(actionPlanId)); } diff --git a/growthookServer/src/main/java/com/example/growthookserver/common/response/SuccessStatus.java b/growthookServer/src/main/java/com/example/growthookserver/common/response/SuccessStatus.java index 05842d3..3e780c6 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/common/response/SuccessStatus.java +++ b/growthookServer/src/main/java/com/example/growthookserver/common/response/SuccessStatus.java @@ -56,6 +56,11 @@ public enum SuccessStatus { */ POST_REVIEW_SUCCESS(HttpStatus.CREATED, "리뷰 생성 성공"), GET_REVIEW_DETAIL(HttpStatus.OK, "리뷰 내용 상세 조회 성공"), + + /** + * member + */ + GET_MEMBER_PROFILE(HttpStatus.OK, "멤버 프로필 정보 조회 성공"), ; private final HttpStatus httpStatus;