From 9ec82648bc61cb0316c2da9d0b99730b123858e6 Mon Sep 17 00:00:00 2001 From: hanamgyu Date: Mon, 26 Aug 2024 05:06:59 +0900 Subject: [PATCH] =?UTF-8?q?hotfix-=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20?= =?UTF-8?q?=ED=98=84=EC=9E=AC=20=EC=83=81=ED=83=9C=20=EC=9D=91=EB=8B=B5=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../post/dto/AccompanyPostResponse.java | 4 ++-- .../post/entity/AccompanyPostEntity.java | 3 --- .../service/impl/AccompanyPostServiceImpl.java | 14 +++++++++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/connectripbe/connectrip_be/post/dto/AccompanyPostResponse.java b/src/main/java/connectripbe/connectrip_be/post/dto/AccompanyPostResponse.java index 3987ba87..99e1e5ca 100644 --- a/src/main/java/connectripbe/connectrip_be/post/dto/AccompanyPostResponse.java +++ b/src/main/java/connectripbe/connectrip_be/post/dto/AccompanyPostResponse.java @@ -24,7 +24,7 @@ public record AccompanyPostResponse( String createdAt ) { - public static AccompanyPostResponse fromEntity(AccompanyPostEntity accompanyPost) { + public static AccompanyPostResponse fromEntity(AccompanyPostEntity accompanyPost, String status) { return AccompanyPostResponse.builder() .id(accompanyPost.getId()) @@ -38,7 +38,7 @@ public static AccompanyPostResponse fromEntity(AccompanyPostEntity accompanyPost .customUrl(accompanyPost.getCustomUrl()) .urlQrPath(accompanyPost.getUrlQrPath()) .content(accompanyPost.getContent()) - .status(accompanyPost.getRequestStatus()) + .status(status) .createdAt(formatToUTC(accompanyPost.getCreatedAt())) .build(); diff --git a/src/main/java/connectripbe/connectrip_be/post/entity/AccompanyPostEntity.java b/src/main/java/connectripbe/connectrip_be/post/entity/AccompanyPostEntity.java index 2ecf159b..695992aa 100644 --- a/src/main/java/connectripbe/connectrip_be/post/entity/AccompanyPostEntity.java +++ b/src/main/java/connectripbe/connectrip_be/post/entity/AccompanyPostEntity.java @@ -43,9 +43,6 @@ public class AccompanyPostEntity extends BaseEntity { private String content; // fixme-eric 동행 요청 상태 임시보류 - @Column(name = "request_status") - @Builder.Default - private String requestStatus = "DEFAULT"; public AccompanyPostEntity(MemberEntity memberEntity, String title, LocalDateTime startDate, LocalDateTime endDate, String accompanyArea, String customUrl, String urlQrPath, String content) { this.memberEntity = memberEntity; diff --git a/src/main/java/connectripbe/connectrip_be/post/service/impl/AccompanyPostServiceImpl.java b/src/main/java/connectripbe/connectrip_be/post/service/impl/AccompanyPostServiceImpl.java index 308153f7..acffec67 100644 --- a/src/main/java/connectripbe/connectrip_be/post/service/impl/AccompanyPostServiceImpl.java +++ b/src/main/java/connectripbe/connectrip_be/post/service/impl/AccompanyPostServiceImpl.java @@ -51,7 +51,6 @@ public void createAccompanyPost(Long memberId, CreateAccompanyPostRequest reques .accompanyArea(request.accompanyArea()) .urlQrPath("temp") .customUrl(request.customUrl()) - .requestStatus("DEFAULT") .build(); accompanyPostRepository.save(post); @@ -67,8 +66,12 @@ public void createAccompanyPost(Long memberId, CreateAccompanyPostRequest reques @Transactional(readOnly = true) public AccompanyPostResponse readAccompanyPost(long id) { AccompanyPostEntity accompanyPostEntity = findAccompanyPostEntity(id); + AccompanyStatusEntity accompanyStatusEntity = accompanyStatusJpaRepository + .findTopByAccompanyPostEntityOrderByCreatedAtDesc(accompanyPostEntity) + .orElseThrow(NotFoundAccompanyPostException::new); - return AccompanyPostResponse.fromEntity(accompanyPostEntity); + return AccompanyPostResponse.fromEntity(accompanyPostEntity, + accompanyStatusEntity.getAccompanyStatusEnum().toString()); } @Override @@ -80,6 +83,10 @@ public AccompanyPostResponse updateAccompanyPost(Long memberId, long id, validateAccompanyPostOwnership(memberEntity, accompanyPostEntity); + AccompanyStatusEntity accompanyStatusEntity = accompanyStatusJpaRepository + .findTopByAccompanyPostEntityOrderByCreatedAtDesc(accompanyPostEntity) + .orElseThrow(NotFoundAccompanyPostException::new); + accompanyPostEntity.updateAccompanyPost( request.title(), request.startDate(), @@ -90,7 +97,8 @@ public AccompanyPostResponse updateAccompanyPost(Long memberId, long id, ); // 수정된 데이터를 응답으로 반환 - return AccompanyPostResponse.fromEntity(accompanyPostEntity); + return AccompanyPostResponse.fromEntity(accompanyPostEntity, accompanyStatusEntity + .getAccompanyStatusEnum().toString()); } @Override