Skip to content

Commit

Permalink
refactor: 댓글방 상태 도메인 설계 변경 (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
helenason authored Aug 7, 2024
1 parent 32e37ec commit f208968
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 133 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.zzang.chongdae.offering.controller;

import com.zzang.chongdae.comment.service.dto.CommentRoomStatusResponse;
import com.zzang.chongdae.member.repository.entity.MemberEntity;
import com.zzang.chongdae.offering.service.OfferingService;
import com.zzang.chongdae.offering.service.dto.CommentRoomStatusResponse;
import com.zzang.chongdae.offering.service.dto.OfferingAllResponse;
import com.zzang.chongdae.offering.service.dto.OfferingDetailResponse;
import com.zzang.chongdae.offering.service.dto.OfferingFilterAllResponse;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.zzang.chongdae.offering.domain;

import lombok.Getter;

@Getter
public enum CommentRoomStatus {

GROUPING,
BUYING,
TRADING,
DONE;

static {
GROUPING.nextStatus = BUYING;
BUYING.nextStatus = TRADING;
TRADING.nextStatus = DONE;
DONE.nextStatus = DONE;
}

private CommentRoomStatus nextStatus;

public CommentRoomStatus nextStatus() {
return this.nextStatus;
}

public boolean isGrouping() {
return this == GROUPING;
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import com.zzang.chongdae.global.repository.entity.BaseTimeEntity;
import com.zzang.chongdae.member.repository.entity.MemberEntity;
import com.zzang.chongdae.offering.domain.CommentRoomStatus;
import com.zzang.chongdae.offering.domain.OfferingMeeting;
import com.zzang.chongdae.offering.domain.OfferingPrice;
import com.zzang.chongdae.offering.domain.OfferingStatus;
import com.zzang.chongdae.offering.domain.status.CommentRoomStatus;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.zzang.chongdae.offering.service;

import com.zzang.chongdae.comment.service.dto.CommentRoomStatusResponse;
import com.zzang.chongdae.global.exception.MarketException;
import com.zzang.chongdae.member.repository.entity.MemberEntity;
import com.zzang.chongdae.offering.domain.CommentRoomStatus;
import com.zzang.chongdae.offering.domain.OfferingFilter;
import com.zzang.chongdae.offering.domain.OfferingPrice;
import com.zzang.chongdae.offering.domain.OfferingStatus;
import com.zzang.chongdae.offering.domain.status.CommentRoomStatus;
import com.zzang.chongdae.offering.exception.OfferingErrorCode;
import com.zzang.chongdae.offering.repository.OfferingRepository;
import com.zzang.chongdae.offering.repository.entity.OfferingEntity;
import com.zzang.chongdae.offering.service.dto.CommentRoomStatusResponse;
import com.zzang.chongdae.offering.service.dto.OfferingAllResponse;
import com.zzang.chongdae.offering.service.dto.OfferingAllResponseItem;
import com.zzang.chongdae.offering.service.dto.OfferingDetailResponse;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.zzang.chongdae.offering.service.dto;

import com.zzang.chongdae.offering.domain.CommentRoomStatus;

public record CommentRoomStatusResponse(CommentRoomStatus updatedStatus) {
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.zzang.chongdae.offering.service.dto;

import static com.zzang.chongdae.offering.domain.status.CommentRoomStatus.GROUPING;
import static com.zzang.chongdae.offering.domain.CommentRoomStatus.GROUPING;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zzang.chongdae.member.repository.entity.MemberEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package com.zzang.chongdae.offering.service.dto;

import static com.zzang.chongdae.offering.domain.status.CommentRoomStatus.BUYING;
import static com.zzang.chongdae.offering.domain.status.CommentRoomStatus.DONE;
import static com.zzang.chongdae.offering.domain.status.CommentRoomStatus.GROUPING;
import static com.zzang.chongdae.offering.domain.status.CommentRoomStatus.TRADING;
import static com.zzang.chongdae.offering.domain.CommentRoomStatus.BUYING;
import static com.zzang.chongdae.offering.domain.CommentRoomStatus.DONE;
import static com.zzang.chongdae.offering.domain.CommentRoomStatus.GROUPING;
import static com.zzang.chongdae.offering.domain.CommentRoomStatus.TRADING;

import com.zzang.chongdae.global.exception.MarketException;
import com.zzang.chongdae.offering.domain.status.CommentRoomStatus;
import com.zzang.chongdae.offering.domain.CommentRoomStatus;
import com.zzang.chongdae.offering.exception.OfferingErrorCode;
import java.util.Arrays;
import java.util.List;

public record OfferingStatusResponse(String status,
public record OfferingStatusResponse(CommentRoomStatus status,
List<String> steps) {

public OfferingStatusResponse(CommentRoomStatus commentRoomStatus) {
this(commentRoomStatus.name(), OfferingStatusResponseMapper.toView(commentRoomStatus));
this(commentRoomStatus, ViewMapper.toView(commentRoomStatus));
}

private enum OfferingStatusResponseMapper {
private enum ViewMapper {

GROUPING_VIEW(GROUPING, List.of("모집중", "인원확정", "구매중", "거래중")),
BUYING_VIEW(BUYING, List.of("모집중", "인원확정", "구매중", "거래중")),
Expand All @@ -28,14 +28,14 @@ private enum OfferingStatusResponseMapper {
private final CommentRoomStatus roomStatus;
private final List<String> view;

OfferingStatusResponseMapper(CommentRoomStatus roomStatus, List<String> view) {
ViewMapper(CommentRoomStatus roomStatus, List<String> view) {
this.roomStatus = roomStatus;
this.view = view;
}

private static List<String> toView(CommentRoomStatus roomStatus) {
return Arrays.stream(values())
.filter((value) -> value.roomStatus.equals(roomStatus))
.filter(mapper -> mapper.roomStatus.equals(roomStatus))
.findFirst()
.orElseThrow(() -> new MarketException(OfferingErrorCode.INVALID_CONDITION))
.view;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.zzang.chongdae.global.domain;

import com.zzang.chongdae.member.repository.entity.MemberEntity;
import com.zzang.chongdae.offering.domain.status.CommentRoomStatus;
import com.zzang.chongdae.offering.domain.CommentRoomStatus;
import com.zzang.chongdae.offering.repository.OfferingRepository;
import com.zzang.chongdae.offering.repository.entity.OfferingEntity;
import java.time.LocalDateTime;
Expand Down

0 comments on commit f208968

Please sign in to comment.