-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Member 생성, 조회, 수정 구현 #12
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2ed5212
feat: 멤버 생성
yeeunli 8fe3efa
Revert "feat: 멤버 생성"
yeeunli 29b2e84
feat: 멤버 생성, 조회, 수정 서비스 로직 구현
yeeunli 6c428c3
feat: 멤버 생성, 조회, 수정 컨트롤러 구현
yeeunli 08c6823
chore: 멤버 도메인에 멤버 수정 로직 추가
yeeunli e379980
feat: 멤버 관련 dto 구현
yeeunli 65d6413
refactor: MemberController api 관련 어노테이션 추가
yeeunli b5f1e96
refactor: MemberService에 transactional 추가
yeeunli 86e6b33
refactor: Member 도메인 생성자 접근 제어자 protected로 추가
yeeunli af3eb16
refactor: Member dto record로 변경
yeeunli 23381cc
refactor: Member 응답 메시지 삭제
yeeunli 178ec0f
refactor: Member @Transactional 적용 변경
yeeunli fb72a9b
refactor: Member 정보 수정 로직 Optional로 변경
yeeunli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
src/main/java/com/gdgoc/study_group/member/application/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,61 @@ | ||
package com.gdgoc.study_group.member.application; | ||
|
||
import com.gdgoc.study_group.member.dao.MemberRepository; | ||
import com.gdgoc.study_group.member.domain.Member; | ||
import com.gdgoc.study_group.member.dto.request.MemberCreateRequestDto; | ||
import com.gdgoc.study_group.member.dto.request.MemberUpdateRequestDto; | ||
import java.util.NoSuchElementException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class MemberService { | ||
|
||
private final MemberRepository memberRepository; | ||
|
||
/** | ||
* 새 멤버를 생성합니다. | ||
* | ||
* @param request 새로 만들 멤버 정보 | ||
* @return Member 형태로 반환 | ||
*/ | ||
public Member createMember(MemberCreateRequestDto request) { | ||
|
||
Member newMember = | ||
Member.builder() | ||
.name(request.getName()) | ||
.github(request.getGithub()) | ||
.studentNumber(request.getStudentNumber()) | ||
.build(); | ||
|
||
return memberRepository.save(newMember); | ||
} | ||
|
||
/** | ||
* 멤버를 조회합니다. | ||
* | ||
* @param memberId 멤버를 조회할 정보 | ||
* @return Member 형태로 반환 | ||
*/ | ||
public Member getMember(Long memberId) { | ||
return memberRepository | ||
.findById(memberId) | ||
.orElseThrow(() -> new NoSuchElementException("member not found")); | ||
} | ||
|
||
/** | ||
* 멤버가 정보를 수정합니다. | ||
* | ||
* @param memberId 멤버를 조회할 정보 | ||
* @param request 수정할 정보 | ||
*/ | ||
@Transactional | ||
public void updateMember(Long memberId, MemberUpdateRequestDto request) { | ||
|
||
Member member = getMember(memberId); | ||
|
||
member.updateMember(request.getName(), request.getGithub(), request.getStudentNumber()); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class 에 transactional readOnly 걸고, write 하는 메소드만 다시 어노테이션 거는게 어떠하옵니까