-
Notifications
You must be signed in to change notification settings - Fork 0
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
[FEAT] 유저 차단 관련 기능 구현 #55
Conversation
/users/blocks -> /blocks
SelfBlockedException
@UserIdConstraint는 db에 존재하는 userId일 때와 userId=0일 때도 유효함 -> db에 존재하는 userId일 때만 유효함
userId=0일 때 로직 추가, db에 존재하는 userId인지 검사는 composition으로 userIdValidator를 사용
validator로 UserIdInclusiveZeroValidator를 사용
BlockGetResponse BlocksGetResponse
유효하지 않은 ID -> 400 유효하지만 해당하지 않은 ID -> 404
BlockIdConstraint, BlockIdValidator
INVALID_BLOCK_ID - 400 Bad Request
InvalidBlockIdException
제대로 된 blockId, 유저가 작성한 block인지 판단하도록
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.
어후 대단히 고생하셨네요 🥹👍
코멘트 확인 해주시면 승인하겠습니다!
src/main/java/org/websoso/WSSServer/exception/avatar/exception/AvatarNotFoundException.java
Outdated
Show resolved
Hide resolved
src/main/java/org/websoso/WSSServer/validation/BlockIdValidator.java
Outdated
Show resolved
Hide resolved
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.
코드 양이 엄청 많네요! 여러 예외사항을 꼼꼼하게 막아두신거 보고 많이 배워갑니다.. 수고하셨습니다~
src/main/java/org/websoso/WSSServer/validation/UserIdInclusiveZeroValidator.java
Outdated
Show resolved
Hide resolved
src/main/java/org/websoso/WSSServer/validation/UserIdInclusiveZeroConstraint.java
Outdated
Show resolved
Hide resolved
userId가 0을 허용한다는 의미 포함하여 리네임
유효한 값 검증만 하도록 변경
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.
수고하셨습니다~
Related Issue
Key Changes
UserIdValidator
UserIdValidator
는userId가 0
인 경우에도 valid함으로 판단했습니다. 공지사항에서 userId가 쓰이는데, 0인 경우 전체 유저 대상이기 때문입니다.InvalidUserIdException(400 Bad Request)
을 던집니다.UserNotFoundException(404 Not Found)
를 던집니다. -> 이 부분은 어떻게 validation하는지 좀 더 고민해보겠습니다.UserIdConstraint
의 validation을 위해 쓰입니다.UserIdInclusiveZeroValidator
UserIdValidator
를composition
하여 사용합니다.userId가 0
인 경우(= inclusiveZero할 때)에는 바로 valid함을 return하고, userId가 0이 아닌 경우에는UserIdValidator
에게 판단을위임
합니다. 따라서 userId가 0일 때는 valid, 0보다 작을 때는InvalidUserIdException(400 Bad Request)
을 던집니다.UserIdInclusiveZeroConstraint
의 validation을 위해 쓰입니다.BlockIdValidator
InvalidBlockIdException(400 Bad Request)
을 던지고, 조회 후 결과가 없을 때는BlockNotFoundException(404 Not Found)
를 던집니다.BlockIdConstraint
의 validation을 위해 쓰입니다.타 유저 차단 API
users/blocks
->blocks
정적 팩터리 메서드 패턴
을 사용해봤습니다. 코드가 훨씬 깔끔해진 것 같긴 한데, 의견 제시 부탁드립니다!! (ref1
: 이펙티브 자바 item01에 빌더 패턴과 정적 팩터리 메서드 패턴을 비교하는 주제가 있어서 제가 정리한 자료 레퍼런스에 달아두었습니다.)400 Bad Request
: 존재할 수 있는 userId가 아닐 경우(유효한 값이 아닌 경우 ex. 0, 음수), 자기 자신을 차단 시도한 경우401 Unauthorized
: 토큰 문제404 Not Found
: 존재할 수 있는 userId이지만, userId에 해당하는 유저가 없는 경우409 Conflict
: 이미 차단된 유저인 경우차단 목록 조회 API
users/blocks
->blocks
차단 삭제 API
users/blocks
->blocks
400 Bad Request
: 존재할 수 있는 blockId가 아닌 경우(유효한 값이 아닌 경우 ex. 0, 음수)401 Unauthorized
: 토큰 문제403 Forbidden
: 존재할 수 있는 blockId이지만, 해당 유저의 차단이 아닌 경우404 Not Found
: 존재할 수 있는 blockId지만, blockId에 해당하는 차단이 없는 경우To Reviewers
ref1
: https://wooki99.notion.site/Item-1-93f967817dcb45c9b986ba3e3fae5738?pvs=4