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

2주차 다운 #10

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open

2주차 다운 #10

wants to merge 35 commits into from

Conversation

momnpa333
Copy link
Collaborator

죄송합니다..

momnpa333 added 30 commits April 2, 2024 22:23
momnpa333 added 5 commits May 11, 2024 02:03
죄송합니다.. 담부터 커밋 잘할게요..
양방향 및 단방향 둘다 삭제 가능하게 구현
양방향 및 단방향 둘다 삭제 가능하게 구현
양방향 및 단방향 둘다 삭제 가능하게 구현
} catch (SecurityException | MalformedJwtException | ExpiredJwtException |
UnsupportedJwtException |
IllegalArgumentException e) {
throw e;
Copy link
Collaborator

Choose a reason for hiding this comment

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

throw error 하나로 추상화하는거 어떤가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Slf4j
@RequiredArgsConstructor
@PropertySource("classpath:application.yml")
public class OAuthService {
Copy link
Collaborator

Choose a reason for hiding this comment

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

이부분도 얘기해보면 좋을거같아요

this.expirationPeriod = expirationPeriod;
}

public static GifticonResponse from(final Gifticon gifticon){
Copy link
Collaborator

Choose a reason for hiding this comment

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

final 붙이는거 좋은거같아요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

감사합니다

/**
* 재고 증가
*/
public void addStock(Long quantity) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

0 방어로직 넣어보는거도 좋을거같아요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵 감사합니다

this.owner = owner;
}


Copy link
Collaborator

Choose a reason for hiding this comment

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

validCheck private메소드로 뺴는거도 좋을거같아요

throw new IllegalArgumentException("브랜드는 필수 입력 값입니다.");
}
if(gifticonUpdate.getDescription() != null && gifticonUpdate.getDescription().isBlank()){
throw new IllegalArgumentException("설명은 필수 입력 값입니다.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

jakerta에서 Validator있는데 이거 쓰는거도 고려해보세용

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵 감사합니다

*/
public PagingResponse<FundingArticleResponse> getFundingArticlePaging(
PagingRequest pagingRequest) {
return PagingResponse.from(fundingArticleJpaRepository.findAll(pagingRequest.toPageable()),
Copy link
Collaborator

Choose a reason for hiding this comment

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

리턴할때 메소드 한방에하는거보다 나눠서 쓰는거는 어떤가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

감사합니다

public void deleteGifticon(Long gifticonId){
//상품이 있는지 확인
Gifticon findGifticon = gifticonJpaRepository.findById(gifticonId).orElse(null);
if(findGifticon == null){
Copy link
Collaborator

Choose a reason for hiding this comment

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

orElseThrow 쓰면 좋을꺼 같네요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵!

Copy link
Collaborator

@fanta4715 fanta4715 left a comment

Choose a reason for hiding this comment

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

!

Comment on lines +16 to +33
public class UserGifticonService {
private final UserGifticonJpaRepository userGifticonJpaRepository;

/**
* 유저기프티콘 전체 조회
*/
public List<UserGifticon> findUserGifticonAll()
{
return userGifticonJpaRepository.findAll();
}

/**
* 유저기프티콘 상세 조회
*/
public UserGifticon findUserGifticon(Long userGifticonId)
{
return userGifticonJpaRepository.findById(userGifticonId).orElse(null);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

페이징 처리 해주세요!

Comment on lines +74 to +91
public void addStock(Long gifticonId, Long stock){
Gifticon findGifticon = gifticonJpaRepository.findById(gifticonId).orElse(null);
if(findGifticon == null){
throw new NotFoundGifticonException("해당 상품이 존재하지 않습니다.");
}
findGifticon.addStock(stock);
}

/**
* 재고 감소
*/
@Transactional
public void removeStock(Long gifticonId, Long stock){
Gifticon findGifticon = gifticonJpaRepository.findById(gifticonId).orElse(null);
if(findGifticon == null){
throw new NotFoundGifticonException("해당 상품이 존재하지 않습니다.");
}
findGifticon.removeStock(stock);
Copy link
Collaborator

Choose a reason for hiding this comment

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

재고에 동시성 이슈가 발생할 것 같습니다!

Comment on lines +54 to +56
List<Gifticon> gifticons = gifticonIds.stream()
.map(gifticonId -> gifticonJpaRepository.findById(gifticonId).orElseThrow())
.toList();
Copy link
Collaborator

Choose a reason for hiding this comment

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

JPA메소드에 findByIdIn 쓰면 한 번에 가져오기 편할 거 같아요
가져오고 나서, 리스트 사이즈가 pk리스트 사이즈랑 같은 지 판별하면 굿

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

감사합니다

Comment on lines +49 to +54
UserGifticon userGifticon = new UserGifticon();
userGifticon.buyer = gifticonPurchase.getBuyer();
userGifticon.owner = gifticonPurchase.getOwner();
userGifticon.gifticon = gifticonPurchase.getGifticon();
userGifticon.purchaseDate = gifticonPurchase.getPurchaseDate();
userGifticon.expirationDate = gifticonPurchase.getExpirationDate();
Copy link
Collaborator

Choose a reason for hiding this comment

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

이거 빌더패턴 사용하면 어떨까요

Copy link
Member

Choose a reason for hiding this comment

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

Filter는 configurage가 아닌데 여기 폴더에 있네요
저번주에 저가 지적받은 부분이라 남겨둡ㄴ디ㅏ

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

죄송합니다

.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.authorizeHttpRequests(authReq -> authReq
.requestMatchers(HttpMethod.OPTIONS).permitAll()
.requestMatchers("/", "/login", "/oauth2/**", "/refresh","/swagger-ui/**","/api-docs","/v3/api-docs/**").permitAll()
Copy link
Member

Choose a reason for hiding this comment

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

위에 WHITELIST 정의하셨는데 url 목록을 이걸로 대체할 수 있을꺼 같아요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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.

4 participants