-
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 7 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 | ||||
---|---|---|---|---|---|---|
|
@@ -10,6 +10,9 @@ | |||||
@Getter | ||||||
public class AuthInfo { | ||||||
|
||||||
private static final long NOT_EXIST_ID = -1L; | ||||||
private static final AuthInfo ANONYMOUS = new AuthInfo(NOT_EXIST_ID, "", ""); | ||||||
|
||||||
private final Long id; | ||||||
private final String name; | ||||||
private final String email; | ||||||
|
@@ -18,6 +21,17 @@ public static AuthInfo from(Member member){ | |||||
return new AuthInfo(member.getId(), member.getUserName(), member.getEmail()); | ||||||
} | ||||||
|
||||||
public boolean isAnonymous() { | ||||||
return id == NOT_EXIST_ID; | ||||||
} | ||||||
public boolean isNotAnonymous(){ | ||||||
return id != NOT_EXIST_ID; | ||||||
} | ||||||
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 와 같은 맥락인 것 같아요! 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. 해당 값이 불필요할 거 같긴 하네요. |
||||||
|
||||||
public static AuthInfo getAnonymous(){ | ||||||
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.
Suggested change
|
||||||
return ANONYMOUS; | ||||||
} | ||||||
|
||||||
@Override | ||||||
public boolean equals(final Object o) { | ||||||
if (this == o) return true; | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import corea.auth.RequestHandler; | ||
import corea.auth.annotation.AccessedMember; | ||
import corea.auth.domain.AuthInfo; | ||
import corea.member.domain.Member; | ||
import corea.member.repository.MemberRepository; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
|
@@ -26,11 +27,11 @@ public boolean supportsParameter(MethodParameter parameter) { | |
} | ||
|
||
@Override | ||
public Member resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, | ||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { | ||
public AuthInfo resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, | ||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { | ||
HttpServletRequest request = (HttpServletRequest) webRequest.getNativeRequest(); | ||
|
||
return memberRepository.findByEmail(requestHandler.extract(request)) | ||
Member member = memberRepository.findByEmail(requestHandler.extract(request)) | ||
.orElse(null); | ||
return member == null ? AuthInfo.getAnonymous() : AuthInfo.from(member); | ||
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. 이후
기준으로 나누어봐도 좋을 것 같다는 뽀로로 의견 추가 작성해둡니다. |
||
} | ||
} |
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) | ||
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 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,25 @@ | ||
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> { | ||
|
||
@Override | ||
public String convertToDatabaseColumn(List<String> strings) { | ||
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. 배열을 문자열로, 문자열을 배열로 변환하는 부분인데 |
||
StringBuilder sb = new StringBuilder(); | ||
strings.forEach(s -> sb.append(s).append(", ")); | ||
sb.delete(sb.length() - 2, sb.length()); | ||
return sb.toString(); | ||
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. String.join 쓰세용~ |
||
} | ||
|
||
@Override | ||
public List<String> convertToEntityAttribute(String s) { | ||
return Arrays.stream(s.split(", ")) | ||
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. ", " -> 상수 처리 후 중복으로 사용 가능하니 상수로 ㄱ |
||
.toList(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,6 +6,7 @@ | |||||
import corea.room.domain.RoomStatus; | ||||||
|
||||||
import java.time.LocalDateTime; | ||||||
import java.util.List; | ||||||
|
||||||
public class RoomFixture { | ||||||
|
||||||
|
@@ -16,7 +17,7 @@ public static Room ROOM_DOMAIN(final Member member) { | |||||
4, | ||||||
"https://github.com/example/java-racingcar", | ||||||
"https://gongu.copyright.or.kr/gongu/wrt/cmmn/wrtFileImageView.do?wrtSn=13301655&filePath=L2Rpc2sxL25ld2RhdGEvMjAyMS8yMS9DTFMxMDAwNC8xMzMwMTY1NV9XUlRfMjFfQ0xTMTAwMDRfMjAyMTEyMTNfMQ==&thumbAt=Y&thumbSe=b_tbumb&wrtTy=10004", | ||||||
"TDD,클린코드,자바", | ||||||
List.of("TDD,클린코드,자바"), | ||||||
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.
Suggested change
|
||||||
17, | ||||||
30, | ||||||
member, | ||||||
|
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.
줄 공백 넣어주세요 🔪
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.
그리고 어차피
id
로 동등성 검사하니 this.equals(ANONYMOUS); 가 날듯.관리 포인트 증가.