Skip to content

Commit

Permalink
fix: Init Db 및 데이터베이스 생성 관련 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
dong2ast committed Jul 12, 2023
1 parent 2447d9d commit 38ff5f0
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/sophy/sophy/InitDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void dbInit() {
.place(place2)
.title("테스트 타이틀")
.booktalkImageUrl("dwqE@EWQDQFQEWQ")
.author(author)
.member(author)
.bookCategory(BookCategory.HUMANITIES)
.startDate(LocalDateTime.of(2023, 7, 13, 13, 0))
.endDate(LocalDateTime.of(2023, 7, 13, 15, 0))
Expand All @@ -102,7 +102,7 @@ public void dbInit() {
.place(place)
.title("테스트 타이틀2")
.booktalkImageUrl("dwqE@EWQDQFQEWQ")
.author(author)
.member(author)
.bookCategory(BookCategory.HEALTH_COOKING)
.startDate(LocalDateTime.of(2023, 7, 18, 16, 0))
.endDate(LocalDateTime.of(2023, 7, 18, 18, 0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Booktalk toBooktalk(Place place, Member member) {
.preliminaryInfo(preliminaryInfo)
.description(description)
.booktalkStatus(BooktalkStatus.APPLYING)
.author(member)
.member(member)
.place(place)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static BooktalkDetailResponseDto of(Booktalk booktalk) {
return new BooktalkDetailResponseDto(
booktalk.getBooktalkImageUrl(),
booktalk.getTitle(),
booktalk.getAuthor().getName(),
booktalk.getMember().getName(),
booktalk.getBookCategory(),
"책이름", //TODO 추후 연결
booktalk.getStartDate(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static BooktalkResponseDto of(Booktalk booktalk) {
booktalk.getId(),
booktalk.getPreliminaryInfo().ordinal(),
booktalk.getTitle(),
booktalk.getAuthor().getName(),
booktalk.getMember().getName(),
booktalk.getStartDate(),
booktalk.getEndDate(),
booktalk.getPlace().getName(),
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/sophy/sophy/domain/Booktalk.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public class Booktalk extends AuditingTimeEntity {

private String booktalkImageUrl;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.CONSTRAINT))
private Member author;
@OneToOne
@JoinColumn(name = "member_id")
private Member member; //작가 = 북토크당 1명

@Column(nullable = false)
@Enumerated(EnumType.STRING)
Expand Down Expand Up @@ -76,21 +76,21 @@ public void setPlace(Place place) {
}

public void setAuthor(Member member) {
if (this.author != null) {
this.author.getAuthorProperty().getMyBookTalkList().remove(this);
if (this.member != null) {
this.member.getAuthorProperty().getMyBookTalkList().remove(this);
}
this.author = member;
this.member = member;
if (!member.getAuthorProperty().getMyBookTalkList().contains(this)) {
member.getAuthorProperty().getMyBookTalkList().add(this);
}
}

@Builder
public Booktalk(Place place, String title, String booktalkImageUrl, Member author, BookCategory bookCategory, LocalDateTime startDate, LocalDateTime endDate, Integer maximum, Integer participationFee, PreliminaryInfo preliminaryInfo, String description, BooktalkStatus booktalkStatus) {
public Booktalk(Place place, String title, String booktalkImageUrl, Member member, BookCategory bookCategory, LocalDateTime startDate, LocalDateTime endDate, Integer maximum, Integer participationFee, PreliminaryInfo preliminaryInfo, String description, BooktalkStatus booktalkStatus) {
setPlace(place);
this.title = title;
this.booktalkImageUrl = booktalkImageUrl;
setAuthor(author);
setAuthor(member);
this.bookCategory = bookCategory;
this.startDate = startDate;
this.endDate = endDate;
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/org/sophy/sophy/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ public class Member extends AuditingTimeEntity{
private Integer bookCount;
private Integer bookTalkCount;

@OneToOne
private Booktalk imminentBooktalk;

@OneToMany(mappedBy = "member")
private List<MemberBooktalk> userBookTalkList;

Expand Down Expand Up @@ -85,10 +82,6 @@ public void setBookTalkCount(int count) {
this.bookTalkCount = count;
}

public void changeImminentBooktalk(Booktalk booktalk) {
this.imminentBooktalk = booktalk;
}

public void setAdditionalInfo(MemberAdditionalInfoDto memberAdditionalInfoDto) {
this.gender = memberAdditionalInfoDto.getGender();
this.birth = memberAdditionalInfoDto.getBirth();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface BooktalkRepository extends JpaRepository<Booktalk, Long> {
List<Booktalk> findAllByAuthorId(Long authorId); //Booktalk의 작가
}
2 changes: 1 addition & 1 deletion src/main/java/org/sophy/sophy/service/BooktalkService.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public BooktalkDeleteResponseDto deleteBooktalk(Long booktalkId) {
//TODO soft delete?
//공간이 거절 됐거나 공간 매칭중일 때만 삭제가능
booktalk.getPlace().deleteBooktalk(booktalk);
booktalk.getAuthor().getAuthorProperty().deleteBooktalk(booktalk);
booktalk.getMember().getAuthorProperty().deleteBooktalk(booktalk);
booktalkRepository.deleteById(booktalkId);
return BooktalkDeleteResponseDto.of(booktalkId);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/sophy/sophy/service/MemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public List<MyPageBooktalkDto> getBooktalksByMemberId(Long memberId) { //예정
.booktalkId(booktalk.getId())
.booktalkImageUrl(booktalk.getBooktalkImageUrl())
.title(booktalk.getTitle())
.author(booktalk.getAuthor().getName())
.author(booktalk.getMember().getName())
.startDate(booktalk.getStartDate())
.endDate(booktalk.getEndDate())
.place(booktalk.getPlace().getName())
Expand All @@ -105,7 +105,7 @@ public List<MyPageBooktalkDto> getAuthorBooktalksByMemberId(Long memberId) { //
.booktalkId(booktalk.getId())
.booktalkImageUrl(booktalk.getBooktalkImageUrl())
.title(booktalk.getTitle())
.author(booktalk.getAuthor().getName())
.author(booktalk.getMember().getName())
.startDate(booktalk.getStartDate())
.endDate(booktalk.getEndDate())
.place(booktalk.getPlace().getName())
Expand Down

0 comments on commit 38ff5f0

Please sign in to comment.