-
Notifications
You must be signed in to change notification settings - Fork 1
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
Recent_Played 테이블 생성 + API 수정 #290
Conversation
* 최근 재생 목록을 관리하는 recent_played entity 생성
* created_at 으로 이름 변경
* signup 에서 createRecentPlaylist 삭제
* 음악이 해당 유저의 최근 재생 목록에 있는지 확인하는 함수
* recent_played 테이블을 활용하는 방법으로 수정
* PATCH -> PUT * Recent_Played 테이블을 활용하도록 수정
* 불필요해진 모듈 관계 삭제
* 최근 재생 목록 관련 쿼리문 추가
* 최근 재생 목록 GET API 수정 * Recent_Played 테이블 활용
* recent 관련 API 모두 USER 모듈로 이동 * recent_played 테이블을 따로 만든 것을 고려
* GET /users/recent-info 구현 * 최근 재생 목록의 music_count, thumbnail 응답
* 최근 재생 목록의 노래를 받는 쿼리에서 음악의 아티스트 정보가 없는 이슈 발견 * 유저 정보 포함하도록 수정
* updateRecentMusic 에서 노래가 없는 경우 예외 처리
* 엔티티 추가에 대응
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.
아래 커멘트는 제가 잘 이해했는지 묻는 질문이랑 감탄사 밖에 없습니당 👍😊
형운님 코드는 볼때마다 섬세해서 감탄하는 것 같아요. 고생 진짜 엄청 많이 하셨어요 !!
}, | ||
{ | ||
provide: getRepositoryToken(Music_Playlist), | ||
provide: getRepositoryToken(Recent_Played), |
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.
여러 개의 모듈이 의존관계를 갖다가 Recent_Played만 딱 들어가니까 깔끔하고 좋은 것 같네요! 👍😊
@@ -88,4 +92,37 @@ export class UserController { | |||
this.logger.log(`GET /users/search - keyword=${keyword}`); | |||
return this.userService.getCertainKeywordNicknameUser(keyword); | |||
} | |||
|
|||
@Put('recent-played') |
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.
오 요 부분 put
으로 변경하신 이유가 있을까요?
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.
그 전에는 date 한 부분만 update 하기도 하고 멱등하지 않다고 생각해서 Patch 를 썼는데
바뀐 후에는 멱등해서 Put 으로 바꿨습니다!
if (!(await Music.getMusicById(music_id))) { | ||
this.logger.error( | ||
`user.service - updateRecentMusic : NOT_EXIST_MUSIC_ID`, | ||
); | ||
throw new CatchyException( | ||
'NOT_EXIST_MUSIC_ID', | ||
HTTP_STATUS_CODE.BAD_REQUEST, | ||
ERROR_CODE.NOT_EXIST_MUSIC_ID, | ||
); | ||
} |
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.
저는 뭔가 당연하게 생각해서 처리할 생각도 못했는 이런 에러까지 고려하신 것 엄청 세심하시네요 ! 👍😊
async getRecentPlaylistMusicCount(user_id: string): Promise<number> { | ||
try { | ||
return await this.recentPlayedRepository.count({ | ||
where: { user: { user_id } }, | ||
}); | ||
} catch { | ||
this.logger.error( | ||
`user.service - getRecentPlaylistMusicCount : QUERY_ERROR`, | ||
); | ||
throw new CatchyException( | ||
'QUERY_ERROR', | ||
HTTP_STATUS_CODE.SERVER_ERROR, | ||
ERROR_CODE.QUERY_ERROR, | ||
); | ||
} | ||
} |
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.
네네 맞습니다!
const userMusicData = await this.userService.getRecentPlayedMusicByUserId( | ||
userId, | ||
count, |
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.
오 이건 최근 재생목록 개수를 count로 따로 설정하게끔 하신거군요!
(제가 잘 이해했는지 묻는 단순 질문입니당) |
네네 정확합니다! |
Issue
Overview
/user/recent-played
PATCH
->PUT
GET
/user/recent-info
음악 수, 썸네일 링크 응답하는 API 구현Screenshot
GET
/users/recent-info
최근 재생 목록 정보 APIGET
/users/recent-played
최근 재생 목록 노래 정보 APIPUT
/users/recent-played
최근 재생 목록 노래 update