-
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.
* ✨ [STMT-171] 스터디 가입 API 구현 * ✅ [STMT-171] 테스트용 유저 데이터 추가 * ✅ [STMT-171] 멤버 스터디 가입 API 테스트 코드 작성 및 문서화 * ✅ [STMT-171] 이미 가입된 멤버일때 실패하는 케이스 추가 * ♻️ [STMT-171] 메시지를 예외 클래스안에서 관리하도록 변경 * ♻️ [STMT-171] first_login 상태에서 MEMBER 상태로 변경
- Loading branch information
Showing
17 changed files
with
350 additions
and
56 deletions.
There are no files selected for viewing
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
37 changes: 37 additions & 0 deletions
37
src/main/java/com/stumeet/server/studymember/adapter/in/web/StudyMemberJoinApi.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,37 @@ | ||
package com.stumeet.server.studymember.adapter.in.web; | ||
|
||
import com.stumeet.server.common.annotation.WebAdapter; | ||
import com.stumeet.server.common.auth.model.LoginMember; | ||
import com.stumeet.server.common.model.ApiResponse; | ||
import com.stumeet.server.common.response.SuccessCode; | ||
import com.stumeet.server.studymember.adapter.in.web.mapper.StudyMemberJoinWebAdapterMapper; | ||
import com.stumeet.server.studymember.application.port.in.StudyMemberJoinUseCase; | ||
import com.stumeet.server.studymember.application.port.in.command.StudyMemberJoinCommand; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
@WebAdapter | ||
@RequestMapping("/api/v1") | ||
@RequiredArgsConstructor | ||
public class StudyMemberJoinApi { | ||
|
||
private final StudyMemberJoinUseCase studyMemberJoinUseCase; | ||
private final StudyMemberJoinWebAdapterMapper studyMemberJoinWebAdapterMapper; | ||
|
||
@PostMapping("/studies/{studyId}/members") | ||
public ResponseEntity<ApiResponse<Void>> join( | ||
@PathVariable Long studyId, | ||
@AuthenticationPrincipal LoginMember member | ||
) { | ||
StudyMemberJoinCommand command = studyMemberJoinWebAdapterMapper.toCommand(studyId, member.getMember().getId()); | ||
studyMemberJoinUseCase.join(command); | ||
|
||
return ResponseEntity.status(HttpStatus.OK) | ||
.body(ApiResponse.success(SuccessCode.STUDY_JOIN_SUCCESS)); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...com/stumeet/server/studymember/adapter/in/web/mapper/StudyMemberJoinWebAdapterMapper.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,15 @@ | ||
package com.stumeet.server.studymember.adapter.in.web.mapper; | ||
|
||
import com.stumeet.server.studymember.application.port.in.command.StudyMemberJoinCommand; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class StudyMemberJoinWebAdapterMapper { | ||
public StudyMemberJoinCommand toCommand(Long studyId, Long memberId) { | ||
return StudyMemberJoinCommand.builder() | ||
.studyId(studyId) | ||
.memberId(memberId) | ||
.isAdmin(false) | ||
.build(); | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
...java/com/stumeet/server/studymember/domain/exception/AlreadyStudyJoinMemberException.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,13 @@ | ||
package com.stumeet.server.studymember.domain.exception; | ||
|
||
import com.stumeet.server.common.exception.model.InvalidStateException; | ||
import com.stumeet.server.common.response.ErrorCode; | ||
|
||
import java.text.MessageFormat; | ||
|
||
public class AlreadyStudyJoinMemberException extends InvalidStateException { | ||
private static final String MESSAGE = "이미 스터디에 가입한 멤버입니다. studyId={0}, memberId={1}"; | ||
public AlreadyStudyJoinMemberException(Long studyId, Long memberId) { | ||
super(MessageFormat.format(MESSAGE, studyId, memberId), ErrorCode.ALREADY_STUDY_JOIN_MEMBER_EXCEPTION); | ||
} | ||
} |
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
Oops, something went wrong.