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