Skip to content

Commit

Permalink
Merge pull request #217 from themoment-team/develop
Browse files Browse the repository at this point in the history
Develop - 운영을 위한 도메인 핫픽스
  • Loading branch information
jyeonjyan authored Oct 10, 2021
2 parents 5b1d543 + 412af85 commit 5c5245f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/moment/the/admin/AdminDomain.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class AdminDomain implements UserDetails {
private String password;

@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "role", joinColumns = @JoinColumn(name = "admin_id"))
@Builder.Default
private List<String> roles = new ArrayList<>();

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/moment/the/answer/AnswerDomain.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class AnswerDomain {
@Column(name = "content", length = 1000, nullable = false)
private String content;

@OneToOne(fetch = LAZY)
@OneToOne(fetch = LAZY, mappedBy = "answerDomain")
@JoinColumn(name = "uncomfortable_id", nullable = false)
private UncomfortableDomain uncomfortableDomain;

Expand All @@ -34,7 +34,7 @@ public void update(AnswerDto answerDto) {
this.content = answerDto.getContent();
}

public void updateTableDomain(UncomfortableDomain uncomfortableDomain){
public void updateAnswerDomain(UncomfortableDomain uncomfortableDomain){
this.uncomfortableDomain = uncomfortableDomain;
this.uncomfortableDomain.updateAnswerDomain(this);
}
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/com/moment/the/answer/service/AnswerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ public AnswerDomain createThisAnswer(AnswerDto answerDto, Long uncomfortableIdx)
// AnswerDomain 생성 및 Table 과의 연관관계 맻음
answerDto.setAdminDomain(adminDomain);
AnswerDomain saveAnswerDomain = answerDto.toEntity();
saveAnswerDomain.updateTableDomain(uncomfortableDomain);
saveAnswerDomain.updateAnswerDomain(uncomfortableDomain);

AnswerDomain savedAnswerDomain = answerRepo.save(saveAnswerDomain);

return savedAnswerDomain;
return answerRepo.save(saveAnswerDomain);
}

// 답변 수정하기
Expand All @@ -59,14 +57,12 @@ public AnswerResDto getThisAnswer(Long uncomfortableIdx) {
// 해당 uncomfortableIdx를 참조하는 answerDomain 찾기.
AnswerDomain answerDomain = answerRepo.findTop1ByUncomfortableDomain_uncomfortableIdx(uncomfortableIdx);

AnswerResDto answerResDto = AnswerResDto.builder()
return AnswerResDto.builder()
.answerIdx(answerDomain.getAnswerIdx())
.title(answerDomain.getUncomfortableDomain().getContent())
.content(answerDomain.getContent())
.writer(answerDomain.getAdminDomain().getName())
.build();

return answerResDto;
}

// 답변 삭제하기
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class UncomfortableDomain {
private int goods;

@OneToOne(fetch = LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "answer_id")
private AnswerDomain answerDomain;

public void updateGoods(int goods){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ public int getDateSinceProjectStart(){
* D-day를 계산하는 메서드.
* @return int
*/
public static int calculateAfterDate(){
// today: 오늘 날짜
// theMomentStart: the-moment 시작 날짜
private static int calculateAfterDate() {
// today: 오늘 날짜
// theMomentStart: the-moment 시작 날짜
LocalDate today = LocalDate.now();
LocalDate theMomentStart = LocalDate.of(2021, 6, 7);

Expand All @@ -116,4 +116,11 @@ public static int calculateAfterDate(){

return period;
}

private void refreshGoodsOnThisDayOfEveryMonth(){
LocalDate today = LocalDate.now();
if (today.getDayOfMonth() == 1 || today.getDayOfMonth() == 14){

}
}
}

0 comments on commit 5c5245f

Please sign in to comment.