-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 회원가입 약관 도메인 추가 * feat: 회원가입 약관 목록 조회 기능 추가 * refactor: 정보 입력 중 필수 약관에 동의하도록 리팩토링 * fix: 약관 사용여부 디폴트 값 false로 수정 * test: 회원가입 이후, 정보 입력 시 변경된 방법으로 인한 테스트 수정 * test: 필수 약관 Id Set을 변경 및 Fixture수정 및 추가 * test: 비즈니스 로직 변경으로 인한 테스트 코드 수정 * feat: 필수 약관 동의 시, 저장 비즈니스 로직 추가 * fix: 매개변수 명 수정 * fix: memberId 로 매개변수 변경 * test: test description 수정 * chore: TermService 임시로 exclude 추가
- Loading branch information
Showing
17 changed files
with
322 additions
and
12 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
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
24 changes: 24 additions & 0 deletions
24
src/main/java/com/ssafy/ssafsound/domain/term/controller/TermController.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,24 @@ | ||
package com.ssafy.ssafsound.domain.term.controller; | ||
|
||
import com.ssafy.ssafsound.domain.term.dto.GetTermsResDto; | ||
import com.ssafy.ssafsound.domain.term.service.TermService; | ||
import com.ssafy.ssafsound.global.common.response.EnvelopeResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/terms") | ||
@RequiredArgsConstructor | ||
public class TermController { | ||
|
||
private final TermService termService; | ||
|
||
@GetMapping | ||
public EnvelopeResponse<GetTermsResDto> getTerms() { | ||
return EnvelopeResponse.<GetTermsResDto>builder() | ||
.data(termService.getTerms()) | ||
.build(); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/ssafy/ssafsound/domain/term/domain/MemberTermAgreement.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,46 @@ | ||
package com.ssafy.ssafsound.domain.term.domain; | ||
|
||
import com.ssafy.ssafsound.domain.BaseTimeEntity; | ||
import com.ssafy.ssafsound.domain.member.domain.Member; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Entity(name = "member_term_agreement") | ||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class MemberTermAgreement extends BaseTimeEntity { | ||
|
||
@Id | ||
@Column(name = "member_term_agreement_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "term_id") | ||
private Term term; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
public static List<MemberTermAgreement> ofMemberAndTerms(Member member, List<Term> terms) { | ||
return terms.stream() | ||
.map(term -> MemberTermAgreement.builder().member(member).term(term).build()) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/com/ssafy/ssafsound/domain/term/domain/Term.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,44 @@ | ||
package com.ssafy.ssafsound.domain.term.domain; | ||
|
||
import com.ssafy.ssafsound.domain.BaseTimeEntity; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
|
||
|
||
@Entity(name="term") | ||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class Term extends BaseTimeEntity { | ||
|
||
@Id | ||
@Column(name = "term_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column | ||
private String content; | ||
|
||
@Column | ||
private String name; | ||
|
||
@Column | ||
@Builder.Default | ||
private Boolean usedYN = false; | ||
|
||
@Column | ||
@Builder.Default | ||
private Boolean requiredYN = false; | ||
|
||
@Column | ||
private Integer sequence; | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/ssafy/ssafsound/domain/term/domain/TermElement.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,33 @@ | ||
package com.ssafy.ssafsound.domain.term.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class TermElement { | ||
|
||
private Long termId; | ||
|
||
private String termName; | ||
|
||
private String content; | ||
|
||
private Boolean requiredYN; | ||
|
||
private Integer sequence; | ||
|
||
public static TermElement from(Term term) { | ||
return TermElement.builder() | ||
.termId(term.getId()) | ||
.termName(term.getName()) | ||
.content(term.getContent()) | ||
.requiredYN(term.getRequiredYN()) | ||
.sequence(term.getSequence()) | ||
.build(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/ssafy/ssafsound/domain/term/dto/GetTermsResDto.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,19 @@ | ||
package com.ssafy.ssafsound.domain.term.dto; | ||
|
||
import com.ssafy.ssafsound.domain.term.domain.TermElement; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@Builder | ||
public class GetTermsResDto { | ||
List<TermElement> termElements; | ||
|
||
public static GetTermsResDto fromTermElements(List<TermElement> termElements) { | ||
return GetTermsResDto.builder() | ||
.termElements(termElements) | ||
.build(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/ssafy/ssafsound/domain/term/repository/MemberTermAgreementRepository.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,9 @@ | ||
package com.ssafy.ssafsound.domain.term.repository; | ||
|
||
import com.ssafy.ssafsound.domain.term.domain.MemberTermAgreement; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface MemberTermAgreementRepository extends JpaRepository<MemberTermAgreement, Long> { | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/ssafy/ssafsound/domain/term/repository/TermRepository.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,33 @@ | ||
package com.ssafy.ssafsound.domain.term.repository; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import com.ssafy.ssafsound.domain.term.domain.Term; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
import static com.ssafy.ssafsound.domain.term.domain.QTerm.term; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class TermRepository { | ||
|
||
private final JPAQueryFactory jpaQueryFactory; | ||
|
||
public List<Term> getTerms() { | ||
return jpaQueryFactory | ||
.selectFrom(term) | ||
.where(term.usedYN.eq(true)) | ||
.orderBy(term.sequence.asc()) | ||
.fetch(); | ||
|
||
} | ||
|
||
public List<Term> getRequiredTerms() { | ||
return jpaQueryFactory | ||
.selectFrom(term) | ||
.where(term.usedYN.eq(true), term.requiredYN.eq(true)) | ||
.fetch(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/ssafy/ssafsound/domain/term/service/TermService.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,25 @@ | ||
package com.ssafy.ssafsound.domain.term.service; | ||
|
||
import com.ssafy.ssafsound.domain.term.domain.TermElement; | ||
import com.ssafy.ssafsound.domain.term.dto.GetTermsResDto; | ||
import com.ssafy.ssafsound.domain.term.repository.TermRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class TermService { | ||
|
||
private final TermRepository termRepository; | ||
|
||
@Transactional(readOnly = true) | ||
public GetTermsResDto getTerms() { | ||
return GetTermsResDto.fromTermElements(termRepository | ||
.getTerms().stream() | ||
.map(TermElement::from) | ||
.collect(Collectors.toList())); | ||
} | ||
} |
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.