-
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
Changes from 1 commit
2ed5212
8fe3efa
29b2e84
6c428c3
08c6823
e379980
65d6413
b5f1e96
86e6b33
af3eb16
23381cc
178ec0f
fb72a9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
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.MemberCreateRequestDto; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class MemberService { | ||
|
||
private final MemberRepository memberRepository; | ||
|
||
// public MemberService(MemberRepository memberRepository) { | ||
// this.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); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,15 @@ | |
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.OneToMany; | ||
import lombok.*; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Entity | ||
@Builder | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. builder 로만 생성가능하도록 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 허허 이미 그렇게 올라가있느니라 |
||
@Getter | ||
public class Member { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DTO 는 record 로 바꾸는게 권장드리옵니다 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.gdgoc.study_group.member.dto; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class MemberCreateRequestDto { | ||
|
||
private String name; | ||
private String github; | ||
private String studentNumber; | ||
|
||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이것도 record 로 바꿔드리기를 간청드리옵니다 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.gdgoc.study_group.member.dto; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class MemberUpdateRequestDto { | ||
|
||
private String name; | ||
private String github; | ||
private String studentNumber; | ||
|
||
} |
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 하는 메소드만 다시 어노테이션 거는게 어떠하옵니까