-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…-api [FEAT] 회원 정보 조회 API
- Loading branch information
Showing
6 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...ver/src/main/java/com/example/growthookserver/api/member/controller/MemberController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MemberDetailGetResponseDto> getMemberProfile(@PathVariable("memberId") Long memberId) { | ||
return ApiResponse.success(SuccessStatus.GET_MEMBER_PROFILE, memberService.getMemberProfile(memberId)); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
.../java/com/example/growthookserver/api/member/dto/response/MemberDetailGetResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
9 changes: 9 additions & 0 deletions
9
...ookServer/src/main/java/com/example/growthookserver/api/member/service/MemberService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
...erver/src/main/java/com/example/growthookserver/api/member/service/MemberServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters