-
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
M3-120 픽셀 차지하는 API 만들기 #10
Conversation
📝 테스트 커버리지 리포트
|
Qodana for JVMIt seems all right 👌 No new problems were found according to the checks applied 💡 Qodana analysis was run in the pull request mode: only the changed files were checked Contact Qodana teamContact us at qodana-support@jetbrains.com
|
package com.m3pro.groundflip.domain.dto;import lombok.AllArgsConstructor;import lombok.Getter;import lombok.NoArgsConstructor;@Getter@NoArgsConstructor@AllArgsConstructorpublic class Response<T> { private static final String SUCCESS_RESULT = "success"; private static final String ERROR_RESULT = "error"; private String result; private String message; private T data; public static <T> Response<T> createSuccess(T data) { return new Response<>(SUCCESS_RESULT, null, data); } public static Response<?> createSuccessWithNoData() { return new Response<>(SUCCESS_RESULT, null, null); } public static Response<?> createSuccessWithMessage(String message) { return new Response<>(SUCCESS_RESULT, message, null); } public static Response<?> createError(String message) { return new Response<>(ERROR_RESULT, message, null); }} |
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.
또 ^M 이 들어왔네요 ㅎㅎ
@Transactional | ||
public void occupyPixel(PixelOccupyRequest pixelOccupyRequest) { | ||
Long communityId = pixelOccupyRequest.getCommunityId(); | ||
|
||
if (pixelOccupyRequest.getCommunityId() == null) { | ||
communityId = -1L; | ||
} | ||
|
||
PixelUser pixelUser = PixelUser.builder() | ||
.community(communityRepository.getReferenceById(communityId)) | ||
.pixel(pixelRepository.getReferenceById(pixelOccupyRequest.getPixelId())) | ||
.user(userRepository.getReferenceById(pixelOccupyRequest.getUserId())) | ||
.build(); | ||
|
||
pixelUserRepository.save(pixelUser); | ||
} |
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.
그룹 아이디와 유저 아이디와 픽셀 아이디가 존재하는 값인지 한번 확인하고 없으면 400을 반환해주는 로직이 있으면 좋을거같은데 어떻게 생각하시나요??
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.
추후 jwt를 통한 인증인가 구현시 토큰에 userID와 communityId를 넣으려했는데 그 때도 validation 하는게 좋을까요?
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.
음 그럼 userId와 communityId는 인증인가에서 검증하니 pixelId 정도는 저희 db 에 존재하는 값인지 확인하는 로직이 들어가면 좋지 않을까 생각됩니다.
혹시나 클라에서 저희가 설정해둔 범위를 벗어나서 요청을 하면 에러가 생길수도 있을거 같아서요..
아님 클라가 아니라 누군가 악의적인 요청을 보낼 수도 있지 않을까 예상됩니다..
} | ||
|
||
PixelUser pixelUser = PixelUser.builder() | ||
.community(communityRepository.getReferenceById(communityId)) |
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.
getReferenceById
좋은거 배워갑니다~
📝 테스트 커버리지 리포트
|
📝 테스트 커버리지 리포트
|
📝 테스트 커버리지 리포트
|
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.
픽셀 유효성 검사도 잘 된 것 같습니다!
작업 내용*
고민한 내용*
리뷰 요구사항
스크린샷