From 03e178e169efee5437fb64a392cda6f78be39459 Mon Sep 17 00:00:00 2001 From: DongGeon Lee <71763322+himodu@users.noreply.github.com> Date: Mon, 20 May 2024 19:31:36 +0900 Subject: [PATCH] [ADD] commentCount add in BoothDetail - commentCount add --- .../LlikelionKNU/KNUfest/domain/booth/dto/BoothDetail.java | 1 + .../LlikelionKNU/KNUfest/domain/booth/entity/BoothEntity.java | 4 ++++ .../KNUfest/domain/booth/service/BoothServiceImpl.java | 1 + .../KNUfest/domain/comment/service/CommentServiceImpl.java | 1 + 4 files changed, 7 insertions(+) diff --git a/src/main/java/LlikelionKNU/KNUfest/domain/booth/dto/BoothDetail.java b/src/main/java/LlikelionKNU/KNUfest/domain/booth/dto/BoothDetail.java index c9c1d59..99583ed 100644 --- a/src/main/java/LlikelionKNU/KNUfest/domain/booth/dto/BoothDetail.java +++ b/src/main/java/LlikelionKNU/KNUfest/domain/booth/dto/BoothDetail.java @@ -13,6 +13,7 @@ public class BoothDetail { private String host; private String boothDescription; private int likes; + private int commentCount; private String categori; private int boothnum; private List urls; diff --git a/src/main/java/LlikelionKNU/KNUfest/domain/booth/entity/BoothEntity.java b/src/main/java/LlikelionKNU/KNUfest/domain/booth/entity/BoothEntity.java index 9c6e2da..ec9ae8a 100644 --- a/src/main/java/LlikelionKNU/KNUfest/domain/booth/entity/BoothEntity.java +++ b/src/main/java/LlikelionKNU/KNUfest/domain/booth/entity/BoothEntity.java @@ -37,6 +37,10 @@ public class BoothEntity extends BasicEntity { @Column(name="host") private String host; + @Column(name="commentCount") + @ColumnDefault("0") + private int commentCount; + @OneToMany(mappedBy = "booth", fetch = FetchType.LAZY) private List commentEntityList; diff --git a/src/main/java/LlikelionKNU/KNUfest/domain/booth/service/BoothServiceImpl.java b/src/main/java/LlikelionKNU/KNUfest/domain/booth/service/BoothServiceImpl.java index af5108b..11e022c 100644 --- a/src/main/java/LlikelionKNU/KNUfest/domain/booth/service/BoothServiceImpl.java +++ b/src/main/java/LlikelionKNU/KNUfest/domain/booth/service/BoothServiceImpl.java @@ -93,6 +93,7 @@ public BoothDetail getBooth(int boothnum, String categori, String userHash) { .host(booth.getHost()) .boothDescription(booth.getDescription()) .likes(booth.getLikes()) + .commentCount(booth.getCommentCount()) .boothnum(booth.getBoothnum()) .categori(booth.getCategori()) .urls(booth.getUrls()) diff --git a/src/main/java/LlikelionKNU/KNUfest/domain/comment/service/CommentServiceImpl.java b/src/main/java/LlikelionKNU/KNUfest/domain/comment/service/CommentServiceImpl.java index 50a2bfe..0647112 100644 --- a/src/main/java/LlikelionKNU/KNUfest/domain/comment/service/CommentServiceImpl.java +++ b/src/main/java/LlikelionKNU/KNUfest/domain/comment/service/CommentServiceImpl.java @@ -70,6 +70,7 @@ public Long postComment(int boothNum, String categori, CommentRequest commentReq throw new NoExistException("해당 부스 정보가 없습니다. (카테고리, 부스번호 확인 요망)"); }else{ booth = boothOp.get(); + booth.setCommentCount(booth.getCommentCount()+1); } CommentEntity newComment = Comment.toEntity(commentRequest, booth, user);