Skip to content

Commit

Permalink
Merge pull request #80 from Team-baebae/fix/FcmAnswer/#76
Browse files Browse the repository at this point in the history
Fix/fcm answer/#76
  • Loading branch information
tioon authored May 15, 2024
2 parents 27d7c90 + 86b2bc9 commit d0527df
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ public class AnswerDetailResponse {
private Integer heartCount;
private Integer curiousCount;
private Integer sadCount;
private Integer connectCount;

public AnswerDetailResponse(Long answerId, Long questionId, String questionContent, Long memberId,
String content, String memberNickname, String nickname, Boolean profileOnOff,
String linkAttachments, String musicName, String musicSinger, String musicAudioUrl,
String imageUrl, LocalDateTime createdDate,
Integer heartCount, Integer curiousCount, Integer sadCount) {
Integer heartCount, Integer curiousCount, Integer sadCount, Integer connectCount) {
this.answerId = answerId;
this.questionId = questionId;
this.questionContent = questionContent;
Expand All @@ -49,16 +50,17 @@ public AnswerDetailResponse(Long answerId, Long questionId, String questionConte
this.heartCount = heartCount;
this.curiousCount = curiousCount;
this.sadCount = sadCount;
this.connectCount = connectCount;
}

public static AnswerDetailResponse of(Long answerId, Long questionId, String questionContent, Long memberId,
String content, String memberNickname, String nickname, Boolean profileOnOff,
String linkAttachments, String musicName, String musicSinger, String musicAudioUrl,
String imageUrl, LocalDateTime createdDate,
Integer heartCount, Integer curiousCount, Integer sadCount) {
Integer heartCount, Integer curiousCount, Integer sadCount, Integer connectCount) {
return new AnswerDetailResponse(answerId, questionId, questionContent, memberId, content, memberNickname,
nickname, profileOnOff, linkAttachments, musicName, musicSinger, musicAudioUrl, imageUrl, createdDate,
heartCount, curiousCount, sadCount);
heartCount, curiousCount, sadCount, connectCount);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public class Answer {
@Column(name = "sad_count", nullable = false)
private int sadCount;

@Column(name = "connect_count", nullable = false)
private int connectCount;

@Column(name = "created_date", nullable = false)
private LocalDateTime createdDate;

Expand All @@ -82,23 +85,10 @@ public class Answer {

public static Answer of(Long id, Question question, Category category, Member member, String nickname,String content,
List<String> imageFiles, Music music, String linkAttachments, String imageUrl, int heartCount,
int curiousCount, int sadCount, LocalDateTime createdDate, boolean profileOnOff) {
int curiousCount, int sadCount, int connectCount, LocalDateTime createdDate, boolean profileOnOff) {

return new Answer(id, question, category, member, nickname, imageFiles, content, music, linkAttachments,imageUrl, heartCount,
curiousCount, sadCount, createdDate,null, profileOnOff);
curiousCount, sadCount, connectCount, createdDate,null, profileOnOff);
}

public void increaseReactionCount(ReactionValue reaction) {
switch (reaction) {
case HEART: // 좋아요
this.heartCount++;
break;
case CURIOUS: // 궁금해요
this.curiousCount++;
break;
case SAD: // 슬퍼요
this.sadCount++;
break;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public AnswerDetailResponse toDomain(Answer answer) {
answer.getCreatedDate(),
answer.getHeartCount(),
answer.getCuriousCount(),
answer.getSadCount()
answer.getSadCount(),
answer.getConnectCount()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public QuestionDetailResponse createQuestion(QuestionCreateRequest request, Long
Question question = questionMapper.toEntity(request, member);
Question savedQuestion = questionRepository.save(question);

firebaseNotificationService.notifyNewQuestion(member, question); // 파이어베이스 메세지 송신
//firebaseNotificationService.notifyNewQuestion(member, question); // 파이어베이스 메세지 송신

return questionMapper.toDomain(savedQuestion);
}
Expand All @@ -54,7 +54,7 @@ public QuestionDetailResponse updateQuestion(Long questionId, String content, Bo
// 질문 업데이트 후 저장
Question updatedQuestion = questionRepository.save(question);

firebaseNotificationService.notifyNewQuestion(updatedQuestion.getMember(), updatedQuestion); // 파이어베이스 메세지 송신
//firebaseNotificationService.notifyNewQuestion(updatedQuestion.getMember(), updatedQuestion); // 파이어베이스 메세지 송신

return questionMapper.toDomain(updatedQuestion);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public ResponseEntity<ReactionResponse.ReactionInformationDto> createReaction(
return ResponseEntity.ok(memberAnswerReactionService.createReaction(memberId, answerId, reactionDto.getReaction()));
}

// 통했당~
/*// 통했당~
@PostMapping("/connection/{memberId}/{answerId}/{destinationMemberId}")
public ResponseEntity<ReactionResponse.ConnectionReactionInformationDto> createClickReaction(
@PathVariable Long memberId, // 자기자신 (통했당 하는 주체)
Expand All @@ -36,5 +36,5 @@ public ResponseEntity<ReactionResponse.ConnectionReactionInformationDto> createC
return ResponseEntity.ok(memberAnswerReactionService.createConnectionReaction(memberId, answerId));
else
return ResponseEntity.ok(memberAnswerReactionService.connectConnectionReaction(memberId, answerId, destinationMemberId));
}
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ResponseEntity<ReactionResponse.ReactionInformationDto> createReaction(@Paramete
@Parameter(description = "답변의 ID", required = true) @PathVariable Long answerId,
@RequestBody ReactionRequest.create reactionDto);

@Operation(
/* @Operation(
summary = "통했당 생성",
description = "지정된 멤버 ID, 답변 ID, 대상 멤버 ID에 대한 '통했당'을 생성합니다. " +
"다른 피드에 '통했당'을 남길경우 memberId, answerId만 필요합니다. " +
Expand Down Expand Up @@ -98,5 +98,5 @@ ResponseEntity<ReactionResponse.ReactionInformationDto> createReaction(@Paramete
})
ResponseEntity<ReactionResponse.ConnectionReactionInformationDto> createClickReaction(@Parameter(description = "멤버의 ID", required = true) @PathVariable Long memberId,
@Parameter(description = "답변의 ID", required = true) @PathVariable Long answerId,
@Parameter(description = "대상 멤버의 ID (피드주인이 통했당 완료할때만 가능)", required = false) @RequestParam(required = false) Long destinationMemberId);
@Parameter(description = "대상 멤버의 ID (피드주인이 통했당 완료할때만 가능)", required = false) @RequestParam(required = false) Long destinationMemberId);*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ public static class ReactionInformationDto {
private int heartCount;
private int curiousCount;
private int sadCount;
private int connectCount;

public static ReactionInformationDto of(Answer answer, boolean isClicked) {
return ReactionInformationDto.builder()
.isClicked(isClicked)
.heartCount(answer.getHeartCount())
.curiousCount(answer.getCuriousCount())
.sadCount(answer.getSadCount())
.connectCount(answer.getConnectCount())
.build();
}
}

@Getter
/*@Getter
@Setter
@Builder
@NoArgsConstructor
Expand All @@ -42,5 +44,5 @@ public static ConnectionReactionInformationDto of(boolean isClicked, boolean isM
.isMatched(isMatched)
.build();
}
}
}*/
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.web.baebaeBE.domain.reaction.entity;

public enum ReactionValue {
HEART, CURIOUS, SAD, CONNECTION
HEART, CURIOUS, SAD, CONNECT
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public ReactionResponse.ReactionInformationDto createReaction(Long memberId, Lon
return ReactionResponse.ReactionInformationDto.of(answer,isClicked);
}

// 피드 주인이 아닌 다른 사람이 통했당 신청
/*// 피드 주인이 아닌 다른 사람이 통했당 신청
public ReactionResponse.ConnectionReactionInformationDto createConnectionReaction(Long memberId, Long answerId) {
Member member = memberRepository.findById(memberId)
.orElseThrow(() -> new BusinessException(ReactionException.NOT_EXIST_MEMBER));
Expand Down Expand Up @@ -107,5 +107,5 @@ public ReactionResponse.ConnectionReactionInformationDto connectConnectionReacti
} else {
throw new BusinessException(ReactionException.NOT_EXIST_CONNECTION_REACTION);
}
}
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public void increaseReactionCount(Answer answer, ReactionValue reaction) {
case SAD: // 슬퍼요
answer.setSadCount(answer.getSadCount() + 1);
break;
case CONNECT: // 통했당
answer.setConnectCount(answer.getConnectCount() + 1);
break;
}
}

Expand All @@ -36,6 +39,9 @@ public void decreaseReactionCount(Answer answer, ReactionValue reaction) {
case SAD: // 슬퍼요
answer.setSadCount(answer.getSadCount() - 1);
break;
case CONNECT: // 통했당
answer.setConnectCount(answer.getConnectCount() - 1);
break;
}
}
}

0 comments on commit d0527df

Please sign in to comment.