-
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
포인트 도메인 구현 #44
포인트 도메인 구현 #44
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
||
@EnableJpaAuditing | ||
@EnableAsync |
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.
P1) TaskExecutor를 설정하지 않았는데, default로 사용했을 때 발생하는 문제에 대해 찾아보면 좋을 것 같아요!
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.
지금 당장 해결해야할 문제는 아니라고 생각되어서, 클라이언트 api 연동 후 해결하려고 합니다 ! 이번 pr 후 해야할 일들을 위에 정리해뒀습니다 ~
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.
크리티컬한 문제라고 생각해요 다음 pr에 빠르게 반영됐으면 좋겠습니다~
@@ -39,6 +41,8 @@ | |||
@Component | |||
@RequiredArgsConstructor | |||
public class JwtValidationFilter extends OncePerRequestFilter { | |||
private final PointService pointService; |
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.
P2) Jwt 검증 필터에 서비스 레이어를 주입해서 사용하는 것이 좋은 방법일지 고민이 되네요
결합도가 높아지고 여러 개의 책임을 지는 것은 아닐까? 하는 생각입니다
presentation layer에 AOP를 적용하는 방법은 어떨까요?
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.
좋은 방법인 것 같아요 ~ 이번 pr 후 고려해서 수정해보겠습니다 ~
@@ -39,6 +41,8 @@ | |||
@Component | |||
@RequiredArgsConstructor | |||
public class JwtValidationFilter extends OncePerRequestFilter { | |||
private final PointService pointService; | |||
private final UserRepository userRepository; |
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.
P3) 사용하지 않는 DI인 것 같습니다
@@ -0,0 +1,4 @@ | |||
package com.coniverse.dangjang.domain.healthmetric.dto.request; | |||
|
|||
public record HealthConnectRegisterRequest(boolean healthConnectInterlock) { |
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.
P3) JavaDoc 필요!
pointService.addHealthConnectPoint(user); | ||
} | ||
} else if (!request.healthConnectInterlock() && user.getHealthConnect().equals(HealthConnect.CONNECTING)) { | ||
user.setHealthConnect(HealthConnect.DISCONNECTED); |
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.
한번도 연동한 적 없는 유저와, 연동이 이미 해제되어 있는 유저는 아무런 처리를 하지 않습니다. 연동되어 있는 유저일때만 연동을 해지합니다
* @since 1.0.0 | ||
*/ | ||
@GetMapping("/mypage") | ||
public ResponseEntity<SuccessSingleResponse<?>> getMyPage(@AuthenticationPrincipal User user) { |
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.
P4) response data 필드가 null이 아니면 제네릭에 와일드카드 대신 클래스명을 명시해주셨으면 좋겠습니당
@@ -59,10 +65,19 @@ public class User extends BaseEntity implements Persistable<String> { | |||
private boolean medicine; | |||
private boolean injection; | |||
private String profileImagePath; | |||
@Enumerated(EnumType.STRING) | |||
private HealthConnect healthConnect = HealthConnect.NEVER_CONNECTED; | |||
@Column(name = "ACCESSED_AT", nullable = false) |
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.
유저는 BaseEntity를 상속받아서 updatedAt 필드가 존재하는데 추가로 중복되는 필드를 작성하신 이유가 있을까요?
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.
updatedAt은 객체가 수정되었을 때만 기록되지만, accessedAt은 접속하였을 때만 업데이트합니다.
* | ||
* @since 1.0.0 | ||
*/ | ||
@Modifying(flushAutomatically = true, clearAutomatically = true) |
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.
포인트에서 서술한 내용과 동일
* @since 1.0.0 | ||
*/ | ||
@Service | ||
@AllArgsConstructor |
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.
P3) @requiredargsconstructor로 수정 부탁드려여
* @return User 사용자 | ||
* @since 1.0.0 | ||
*/ | ||
public Optional<User> findNickname(String nickname) { |
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.
P3) JavaDoc은 "존재하는" 닉네임인지 조회하여 "확인" 인데 조회만 하고 있어요
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
if (balancePoint >= 0) { | ||
return balancePoint; | ||
} else { | ||
throw new BusinessException(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.
P3) Exception 클래스를 구현해 주세요
} | ||
|
||
/** | ||
* 헬스커넥트 포인트 적립 |
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.
P3) JavaDoc 수정 필요!
Authentication auth = getAuthentication(token); | ||
SecurityContextHolder.getContext().setAuthentication(auth); | ||
} else if (jwtStatus.equals(JWTStatus.EXPIRED)) { | ||
request.setAttribute("exception", jwtStatus.getMessage()); | ||
} else if (jwtStatus.equals(JWTStatus.INVALID)) { |
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.
P3) elif 하나로 합쳐도 될 것같아요
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.
전체적으로 수정이 이루어지면서 JavaDoc과 불일치하는 메서드가 많아요 아마 IDE가 잡아줄텐데 같이 수정 부탁드려요
* @since 1.0.0 | ||
*/ | ||
@PostMapping | ||
public ResponseEntity<SuccessSingleResponse> usePoint(@Valid @RequestBody UsePointRequest request, |
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.
SuccessSingleResponse 제네릭 명시안하면 IDE가 잡아주지 않나요?
private PointId pointId; | ||
private String phone; | ||
@ColumnDefault("false") | ||
private boolean completed; |
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.
구매가 완료되었다는 의미의 필드인가요? 해당 필드 사용 이유가 궁금해여
*/ | ||
public PointProduct findPointProductById(String pointProduct) { | ||
return pointProductRepository.findById(pointProduct) | ||
.orElseThrow(() -> new BusinessException(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.
P3) Exception 클래스를 구현해 주세요
*/ | ||
public UserPoint findUserPointByOauthId(String oauthId) { | ||
return userPointRepository.findById(oauthId) | ||
.orElseThrow(() -> new BusinessException(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.
P3) Exception 클래스를 구현해 주세요
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.
새로운 예외를 구현하기 보다, 표준 예외를 재사용하는 방법으로 수정하겠습니다 ~
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor |
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.
위에서 서술한 내용과 동일
private User 유저; | ||
|
||
@Test | ||
void getMypage() { |
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.
P3) 테스트 설명으로 수정해주세요
Changes 📝
포인트 도메인 관련 기능 로직을 구현하였습니다.
Details 🌼
Check List ☑️
[Optional] Etc
*이번 PR 후 해야할 일
*Reference
https://tecoble.techcourse.co.kr/post/2023-08-16-concurrency-managing/?fbclid=IwAR3ily9yhZ0wurw1OVGTE9Xvv_fbmRCDl3LTPBf4A73P6U9JDiv7S6GxnUc_aem_Ab7UjAoeWUcSVfSVHL7zzpWs1R5qUoyWmbqGzKB_t04QYHuSjH6kIwsE6hETr40yD3A
자바 ORM 표준 JPA 프로그래밍 (낙관적 락 - 책)
스프링 DB 2편 - 데이터 접근 활용 기술(트랜잭션 - 인프런 강의)