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

Develop #36

Merged
merged 5 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ public ApproveResponse payApprove(String pgToken) {
.orElse(null);

if (storeTeam != null) {
storeTeam.updatePoint(teamChargeHistory.getPaymentAmount());
storeTeam.addPoint(teamChargeHistory.getPaymentAmount());
storeTeam.addRemainPoint(teamChargeHistory.getPaymentAmount());
} else {
storeTeamRepository.save(
StoreTeam.create(teamChargeHistory.getTeam(), store, teamChargeHistory.getPaymentAmount()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.jangburich.domain.payment.domain;

import com.querydsl.core.annotations.QueryProjection;

import lombok.Builder;

@Builder
public record TeamChargeHistoryResponse(
Long id,
String transactionId,
Integer paymentAmount,
PaymentChargeStatus paymentChargeStatus
) {
@QueryProjection
public TeamChargeHistoryResponse(Long id, String transactionId, Integer paymentAmount,
PaymentChargeStatus paymentChargeStatus) {
this.id = id;
this.transactionId = transactionId;
this.paymentAmount = paymentAmount;
this.paymentChargeStatus = paymentChargeStatus;
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package com.jangburich.domain.payment.domain.repository;

import com.jangburich.domain.payment.domain.TeamChargeHistory;
import com.jangburich.domain.payment.domain.TeamChargeHistoryResponse;
import com.jangburich.domain.team.domain.Team;

import java.util.Optional;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface TeamChargeHistoryRepository extends JpaRepository<TeamChargeHistory, Long> {
Optional<TeamChargeHistory> findByTransactionId(String tid);

Page<TeamChargeHistoryResponse> findAllByTeam(Team team, Pageable pageable);
}
14 changes: 13 additions & 1 deletion src/main/java/com/jangburich/domain/store/domain/StoreTeam.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,27 @@ public class StoreTeam extends BaseEntity {
@Column(name = "point")
private Integer point;

public void updatePoint(Integer point) {
@Column(name = "remain_point")
private Integer remainPoint;

public void addPoint(Integer point) {
this.point += point;
Comment on lines +43 to 44
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

포인트 증가 λ©”μ„œλ“œμ— μœ νš¨μ„± 검사가 ν•„μš”ν•©λ‹ˆλ‹€.

음수 값이 μž…λ ₯λ˜λŠ” 것을 λ°©μ§€ν•˜κΈ° μœ„ν•΄ 포인트 κ°’ 검증을 μΆ”κ°€ν•΄ μ£Όμ„Έμš”.

 public void addPoint(Integer point) {
+    if (point < 0) {
+        throw new IllegalArgumentException("ν¬μΈνŠΈλŠ” 음수일 수 μ—†μŠ΅λ‹ˆλ‹€: " + point);
+    }
     this.point += point;
 }
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public void addPoint(Integer point) {
this.point += point;
public void addPoint(Integer point) {
if (point < 0) {
throw new IllegalArgumentException("ν¬μΈνŠΈλŠ” 음수일 수 μ—†μŠ΅λ‹ˆλ‹€: " + point);
}
this.point += point;

}

public void addRemainPoint(Integer point) {
this.remainPoint += point;
}
Comment on lines +47 to +49
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

remainPoint 증가 λ©”μ„œλ“œμ—λ„ μœ νš¨μ„± 검사가 ν•„μš”ν•©λ‹ˆλ‹€.

addRemainPoint λ©”μ„œλ“œμ—λ„ λ™μΌν•œ 음수 κ°’ 검증이 ν•„μš”ν•©λ‹ˆλ‹€.

 public void addRemainPoint(Integer point) {
+    if (point < 0) {
+        throw new IllegalArgumentException("ν¬μΈνŠΈλŠ” 음수일 수 μ—†μŠ΅λ‹ˆλ‹€: " + point);
+    }
     this.remainPoint += point;
 }
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public void addRemainPoint(Integer point) {
this.remainPoint += point;
}
public void addRemainPoint(Integer point) {
if (point < 0) {
throw new IllegalArgumentException("ν¬μΈνŠΈλŠ” 음수일 수 μ—†μŠ΅λ‹ˆλ‹€: " + point);
}
this.remainPoint += point;
}


public void subRemainPoint(Integer point) {
this.remainPoint -= point;
}
Comment on lines +51 to +53
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

μž”μ—¬ ν¬μΈνŠΈκ°€ μŒμˆ˜κ°€ λ˜μ§€ μ•Šλ„λ‘ 검증이 ν•„μš”ν•©λ‹ˆλ‹€.

subRemainPoint λ©”μ„œλ“œμ—μ„œ 차감 ν›„ μž”μ—¬ ν¬μΈνŠΈκ°€ 0보닀 μž‘μ•„μ§€μ§€ μ•Šλ„λ‘ 검증 λ‘œμ§μ„ μΆ”κ°€ν•΄μ•Ό ν•©λ‹ˆλ‹€.

 public void subRemainPoint(Integer point) {
+    if (this.remainPoint < point) {
+        throw new IllegalArgumentException("μž”μ—¬ ν¬μΈνŠΈκ°€ λΆ€μ‘±ν•©λ‹ˆλ‹€. ν˜„μž¬ μž”μ—¬ 포인트: " + this.remainPoint + ", 차감 μš”μ²­ 포인트: " + point);
+    }
     this.remainPoint -= point;
 }
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public void subRemainPoint(Integer point) {
this.remainPoint -= point;
}
public void subRemainPoint(Integer point) {
if (this.remainPoint < point) {
throw new IllegalArgumentException("μž”μ—¬ ν¬μΈνŠΈκ°€ λΆ€μ‘±ν•©λ‹ˆλ‹€. ν˜„μž¬ μž”μ—¬ 포인트: " + this.remainPoint + ", 차감 μš”μ²­ 포인트: " + point);
}
this.remainPoint -= point;
}


public static StoreTeam create(Team team, Store store, Integer point) {
StoreTeam storeTeam = new StoreTeam();
storeTeam.setTeam(team);
storeTeam.setStore(store);
storeTeam.setPoint(point);
storeTeam.setRemainPoint(point);
return storeTeam;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.jangburich.domain.store.domain;

import com.jangburich.domain.team.domain.Team;
import com.querydsl.core.annotations.QueryProjection;

import lombok.Builder;

@Builder
public record StoreTeamResponseDTO(
Long id,
Integer point,
Long teamId,
String teamName,
Long storeId

Comment on lines +9 to +15
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

ν•„λ“œ νƒ€μž…κ³Ό μœ νš¨μ„± 검증을 κ°œμ„ ν•΄μ£Όμ„Έμš”.

  1. Long νƒ€μž…μ˜ ID ν•„λ“œλ“€μ€ null이 될 수 μžˆμœΌλ―€λ‘œ μœ νš¨μ„± 검증이 ν•„μš”ν•©λ‹ˆλ‹€.
  2. point ν•„λ“œλŠ” κΈˆμ•‘μ„ λ‹€λ£¨λŠ” κ²ƒμœΌλ‘œ λ³΄μ΄λŠ”λ°, Integer λŒ€μ‹  BigDecimalμ΄λ‚˜ Money νƒ€μž… μ‚¬μš©μ„ κ³ λ €ν•΄λ³΄μ„Έμš”.
  3. ν•„λ“œμ— λŒ€ν•œ μ„€λͺ… 주석이 μ—†μ–΄ 각 ν•„λ“œμ˜ μš©λ„λ₯Ό νŒŒμ•…ν•˜κΈ° μ–΄λ ΅μŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 κ°œμ„ ν•΄λ³΄μ„Έμš”:

+import jakarta.validation.constraints.NotNull;
+import java.math.BigDecimal;

 @Builder
 public record StoreTeamResponseDTO(
+    @NotNull(message = "idλŠ” ν•„μˆ˜μž…λ‹ˆλ‹€")
     Long id,
-    Integer point,
+    BigDecimal point,
+    @NotNull(message = "teamIdλŠ” ν•„μˆ˜μž…λ‹ˆλ‹€")
     Long teamId,
+    @NotNull(message = "teamName은 ν•„μˆ˜μž…λ‹ˆλ‹€")
     String teamName,
+    @NotNull(message = "storeIdλŠ” ν•„μˆ˜μž…λ‹ˆλ‹€")
     Long storeId
 )
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public record StoreTeamResponseDTO(
Long id,
Integer point,
Long teamId,
String teamName,
Long storeId
import jakarta.validation.constraints.NotNull;
import java.math.BigDecimal;
public record StoreTeamResponseDTO(
@NotNull(message = "idλŠ” ν•„μˆ˜μž…λ‹ˆλ‹€")
Long id,
BigDecimal point,
@NotNull(message = "teamIdλŠ” ν•„μˆ˜μž…λ‹ˆλ‹€")
Long teamId,
@NotNull(message = "teamName은 ν•„μˆ˜μž…λ‹ˆλ‹€")
String teamName,
@NotNull(message = "storeIdλŠ” ν•„μˆ˜μž…λ‹ˆλ‹€")
Long storeId

) {
@QueryProjection
public StoreTeamResponseDTO(Long id, Integer point, Long teamId, String teamName, Long storeId) {
this.id = id;
this.point = point;
this.teamId = teamId;
this.teamName = teamName;
this.storeId = storeId;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package com.jangburich.domain.store.domain.controller;

import com.jangburich.domain.store.domain.Category;
import com.jangburich.domain.store.domain.dto.condition.StoreSearchCondition;
import com.jangburich.domain.store.domain.dto.condition.StoreSearchConditionWithType;
import com.jangburich.domain.store.domain.dto.response.SearchStoresResponse;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.security.core.Authentication;
Expand All @@ -18,13 +14,20 @@
import org.springframework.web.bind.annotation.RestController;

import com.jangburich.domain.oauth.domain.CustomOAuthUser;
import com.jangburich.domain.store.domain.Category;
import com.jangburich.domain.store.domain.StoreAdditionalInfoCreateRequestDTO;
import com.jangburich.domain.store.domain.StoreCreateRequestDTO;
import com.jangburich.domain.store.domain.StoreGetResponseDTO;
import com.jangburich.domain.store.domain.StoreTeamResponseDTO;
import com.jangburich.domain.store.domain.StoreUpdateRequestDTO;
import com.jangburich.domain.store.domain.dto.condition.StoreSearchCondition;
import com.jangburich.domain.store.domain.dto.condition.StoreSearchConditionWithType;
import com.jangburich.domain.store.domain.dto.response.PaymentGroupDetailResponse;
import com.jangburich.domain.store.domain.dto.response.SearchStoresResponse;
import com.jangburich.domain.store.domain.service.StoreService;
import com.jangburich.global.payload.Message;
import com.jangburich.global.payload.ResponseCustom;
import com.jangburich.utils.parser.AuthenticationParser;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand All @@ -41,57 +44,53 @@ public class StoreController {
@Operation(summary = "μΉ΄ν…Œκ³ λ¦¬ 별 κ°€κ²Œ λͺ©λ‘ 쑰회", description = "μΉ΄ν…Œκ³ λ¦¬ λ³„λ‘œ κ°€κ²Œ λͺ©λ‘μ„ μ‘°νšŒν•©λ‹ˆλ‹€.")
@GetMapping
public ResponseCustom<Page<SearchStoresResponse>> searchByCategory(
Authentication authentication,
@RequestParam(required = false, defaultValue = "3") Integer searchRadius,
@RequestParam(required = false, defaultValue = "ALL") Category category,
@ModelAttribute StoreSearchCondition storeSearchCondition,
Pageable pageable
Authentication authentication,
@RequestParam(required = false, defaultValue = "3") Integer searchRadius,
@RequestParam(required = false, defaultValue = "ALL") Category category,
@ModelAttribute StoreSearchCondition storeSearchCondition,
Pageable pageable
) {
return ResponseCustom.OK(storeService.searchByCategory(authentication, searchRadius, category, storeSearchCondition, pageable));
return ResponseCustom.OK(
storeService.searchByCategory(authentication, searchRadius, category, storeSearchCondition, pageable));
}

@Operation(summary = "맀μž₯ μ°ΎκΈ°(검색)", description = "검색어와 맀μž₯ μœ ν˜•μ— λ§žλŠ” 맀μž₯을 κ²€μƒ‰ν•©λ‹ˆλ‹€.")
@GetMapping("/search")
public ResponseCustom<Page<SearchStoresResponse>> searchStores(
Authentication authentication,
@RequestParam(required = false, defaultValue = "") String keyword,
@ModelAttribute StoreSearchConditionWithType storeSearchConditionWithType,
Pageable pageable
Authentication authentication,
@RequestParam(required = false, defaultValue = "") String keyword,
@ModelAttribute StoreSearchConditionWithType storeSearchConditionWithType,
Pageable pageable
) {
return ResponseCustom.OK(storeService.searchStores(authentication, keyword, storeSearchConditionWithType, pageable));
return ResponseCustom.OK(
storeService.searchStores(authentication, keyword, storeSearchConditionWithType, pageable));
Comment on lines +47 to +66
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

인증 처리 둜직 κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

검색 μ—”λ“œν¬μΈνŠΈλ“€μ˜ 인증 μ²˜λ¦¬κ°€ 일관성이 μ—†μŠ΅λ‹ˆλ‹€. AuthenticationParserλ₯Ό μ‚¬μš©ν•˜μ—¬ 인증 처리λ₯Ό ν†΅μΌν•˜λŠ” 것이 μ’‹κ² μŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •μ„ μ œμ•ˆλ“œλ¦½λ‹ˆλ‹€:

 public ResponseCustom<Page<SearchStoresResponse>> searchByCategory(
   Authentication authentication,
   @RequestParam(required = false, defaultValue = "3") Integer searchRadius,
   @RequestParam(required = false, defaultValue = "ALL") Category category,
   @ModelAttribute StoreSearchCondition storeSearchCondition,
   Pageable pageable
 ) {
   return ResponseCustom.OK(
-    storeService.searchByCategory(authentication, searchRadius, category, storeSearchCondition, pageable));
+    storeService.searchByCategory(AuthenticationParser.parseUserId(authentication), searchRadius, category, storeSearchCondition, pageable));
 }

Committable suggestion skipped: line range outside the PR's diff.

}

@Operation(summary = "κ°€κ²Œ 등둝", description = "μ‹ κ·œ νŒŒνŠΈλ„ˆ κ°€κ²Œλ₯Ό λ“±λ‘ν•©λ‹ˆλ‹€.")
@PostMapping("/create")
public ResponseCustom<Message> createStore(Authentication authentication,
@RequestBody StoreCreateRequestDTO storeCreateRequestDTO) {
CustomOAuthUser customOAuth2User = (CustomOAuthUser)authentication.getPrincipal();
storeService.CreateStore(customOAuth2User, storeCreateRequestDTO);
return ResponseCustom.OK(Message.builder()
.message("success")
.build());
storeService.createStore(customOAuth2User, storeCreateRequestDTO);
return ResponseCustom.OK(Message.builder().message("success").build());
}

@Operation(summary = "κ°€κ²Œ 좔가정보 μ €μž₯", description = "μ˜ˆμ•½ κ°€λŠ₯ μ—¬λΆ€, μ΅œμ†Œ μ„ κ²°μ œ κΈˆμ•‘, μ„ κ²°μ œ μ‚¬μš© 기간을 μ €μž₯ν•©λ‹ˆλ‹€.")
@PostMapping("/create/additionalInfo")
public ResponseCustom<Message> createAdditionalInfo(Authentication authentication, @RequestBody
StoreAdditionalInfoCreateRequestDTO storeAdditionalInfoCreateRequestDTO) {
public ResponseCustom<Message> createAdditionalInfo(Authentication authentication,
@RequestBody StoreAdditionalInfoCreateRequestDTO storeAdditionalInfoCreateRequestDTO) {
CustomOAuthUser customOAuthUser = (CustomOAuthUser)authentication.getPrincipal();
storeService.CreateAdditionalInfo(customOAuthUser, storeAdditionalInfoCreateRequestDTO);
return ResponseCustom.OK(Message.builder()
.message("success")
.build());
storeService.createAdditionalInfo(customOAuthUser, storeAdditionalInfoCreateRequestDTO);
return ResponseCustom.OK(Message.builder().message("success").build());
}

@Operation(summary = "κ°€κ²Œ 정보 μˆ˜μ •", description = "κ°€κ²Œ 정보λ₯Ό μˆ˜μ •ν•©λ‹ˆλ‹€.")
@PatchMapping("/{storeId}/update")
public ResponseCustom<Message> updateStore(Authentication authentication, @PathVariable Long storeId, @RequestBody
StoreUpdateRequestDTO storeUpdateRequestDTO) {
public ResponseCustom<Message> updateStore(Authentication authentication, @PathVariable Long storeId,
@RequestBody StoreUpdateRequestDTO storeUpdateRequestDTO) {
CustomOAuthUser principal = (CustomOAuthUser)authentication.getPrincipal();
storeService.updateStore(principal, storeId, storeUpdateRequestDTO);
return ResponseCustom.OK(Message.builder()
.message("success")
.build());
return ResponseCustom.OK(Message.builder().message("success").build());
Comment on lines +74 to +93
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

인증 처리 λ°©μ‹μ˜ 톡일화가 ν•„μš”ν•©λ‹ˆλ‹€.

μŠ€ν† μ–΄ 관리 μ—”λ“œν¬μΈνŠΈλ“€μ—μ„œ CustomOAuthUser μΊμŠ€νŒ… 방식이 반볡되고 μžˆμŠ΅λ‹ˆλ‹€. AuthenticationParserλ₯Ό ν™œμš©ν•˜μ—¬ μ½”λ“œ 쀑볡을 μ œκ±°ν•˜κ³  μΌκ΄€λœ λ°©μ‹μœΌλ‘œ μ²˜λ¦¬ν•˜λŠ” 것이 μ’‹κ² μŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •μ„ μ œμ•ˆλ“œλ¦½λ‹ˆλ‹€:

 public ResponseCustom<Message> createStore(Authentication authentication,
   @RequestBody StoreCreateRequestDTO storeCreateRequestDTO) {
-  CustomOAuthUser customOAuth2User = (CustomOAuthUser)authentication.getPrincipal();
-  storeService.createStore(customOAuth2User, storeCreateRequestDTO);
+  storeService.createStore(AuthenticationParser.parseUserId(authentication), storeCreateRequestDTO);
   return ResponseCustom.OK(Message.builder().message("success").build());
 }

Committable suggestion skipped: line range outside the PR's diff.

}

@Operation(summary = "κ°€κ²Œ 정보 쑰회", description = "κ°€κ²Œ 상세 정보λ₯Ό μ‘°νšŒν•©λ‹ˆλ‹€.")
Expand All @@ -100,4 +99,21 @@ public ResponseCustom<StoreGetResponseDTO> getStoreInfo(Authentication authentic
CustomOAuthUser customOAuth2User = (CustomOAuthUser)authentication.getPrincipal();
return ResponseCustom.OK(storeService.getStoreInfo(customOAuth2User));
}

@Operation(summary = "결제 κ·Έλ£Ή 쑰회", description = "μž₯λΆ€ 결제 그룹을 μ‘°νšŒν•©λ‹ˆλ‹€.")
@GetMapping("/payment_group")
public ResponseCustom<Page<StoreTeamResponseDTO>> getPaymentGroup(Authentication authentication,
Pageable pageable) {
return ResponseCustom.OK(
storeService.getPaymentGroup(AuthenticationParser.parseUserId(authentication), pageable));
}

@Operation(summary = "결제 κ·Έλ£Ή 상세 쑰회", description = "μž₯λΆ€ 결제 그룹을 상세 μ‘°νšŒν•©λ‹ˆλ‹€.")
@GetMapping("/payment_group/{teamId}")
public ResponseCustom<PaymentGroupDetailResponse> getPaymentGroupDetail(Authentication authentication,
@PathVariable Long teamId,
Pageable pageable) {
return ResponseCustom.OK(
storeService.getPaymentGroupDetail(AuthenticationParser.parseUserId(authentication), teamId, pageable));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.jangburich.domain.store.domain.dto.response;

import org.springframework.data.domain.Page;

import com.jangburich.domain.payment.domain.TeamChargeHistoryResponse;
import com.jangburich.domain.user.domain.User;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@RequiredArgsConstructor
Comment on lines +12 to +14
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

DTO의 λΆˆλ³€μ„± κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€

응닡 DTOλŠ” λΆˆλ³€ 객체둜 μ„€κ³„ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€. ν˜„μž¬ κ΅¬μ‘°μ—μ„œλŠ” μ™ΈλΆ€μ—μ„œ setterλ₯Ό 톡해 값을 λ³€κ²½ν•  수 μžˆμ–΄ μ•ˆμ „ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•˜λŠ” 것을 μΆ”μ²œλ“œλ¦½λ‹ˆλ‹€:

 @Getter
-@Setter
-@RequiredArgsConstructor
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Getter
@Setter
@RequiredArgsConstructor
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@RequiredArgsConstructor

public class PaymentGroupDetailResponse {
private String teamName;
private Integer point;
private Integer remainPoint;
private String teamLeaderName;
private String teamLeaderPhoneNum;
private Page<TeamChargeHistoryResponse> historyResponses;
Comment on lines +16 to +21
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

ν•„λ“œ μœ νš¨μ„± 검증이 ν•„μš”ν•©λ‹ˆλ‹€

포인트 κ°’κ³Ό ν•„μˆ˜ ν•„λ“œμ— λŒ€ν•œ μœ νš¨μ„± 검증이 μ—†μŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 검증 μ–΄λ…Έν…Œμ΄μ…˜μ„ μΆ”κ°€ν•˜λŠ” 것을 μΆ”μ²œλ“œλ¦½λ‹ˆλ‹€:

+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.PositiveOrZero;

 public class PaymentGroupDetailResponse {
-    private String teamName;
-    private Integer point;
-    private Integer remainPoint;
-    private String teamLeaderName;
-    private String teamLeaderPhoneNum;
+    @NotBlank(message = "νŒ€ 이름은 ν•„μˆ˜μž…λ‹ˆλ‹€")
+    private final String teamName;
+    @NotNull(message = "ν¬μΈνŠΈλŠ” ν•„μˆ˜μž…λ‹ˆλ‹€")
+    @PositiveOrZero(message = "ν¬μΈνŠΈλŠ” 0 이상이어야 ν•©λ‹ˆλ‹€")
+    private final Integer point;
+    @NotNull(message = "μž”μ—¬ ν¬μΈνŠΈλŠ” ν•„μˆ˜μž…λ‹ˆλ‹€")
+    @PositiveOrZero(message = "μž”μ—¬ ν¬μΈνŠΈλŠ” 0 이상이어야 ν•©λ‹ˆλ‹€")
+    private final Integer remainPoint;
+    @NotBlank(message = "νŒ€μž₯ 이름은 ν•„μˆ˜μž…λ‹ˆλ‹€")
+    private final String teamLeaderName;
+    @NotBlank(message = "νŒ€μž₯ μ „ν™”λ²ˆν˜ΈλŠ” ν•„μˆ˜μž…λ‹ˆλ‹€")
+    private final String teamLeaderPhoneNum;
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private String teamName;
private Integer point;
private Integer remainPoint;
private String teamLeaderName;
private String teamLeaderPhoneNum;
private Page<TeamChargeHistoryResponse> historyResponses;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.PositiveOrZero;
public class PaymentGroupDetailResponse {
@NotBlank(message = "νŒ€ 이름은 ν•„μˆ˜μž…λ‹ˆλ‹€")
private final String teamName;
@NotNull(message = "ν¬μΈνŠΈλŠ” ν•„μˆ˜μž…λ‹ˆλ‹€")
@PositiveOrZero(message = "ν¬μΈνŠΈλŠ” 0 이상이어야 ν•©λ‹ˆλ‹€")
private final Integer point;
@NotNull(message = "μž”μ—¬ ν¬μΈνŠΈλŠ” ν•„μˆ˜μž…λ‹ˆλ‹€")
@PositiveOrZero(message = "μž”μ—¬ ν¬μΈνŠΈλŠ” 0 이상이어야 ν•©λ‹ˆλ‹€")
private final Integer remainPoint;
@NotBlank(message = "νŒ€μž₯ 이름은 ν•„μˆ˜μž…λ‹ˆλ‹€")
private final String teamLeaderName;
@NotBlank(message = "νŒ€μž₯ μ „ν™”λ²ˆν˜ΈλŠ” ν•„μˆ˜μž…λ‹ˆλ‹€")
private final String teamLeaderPhoneNum;
private Page<TeamChargeHistoryResponse> historyResponses;


public static PaymentGroupDetailResponse create(String teamName, Integer point, Integer remainPoint,
User teamLeader, Page<TeamChargeHistoryResponse> historyResponses) {
PaymentGroupDetailResponse paymentGroupDetailResponse = new PaymentGroupDetailResponse();
paymentGroupDetailResponse.setTeamName(teamName);
paymentGroupDetailResponse.setPoint(point);
paymentGroupDetailResponse.setRemainPoint(remainPoint);
paymentGroupDetailResponse.setTeamLeaderName(teamLeader.getNickname());
paymentGroupDetailResponse.setTeamLeaderPhoneNum(teamLeader.getPhoneNumber());
paymentGroupDetailResponse.setHistoryResponses(historyResponses);
return paymentGroupDetailResponse;
}
Comment on lines +23 to +33
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

νŒ©ν† λ¦¬ λ©”μ„œλ“œμ˜ μ•ˆμ „μ„± κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€

μž…λ ₯ νŒŒλΌλ―Έν„°μ— λŒ€ν•œ μœ νš¨μ„± 검증이 μ—†μœΌλ©°, User 객체가 null일 경우 NullPointerException이 λ°œμƒν•  수 μžˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•˜λŠ” 것을 μΆ”μ²œλ“œλ¦½λ‹ˆλ‹€:

 public static PaymentGroupDetailResponse create(String teamName, Integer point, Integer remainPoint,
     User teamLeader, Page<TeamChargeHistoryResponse> historyResponses) {
+    Objects.requireNonNull(teamLeader, "νŒ€μž₯ μ •λ³΄λŠ” ν•„μˆ˜μž…λ‹ˆλ‹€");
+    Objects.requireNonNull(historyResponses, "νžˆμŠ€ν† λ¦¬ μ •λ³΄λŠ” ν•„μˆ˜μž…λ‹ˆλ‹€");
+    
+    if (teamName == null || teamName.trim().isEmpty()) {
+        throw new IllegalArgumentException("νŒ€ 이름은 ν•„μˆ˜μž…λ‹ˆλ‹€");
+    }
+    if (point == null || point < 0) {
+        throw new IllegalArgumentException("μœ νš¨ν•˜μ§€ μ•Šμ€ ν¬μΈνŠΈμž…λ‹ˆλ‹€");
+    }
+    if (remainPoint == null || remainPoint < 0) {
+        throw new IllegalArgumentException("μœ νš¨ν•˜μ§€ μ•Šμ€ μž”μ—¬ ν¬μΈνŠΈμž…λ‹ˆλ‹€");
+    }

-    PaymentGroupDetailResponse paymentGroupDetailResponse = new PaymentGroupDetailResponse();
-    paymentGroupDetailResponse.setTeamName(teamName);
-    paymentGroupDetailResponse.setPoint(point);
-    paymentGroupDetailResponse.setRemainPoint(remainPoint);
-    paymentGroupDetailResponse.setTeamLeaderName(teamLeader.getNickname());
-    paymentGroupDetailResponse.setTeamLeaderPhoneNum(teamLeader.getPhoneNumber());
-    paymentGroupDetailResponse.setHistoryResponses(historyResponses);
-    return paymentGroupDetailResponse;
+    return new PaymentGroupDetailResponse(
+        teamName,
+        point,
+        remainPoint,
+        teamLeader.getNickname(),
+        teamLeader.getPhoneNumber(),
+        historyResponses
+    );
 }

Committable suggestion skipped: line range outside the PR's diff.

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

import java.util.Optional;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import com.jangburich.domain.store.domain.Store;
import com.jangburich.domain.store.domain.StoreTeam;
import com.jangburich.domain.store.domain.StoreTeamResponseDTO;

public interface StoreTeamRepository extends JpaRepository<StoreTeam, Long> {
Optional<StoreTeam> findByStoreIdAndTeamId(Long store_id, Long team_id);

Page<StoreTeamResponseDTO> findAllByStore(Store store, Pageable pageable);
Copy link

Choose a reason for hiding this comment

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

πŸ’‘ Codebase verification

DTO 맀핑 κ΅¬ν˜„μ΄ λˆ„λ½λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

StoreTeamRepositoryμ—μ„œ Page<StoreTeamResponseDTO>λ₯Ό λ°˜ν™˜ν•˜λŠ” λ©”μ„œλ“œκ°€ μ„ μ–Έλ˜μ–΄ μžˆμ§€λ§Œ, μ‹€μ œ 맀핑 κ΅¬ν˜„μ΄ ν™•μΈλ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. λ‹€μŒ μž‘μ—…μ΄ ν•„μš”ν•©λ‹ˆλ‹€:

  • StoreTeamRepositoryImpl 클래슀λ₯Ό μƒμ„±ν•˜μ—¬ QueryDSL λ˜λŠ” JPQL을 μ‚¬μš©ν•œ 맀핑 κ΅¬ν˜„μ΄ ν•„μš”ν•©λ‹ˆλ‹€.
  • λ˜λŠ” @Query μ–΄λ…Έν…Œμ΄μ…˜μ„ μ‚¬μš©ν•˜μ—¬ μΈν„°νŽ˜μ΄μŠ€μ— 직접 맀핑 쿼리λ₯Ό μž‘μ„±ν•΄μ•Ό ν•©λ‹ˆλ‹€.

맀핑 μ‹œ λ‹€μŒ ν•„λ“œλ“€μ΄ μ˜¬λ°”λ₯΄κ²Œ λ³€ν™˜λ˜μ–΄μ•Ό ν•©λ‹ˆλ‹€:

  • StoreTeam의 id β†’ StoreTeamResponseDTO의 id
  • StoreTeam의 point β†’ StoreTeamResponseDTO의 point
  • Team의 id β†’ StoreTeamResponseDTO의 teamId
  • Team의 name β†’ StoreTeamResponseDTO의 teamName
  • Store의 id β†’ StoreTeamResponseDTO의 storeId
πŸ”— Analysis chain

DTO λ³€ν™˜ κ΅¬ν˜„ 확인이 ν•„μš”ν•©λ‹ˆλ‹€.

StoreTeamResponseDTO둜의 μžλ™ 맀핑이 μ œλŒ€λ‘œ λ™μž‘ν•˜λŠ”μ§€ 확인이 ν•„μš”ν•©λ‹ˆλ‹€.

λ‹€μŒ 슀크립트둜 DTO 맀핑 κ΅¬ν˜„μ„ ν™•μΈν•΄λ³΄κ² μŠ΅λ‹ˆλ‹€:


Let me gather more information about the DTO mapping implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: DTO 맀핑 κ΅¬ν˜„ 확인

# StoreTeamResponseDTO 클래슀의 ꡬ쑰 확인
ast-grep --pattern 'record StoreTeamResponseDTO($$$)'

# 맀핑 κ΄€λ ¨ μ„€μ •μ΄λ‚˜ κ΅¬ν˜„ 확인
rg -g '*.java' -A 5 'StoreTeamResponseDTO'

Length of output: 5626


Script:

#!/bin/bash
# StoreTeam 엔티티와 맀핑 κ΅¬ν˜„ 확인
rg -g '*.java' -A 10 'class StoreTeam'

# StoreTeamRepository κ΅¬ν˜„μ²΄ 확인
fd -e java StoreTeamRepository

Length of output: 1116


Script:

#!/bin/bash
# StoreTeamRepository κ΅¬ν˜„μ²΄ 확인 (QueryDSL λ˜λŠ” JPQL κ΅¬ν˜„)
rg -g '*.java' -A 15 'class StoreTeamRepositoryImpl'

# Team μ—”ν‹°ν‹° ꡬ쑰 확인
rg -g '*.java' -A 10 'class Team'

# StoreTeam μ—”ν‹°ν‹°μ˜ λ‚˜λ¨Έμ§€ ν•„λ“œ 확인
rg -g '*.java' -C 20 'class StoreTeam'

Length of output: 9799

}
Loading
Loading