-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 이름 수정 API 구현 및 Facade 적용 (#94)
- Loading branch information
Showing
12 changed files
with
93 additions
and
11 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
module-domain/src/main/java/com/depromeet/member/port/in/usecase/NameUpdateUseCase.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,7 @@ | ||
package com.depromeet.member.port.in.usecase; | ||
|
||
import com.depromeet.member.domain.Member; | ||
|
||
public interface NameUpdateUseCase { | ||
Member updateName(Long memberId, String name); | ||
} |
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
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
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
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
8 changes: 8 additions & 0 deletions
8
module-presentation/src/main/java/com/depromeet/member/api/MemberApi.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 |
---|---|---|
@@ -1,13 +1,21 @@ | ||
package com.depromeet.member.api; | ||
|
||
import com.depromeet.dto.response.ApiResponse; | ||
import com.depromeet.member.annotation.LoginMember; | ||
import com.depromeet.member.dto.request.NameUpdateRequest; | ||
import com.depromeet.member.dto.response.MemberFindOneResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
|
||
@Tag(name = "사용자(members)") | ||
public interface MemberApi { | ||
@Operation(summary = "id로 member 단일 검색") | ||
ApiResponse<MemberFindOneResponse> getMember(@PathVariable("id") Long id); | ||
|
||
@Operation(summary = "닉네임 수정") | ||
ApiResponse<MemberFindOneResponse> updateName( | ||
@LoginMember Long id, | ||
@RequestBody NameUpdateRequest updateNameRequest); | ||
} |
20 changes: 14 additions & 6 deletions
20
module-presentation/src/main/java/com/depromeet/member/api/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 |
---|---|---|
@@ -1,25 +1,33 @@ | ||
package com.depromeet.member.api; | ||
|
||
import com.depromeet.dto.response.ApiResponse; | ||
import com.depromeet.member.annotation.LoginMember; | ||
import com.depromeet.member.domain.Member; | ||
import com.depromeet.member.dto.request.NameUpdateRequest; | ||
import com.depromeet.member.dto.response.MemberFindOneResponse; | ||
import com.depromeet.member.facade.MemberFacade; | ||
import com.depromeet.member.port.in.usecase.MemberUseCase; | ||
import com.depromeet.type.member.MemberSuccessType; | ||
import lombok.RequiredArgsConstructor; | ||
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.RestController; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/member") | ||
public class MemberController implements MemberApi { | ||
private final MemberUseCase memberUseCase; | ||
private final MemberFacade memberFacade; | ||
|
||
@GetMapping("/{id}") | ||
public ApiResponse<MemberFindOneResponse> getMember(@PathVariable("id") Long id) { | ||
Member member = memberUseCase.findById(id); | ||
Member member = memberFacade.findById(id); | ||
return ApiResponse.success(MemberSuccessType.GET_SUCCESS, MemberFindOneResponse.of(member)); | ||
} | ||
|
||
@PatchMapping | ||
public ApiResponse<MemberFindOneResponse> updateName( | ||
@LoginMember Long id, | ||
@RequestBody NameUpdateRequest updateNameRequest) { | ||
Member member = memberFacade.updateName(id, updateNameRequest.name()); | ||
return ApiResponse.success(MemberSuccessType.UPDATE_NAME_SUCCESS, MemberFindOneResponse.of(member)); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
module-presentation/src/main/java/com/depromeet/member/dto/request/NameUpdateRequest.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,6 @@ | ||
package com.depromeet.member.dto.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record NameUpdateRequest(@NotNull String name) { | ||
} |
29 changes: 29 additions & 0 deletions
29
module-presentation/src/main/java/com/depromeet/member/facade/MemberFacade.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,29 @@ | ||
package com.depromeet.member.facade; | ||
|
||
import com.depromeet.member.domain.Member; | ||
import com.depromeet.member.port.in.command.SocialMemberCommand; | ||
import com.depromeet.member.port.in.usecase.MemberUseCase; | ||
import com.depromeet.member.port.in.usecase.NameUpdateUseCase; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class MemberFacade { | ||
private final MemberUseCase memberUseCase; | ||
private final NameUpdateUseCase nameUpdateUseCase; | ||
|
||
public Member findById(Long memberId) { | ||
return memberUseCase.findById(memberId); | ||
} | ||
|
||
public Member findOrCreateMemberBy(SocialMemberCommand command) { | ||
return memberUseCase.findOrCreateMemberBy(command); | ||
} | ||
|
||
public Member updateName(Long memberId, String name) { | ||
return nameUpdateUseCase.updateName(memberId, name); | ||
} | ||
} |