-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BE] feat: 모집 중인 방 리스트 API 구현(#30) #68
Changes from 1 commit
9c61695
a61ee3a
488df13
868a02a
99e9c35
87eaf1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package corea.room.domain; | ||
|
||
import corea.exception.CoreaException; | ||
import corea.exception.ExceptionType; | ||
|
||
import java.util.Arrays; | ||
import java.util.Map; | ||
import java.util.function.Function; | ||
|
||
import static java.util.stream.Collectors.toMap; | ||
|
||
public enum Classification { | ||
|
||
ALL("all"), | ||
ANDROID("an"), | ||
BACKEND("be"), | ||
FRONTEND("fe"); | ||
|
||
private static final Map<String, Classification> CACHED_CLASSIFICATIONS = Arrays.stream(values()) | ||
.collect(toMap(classification -> classification.expression, Function.identity())); | ||
|
||
private final String expression; | ||
|
||
Classification(String expression) { | ||
this.expression = expression; | ||
} | ||
|
||
public static Classification from(String expression) { | ||
if (CACHED_CLASSIFICATIONS.containsKey(expression)) { | ||
return CACHED_CLASSIFICATIONS.get(expression); | ||
} | ||
throw new CoreaException(ExceptionType.NOT_FOUND_ERROR); | ||
} | ||
|
||
public boolean isAll() { | ||
return this == ALL; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,15 +40,29 @@ public class Room { | |
private int limitedParticipantsSize; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "manager_id",foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) | ||
@JoinColumn(name = "manager_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) | ||
private Member manager; | ||
|
||
private LocalDateTime recruitmentDeadline; | ||
|
||
private LocalDateTime reviewDeadline; | ||
|
||
public Room(String title, String content, int matchingSize, String repositoryLink, String thumbnailLink, String keyword, int currentParticipantsSize, int limitedParticipantsSize, Member manager, LocalDateTime recruitmentDeadline, LocalDateTime reviewDeadline) { | ||
this(null, title, content, matchingSize, repositoryLink, thumbnailLink, keyword, currentParticipantsSize, limitedParticipantsSize, manager, recruitmentDeadline, reviewDeadline); | ||
@Enumerated(value = EnumType.STRING) | ||
private Classification classification; | ||
|
||
/** | ||
* RoomStatus가 변경될 수 있는 경우 (OPENED -> CLOSED) | ||
* 1. 방장이 모집 마감을 한 경우 | ||
* 2. 제한 인원이 다 찼을 경우 (방에 참여할 때 같이 검증) | ||
* 3. 모집 기간이 끝난 경우 | ||
* | ||
* 1, 2의 경우 때문에 방 상태를 가지는 필드를 가져야 될듯. | ||
* **/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
@Enumerated(value = EnumType.STRING) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 괜찮은듯. |
||
private RoomStatus status; | ||
|
||
public Room(String title, String content, int matchingSize, String repositoryLink, String thumbnailLink, String keyword, int currentParticipantsSize, int limitedParticipantsSize, Member manager, LocalDateTime recruitmentDeadline, LocalDateTime reviewDeadline, Classification classification, RoomStatus status) { | ||
this(null, title, content, matchingSize, repositoryLink, thumbnailLink, keyword, currentParticipantsSize, limitedParticipantsSize, manager, recruitmentDeadline, reviewDeadline, classification, status); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package corea.room.domain; | ||
|
||
public enum RoomStatus { | ||
|
||
OPENED, CLOSED | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package corea.room.fixture; | ||
|
||
import corea.member.domain.Member; | ||
import corea.room.domain.Classification; | ||
import corea.room.domain.RoomStatus; | ||
import corea.room.dto.RoomCreateRequest; | ||
|
||
import java.time.LocalDateTime; | ||
|
@@ -19,6 +21,9 @@ public static RoomCreateRequest ROOM_CREATE_REQUEST(Member member) { | |
15, | ||
20, | ||
LocalDateTime.of(2024, 12, 25, 12, 0), | ||
LocalDateTime.of(2024, 12, 30, 12, 0)); | ||
LocalDateTime.of(2024, 12, 30, 12, 0), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. now + plusDay 로 하지 않고 |
||
Classification.BACKEND, | ||
RoomStatus.OPENED | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Classification
을 조회하려는 경우가 많을 것 같아 미리 캐싱하여 사용하도록 해보았는데, 괜츈나요??There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
누군가의 발표가 생각나네요 👍