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

M3-120 픽셀 차지하는 API 만들기 #10

Merged
merged 4 commits into from
Jun 28, 2024

Conversation

qjvk2880
Copy link
Contributor

작업 내용*

  • 픽셀 차지하는 api 구현 완료

고민한 내용*

  • 사용자로부터 pixelId, userId, communityId를 받아 PixelUser 엔티티로 Save한다.
  • 커뮤니티에 속해있지 않는 경우 요청 본문에서 communityId가 null이 온다.
  • 따라서 community 테이블에 기본키로 -1 값을 가지는 디폴트 커뮤니티를 넣어두고 그룹이 없는 유저의 경우에 대해 사용함

리뷰 요구사항

  • 리뷰할 때 중점적으로 봐줬으면 하는 내용들

스크린샷

Copy link

📝 테스트 커버리지 리포트

Overall Project 40.33% -10.38%
Files changed 0%

File Coverage
PixelController.java 30% -30%
PixelService.java 23.08% -48.72%

Copy link

github-actions bot commented Jun 26, 2024

Qodana for JVM

It 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
☁️ View the detailed Qodana report

Contact Qodana team

Contact 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); }}
Copy link
Member

Choose a reason for hiding this comment

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

또 ^M 이 들어왔네요 ㅎㅎ

Comment on lines 46 to 61
@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);
}
Copy link
Member

Choose a reason for hiding this comment

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

그룹 아이디와 유저 아이디와 픽셀 아이디가 존재하는 값인지 한번 확인하고 없으면 400을 반환해주는 로직이 있으면 좋을거같은데 어떻게 생각하시나요??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

추후 jwt를 통한 인증인가 구현시 토큰에 userID와 communityId를 넣으려했는데 그 때도 validation 하는게 좋을까요?

Copy link
Member

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))
Copy link
Member

Choose a reason for hiding this comment

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

getReferenceById 좋은거 배워갑니다~

Copy link

📝 테스트 커버리지 리포트

Overall Project 40.89% -10.28%
Files changed 8.33%

File Coverage
GeometryConfig.java 100% 🍏
PixelController.java 30% -30%
PixelService.java 23.08% -48.72%

Copy link

📝 테스트 커버리지 리포트

Overall Project 40.89% -10.28%
Files changed 8.33%

File Coverage
GeometryConfig.java 100% 🍏
PixelController.java 30% -30%
PixelService.java 23.08% -48.72%

Copy link

📝 테스트 커버리지 리포트

Overall Project 39.33% -15.51%
Files changed 5.48%

File Coverage
GeometryConfig.java 100% 🍏
PixelController.java 30% -30%
PixelService.java 20.69% -54.02%
ErrorCode.java 0% -44.44%

Copy link
Member

@koomin1227 koomin1227 left a comment

Choose a reason for hiding this comment

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

픽셀 유효성 검사도 잘 된 것 같습니다!

@qjvk2880 qjvk2880 merged commit ed28a70 into develop Jun 28, 2024
3 checks passed
@qjvk2880 qjvk2880 deleted the feature/M3-120-occupyPixel branch July 6, 2024 04:56
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.

3 participants