Skip to content

Commit

Permalink
Merge pull request #84 from 100-hours-a-week/fix-postStatus
Browse files Browse the repository at this point in the history
hotfix- 게시물 현재 상태 응답 수정
  • Loading branch information
Namgyu11 authored Aug 25, 2024
2 parents 7f89477 + 9ec8264 commit e72a107
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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(),
Expand All @@ -90,7 +97,8 @@ public AccompanyPostResponse updateAccompanyPost(Long memberId, long id,
);

// 수정된 데이터를 응답으로 반환
return AccompanyPostResponse.fromEntity(accompanyPostEntity);
return AccompanyPostResponse.fromEntity(accompanyPostEntity, accompanyStatusEntity
.getAccompanyStatusEnum().toString());
}

@Override
Expand Down

0 comments on commit e72a107

Please sign in to comment.