Skip to content

Commit

Permalink
Merge pull request #135 from Mojacknong/fix_134
Browse files Browse the repository at this point in the history
팜클럽 성공 검증 및 댓글 신고 수정
  • Loading branch information
Ryeolee authored Sep 24, 2024
2 parents 9b788f9 + 9ad24f6 commit 5f67749
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public enum FarmClubErrorCode implements ResponseCode {
FARM_CLUB_NOT_FOUND(3001, "해당 팜클럽을 찾을 수 없습니다."),
USER_FARM_CLUB_NOT_FOUND(3002, "해당 등록 정보를 찾을 수 없습니다."),
MISSION_POST_NOT_FOUND(3003, "해당 미션 포스트를 찾을 수 없습니다."),
MISSION_POST_COMMENT_NOT_FOUND(3004, "해당 미션 포스트 댓글을 찾을 수 없습니다.");
MISSION_POST_COMMENT_NOT_FOUND(3004, "해당 미션 포스트 댓글을 찾을 수 없습니다."),
USER_FARM_CLUB_COMPLETE(3005, "이미 완료된 팜클럽입니다.");

private final int code;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@ public Optional<UserFarmClub> findFarmClubByMyVeggieId(Long myVeggieId){
public SuccessFarmClubVo getFarmClubRecord(Long userId, Long farmClubId) {
return userFarmClubRepository.getFarmClubRecord(userId, farmClubId);
}

public void checkUserFarmClubComplete(UserFarmClub userFarmClub) {
if (userFarmClub.isComplete()) {
throw new FarmClubEntityNotFoundException("이미 완료된 팜클럽입니다.", FarmClubErrorCode.USER_FARM_CLUB_COMPLETE);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ public GetMissionPostCommentResponseDto getMissionPostComment(Long missionPostId
.select(new QMissionPostCommentVo(
missionPostComment,
user,
Expressions.constant(userId),
missionPostComment.id.in(reportCommentIds)
Expressions.constant(userId)
))
.from(missionPostComment)
.join(missionPostComment.missionPost, missionPost)
.where(missionPost.id.eq(missionPostId))
.where(missionPost.id.eq(missionPostId).and(missionPostComment.id.notIn(reportCommentIds)))
.fetch();

Boolean isMyPost = queryFactory
Expand All @@ -88,6 +87,12 @@ public List<MissionPostVo> getMissionPostList(Long userId, Long farmClubId) {
.where(missionPostReport.user.id.eq(userId))
.fetch();

List<Long> reportCommentIds = queryFactory
.select(missionPostCommentReport.missionPostComment.id)
.from(missionPostCommentReport)
.where(missionPostCommentReport.user.id.eq(userId))
.fetch();

return queryFactory
.select(new QMissionPostVo(
missionPost,
Expand All @@ -97,7 +102,8 @@ public List<MissionPostVo> getMissionPostList(Long userId, Long farmClubId) {
.where(missionPostLike.missionPost.eq(missionPost)),
JPAExpressions.select(missionPostComment.count())
.from(missionPostComment)
.where(missionPostComment.missionPost.eq(missionPost)),
.where(missionPostComment.missionPost.eq(missionPost)
.and(missionPostComment.id.notIn(reportCommentIds))),
JPAExpressions.selectOne()
.from(missionPostLike)
.where(missionPostLike.missionPost.eq(missionPost)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public RegisterFarmClubResponseDto registerFarmClub(Long farmClubId, Long myVegg
@Transactional
public SuccessFarmClubResponseDto successFarmClub(Long farmClubId, Long userId) {
UserFarmClub userFarmClub = userFarmClubHelper.findByUserIdAndFarmClubId(userId, farmClubId);
userFarmClubHelper.checkUserFarmClubComplete(userFarmClub);
userFarmClub.updateComplete();
SuccessFarmClubVo farmClubRecord = userFarmClubHelper.getFarmClubRecord(userId, farmClubId);
String period = historyHelper.createFarmClubHistoryDetail(userId, userFarmClub.getId(), userFarmClub.getFarmClub().getVeggieInfoId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@ public record MissionPostCommentVo(
String profileImage,
String date,
String content,
Boolean isMyComment,
Boolean isReported
Boolean isMyComment
) {
@QueryProjection
public MissionPostCommentVo(MissionPostComment missionPostComment, User user, Long myId, Boolean isReported)
public MissionPostCommentVo(MissionPostComment missionPostComment, User user, Long myId)
{
this(
missionPostComment.getId(),
user.getNickname(),
user.getProfileImage(),
missionPostComment.getCreatedDate().toString(),
missionPostComment.getComment(),
user.getId().equals(myId),
isReported
user.getId().equals(myId)
);
}
}

0 comments on commit 5f67749

Please sign in to comment.