-
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: 방 상세 정보 페이지 구현(#33, #36) #78
Changes from all commits
2f66f33
5d912cb
7aa07c9
218488f
60b19f0
10c0235
6f8e470
44b80cf
011e4f3
aab55a9
16b8a3e
571c851
e9d72fb
949f185
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 |
---|---|---|
@@ -1,13 +1,15 @@ | ||
package corea.room.domain; | ||
|
||
import corea.member.domain.Member; | ||
import corea.util.StringToListConverter; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import static jakarta.persistence.GenerationType.IDENTITY; | ||
|
||
|
@@ -33,7 +35,8 @@ public class Room { | |
@Column(length = 32768) | ||
private String thumbnailLink; | ||
|
||
private String keyword; | ||
@Convert(converter = StringToListConverter.class) | ||
private List<String> keyword; | ||
|
||
private int currentParticipantsSize; | ||
|
||
|
@@ -55,14 +58,22 @@ public class Room { | |
* 1. 방장이 모집 마감을 한 경우 | ||
* 2. 제한 인원이 다 찼을 경우 (방에 참여할 때 같이 검증) | ||
* 3. 모집 기간이 끝난 경우 | ||
* | ||
* <p> | ||
* 1, 2의 경우 때문에 방 상태를 가지는 필드를 가져야 될듯. | ||
* **/ | ||
**/ | ||
@Enumerated(value = EnumType.STRING) | ||
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) { | ||
public Room(String title, String content, int matchingSize, String repositoryLink, String thumbnailLink, List<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); | ||
} | ||
|
||
public boolean isOpen() { | ||
return status.isOpen(); | ||
} | ||
|
||
public boolean isClosed() { | ||
return status.isClosed(); | ||
} | ||
Comment on lines
+70
to
+77
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. isOpen 과 isClosed 를 분리한 이유가 궁금합니다! status ENUM 에서 OPENED 와 CLOSED 만 존재한다면, 둘 중 하나만 남겨둬도 될 것 같아요! 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. 앞에 |
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,10 @@ public record RoomResponse( | |
long currentParticipants, | ||
long limitedParticipants, | ||
LocalDateTime recruitmentDeadline, | ||
LocalDateTime reviewDeadline | ||
LocalDateTime reviewDeadline, | ||
boolean isParticipated, | ||
boolean isClosed | ||
) { | ||
|
||
public static RoomResponse from(Room room) { | ||
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. 해당 코드에서 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. 👍 |
||
return new RoomResponse( | ||
room.getId(), | ||
|
@@ -29,11 +30,33 @@ public static RoomResponse from(Room room) { | |
room.getRepositoryLink(), | ||
room.getThumbnailLink(), | ||
room.getMatchingSize(), | ||
List.of(room.getKeyword()), | ||
room.getKeyword(), | ||
room.getCurrentParticipantsSize(), | ||
room.getLimitedParticipantsSize(), | ||
room.getRecruitmentDeadline(), | ||
room.getReviewDeadline(), | ||
false, | ||
room.isOpen() | ||
); | ||
} | ||
|
||
public static RoomResponse from(Room room, boolean isParticipated) { | ||
return new RoomResponse( | ||
room.getId(), | ||
room.getTitle(), | ||
room.getContent(), | ||
room.getManager() | ||
.getName(), | ||
room.getRepositoryLink(), | ||
room.getThumbnailLink(), | ||
room.getMatchingSize(), | ||
room.getKeyword(), | ||
room.getCurrentParticipantsSize(), | ||
room.getLimitedParticipantsSize(), | ||
room.getRecruitmentDeadline(), | ||
room.getReviewDeadline() | ||
room.getReviewDeadline(), | ||
isParticipated, | ||
room.isClosed() | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package corea.util; | ||
|
||
import jakarta.persistence.AttributeConverter; | ||
import jakarta.persistence.Converter; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
@Converter | ||
public class StringToListConverter implements AttributeConverter<List<String>, String> { | ||
|
||
private static final String DELIMITER = ", "; | ||
|
||
@Override | ||
public String convertToDatabaseColumn(List<String> source) { | ||
return String.join(DELIMITER, source); | ||
} | ||
|
||
@Override | ||
public List<String> convertToEntityAttribute(String source) { | ||
return Arrays.stream(source.split(DELIMITER)) | ||
.toList(); | ||
} | ||
} |
This file was deleted.
This file was deleted.
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.
👍