|
1 | 1 | package clap.server.adapter.inbound.web.member; |
2 | 2 |
|
3 | 3 | import clap.server.adapter.inbound.security.SecurityUserDetails; |
| 4 | +import clap.server.adapter.inbound.web.dto.member.MemberDetailInfoResponse; |
4 | 5 | import clap.server.adapter.inbound.web.dto.member.MemberProfileResponse; |
5 | | -import clap.server.application.port.inbound.member.MemberInfoUsecase; |
| 6 | +import clap.server.adapter.inbound.web.dto.member.UpdateMemberInfoRequest; |
| 7 | +import clap.server.application.port.inbound.member.UpdateMemberInfoUsecase; |
| 8 | +import clap.server.application.port.inbound.member.MemberDetailInfoUsecase; |
| 9 | +import clap.server.application.port.inbound.member.MemberProfileUsecase; |
6 | 10 | import clap.server.common.annotation.architecture.WebAdapter; |
7 | 11 | import io.swagger.v3.oas.annotations.Operation; |
8 | 12 | import io.swagger.v3.oas.annotations.tags.Tag; |
9 | 13 | import lombok.RequiredArgsConstructor; |
| 14 | +import org.springframework.http.MediaType; |
10 | 15 | import org.springframework.http.ResponseEntity; |
11 | 16 | import org.springframework.security.core.annotation.AuthenticationPrincipal; |
12 | 17 | import org.springframework.web.bind.annotation.GetMapping; |
| 18 | +import org.springframework.web.bind.annotation.PatchMapping; |
13 | 19 | import org.springframework.web.bind.annotation.RequestMapping; |
| 20 | +import org.springframework.web.bind.annotation.RequestPart; |
| 21 | +import org.springframework.web.multipart.MultipartFile; |
| 22 | + |
| 23 | +import java.io.IOException; |
14 | 24 |
|
15 | 25 | @Tag(name = "01. Member", description = "회원 정보 조회 및 수정 API") |
16 | 26 | @WebAdapter |
17 | 27 | @RequiredArgsConstructor |
18 | 28 | @RequestMapping("/api/members") |
19 | 29 | public class MemberInfoController { |
20 | | - private final MemberInfoUsecase memberInfoUsecase; |
| 30 | + private final MemberProfileUsecase memberProfileUsecase; |
| 31 | + private final MemberDetailInfoUsecase memberDetailInfoUsecase; |
| 32 | + private final UpdateMemberInfoUsecase updateMemberInfoUsecase; |
21 | 33 |
|
22 | | - @Operation(summary = "회원 프로필을 조회합니다. 활성화된 회원만 조회 가능합니다.") |
| 34 | + @Operation(summary = "회원 프로필 조회 API") |
23 | 35 | @GetMapping("/profile") |
24 | 36 | public ResponseEntity<MemberProfileResponse> getMemberProfile(@AuthenticationPrincipal SecurityUserDetails userInfo) { |
25 | | - return ResponseEntity.ok(memberInfoUsecase.getMemberProfile(userInfo.getUserId())); |
| 37 | + return ResponseEntity.ok(memberProfileUsecase.getMemberProfile(userInfo.getUserId())); |
| 38 | + } |
| 39 | + |
| 40 | + @Operation(summary = "회원 상세 정보 조회 API") |
| 41 | + @GetMapping("/info") |
| 42 | + public ResponseEntity<MemberDetailInfoResponse> getMemberDetailInfo(@AuthenticationPrincipal SecurityUserDetails userInfo) { |
| 43 | + return ResponseEntity.ok(memberDetailInfoUsecase.getMemberInfo(userInfo.getUserId())); |
26 | 44 | } |
27 | 45 |
|
| 46 | + @Operation(summary = "회원 정보 수정 API", description = "이미지 수정이 없을 시에는 profileImage를 보내지 않습니다.") |
| 47 | + @PatchMapping(value = "/info", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, MediaType.APPLICATION_JSON_VALUE}) |
| 48 | + public void updateMemberDetailInfo( |
| 49 | + @RequestPart(name = "memberInfo") UpdateMemberInfoRequest request, |
| 50 | + @RequestPart(name = "profileImage", required = false) MultipartFile profileImage, |
| 51 | + @AuthenticationPrincipal SecurityUserDetails userInfo) throws IOException { |
| 52 | + updateMemberInfoUsecase.updateMemberInfo(userInfo.getUserId(), request, profileImage); |
| 53 | + } |
28 | 54 | } |
0 commit comments