Skip to content
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

관심강좌에 강의 평점 추가 #253

Merged
merged 3 commits into from
Jul 28, 2024
Merged

Conversation

asp345
Copy link
Member

@asp345 asp345 commented Jul 24, 2024

GET /v1/bookmarks 에도 강의 검색처럼 강의 평점을 같이 내려달라고 하셔서 SnuttEvLectureSummaryDto를 강의마다 추가해서 보내도록 만들었습니다
#252 나중에 머지되면 db에 있는 정보로 보내주게 해도 괜찮을 거 같아요

@asp345 asp345 requested review from PFCJeong and a team as code owners July 24, 2024 14:40
@asp345 asp345 requested review from davin111 and Hank-Choi and removed request for a team July 24, 2024 14:40
import com.wafflestudio.snu4t.lectures.data.BookmarkLecture
import com.wafflestudio.snu4t.lectures.service.LectureService
import org.springframework.stereotype.Service

interface BookmarkService {
suspend fun getBookmark(userId: String, year: Int, semester: Semester): Bookmark
suspend fun getBookmark(userId: String, year: Int, semester: Semester): BookmarkResponse
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

엄청 꼭 지켜야하는 건 아닐 수 있는데, #70 (comment) 를 참고하면 response dto 로 변환하는 건 가급적 service 바깥에서 하자는 얘기가 있긴 했어. 이미 이걸 안 지키고 있는 것도 있긴 하지만 참고차.

?: Bookmark(userId = userId, year = year, semester = semester)
val snuttIdToEvLectureMap =
snuttEvRepository.getSummariesByIds(bookmark.lectures.map { it.id!! }).associateBy { it.snuttId }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요거 bookmark.lectures에 중복 있을 가능성이 있다면 set 으로 바꿔줘도 좋을 듯.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추가/삭제가 중복 없게 관리되고 있기도 하고 강의마다 id가 유일해서 set으로 변환 안해도 될거 같아요


// FIXME: 안드로이드 구버전 대응용 필드 1년 후 2024년에 삭제 (2023/06/26)
@JsonProperty("class_time_mask")
val classTimeMask: List<Int> = emptyList(),
)

fun BookmarkLectureDto(lecture: BookmarkLecture): BookmarkLectureDto = BookmarkLectureDto(
fun BookmarkLectureDto(lecture: BookmarkLecture, snuttEvLecture: SnuttEvLectureSummaryDto? = null): BookmarkLectureDto = BookmarkLectureDto(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snuttEvLecture가 null 인 건 어떤 경우지? 발생해도 상관 없는 건가?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LectureDto 로 변환할 때랑 비슷한데 snuttEvLecture가 null이 되는 경우는 ev에 보냈던 요청 자체가 실패하거나 해당 강의가 강의평 db에 없어서 map에 해당 강의의 id를 key로 갖는 항목이 없는 경우이고 그렇더라도 요청 자체는 처리되어야 해서 이렇게 만들었어요

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 글쿠만... 그래도 지속되면 좀 문제 있는 거라면, log.warn 같은 거라도 찍어둬도 좋을 거 같네여

@@ -9,8 +10,8 @@ class BookmarkResponse(
val lectures: List<BookmarkLectureDto>,
)

fun BookmarkResponse(bookmark: Bookmark): BookmarkResponse = BookmarkResponse(
fun BookmarkResponse(bookmark: Bookmark, snuttIdToEvLectureMap: Map<String, SnuttEvLectureSummaryDto> = mapOf()): BookmarkResponse = BookmarkResponse(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나는 요런 거, BookmarkLectureDto를 바깥에서 만들어서, BookmarkResponse의 생성자로 넘겨주는 게 더 좋다고 생각해.

@asp345 asp345 force-pushed the feature/bookmark-rating branch from 8d8c48b to 4ce52e4 Compare July 28, 2024 06:54
@asp345
Copy link
Member Author

asp345 commented Jul 28, 2024

리뷰해주신 내용 보고 List<BookmarkLecture>List<BookmarkLectureDto>로 변환하는 함수를 service 단에 추가하고 다시 BookmarkResponse 생성자에 넘겨주는 방식으로 바꿨어요

@asp345 asp345 merged commit 946d849 into develop Jul 28, 2024
2 checks passed
@davin111 davin111 deleted the feature/bookmark-rating branch July 28, 2024 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants