-
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
Develop #36
Develop #36
Changes from all commits
20def78
e276ce7
a4b31a3
40bf044
85feb74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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); | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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; | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
public void addRemainPoint(Integer point) { | ||||||||||||||||||||
this.remainPoint += point; | ||||||||||||||||||||
} | ||||||||||||||||||||
Comment on lines
+47
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
public void subRemainPoint(Integer point) { | ||||||||||||||||||||
this.remainPoint -= point; | ||||||||||||||||||||
} | ||||||||||||||||||||
Comment on lines
+51
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μμ¬ ν¬μΈνΈκ° μμκ° λμ§ μλλ‘ κ²μ¦μ΄ νμν©λλ€.
public void subRemainPoint(Integer point) {
+ if (this.remainPoint < point) {
+ throw new IllegalArgumentException("μμ¬ ν¬μΈνΈκ° λΆμ‘±ν©λλ€. νμ¬ μμ¬ ν¬μΈνΈ: " + this.remainPoint + ", μ°¨κ° μμ² ν¬μΈνΈ: " + point);
+ }
this.remainPoint -= point;
} π Committable suggestion
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion νλ νμ κ³Ό μ ν¨μ± κ²μ¦μ κ°μ ν΄μ£ΌμΈμ.
λ€μκ³Ό κ°μ΄ κ°μ ν΄λ³΄μΈμ: +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
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
) { | ||||||||||||||||||||||||||||||||||||||||
@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; | ||
|
@@ -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; | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion μΈμ¦ μ²λ¦¬ λ‘μ§ κ°μ μ΄ νμν©λλ€. κ²μ μλν¬μΈνΈλ€μ μΈμ¦ μ²λ¦¬κ° μΌκ΄μ±μ΄ μμ΅λλ€. λ€μκ³Ό κ°μ΄ μμ μ μ μλ립λλ€: 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));
}
|
||
} | ||
|
||
@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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion μΈμ¦ μ²λ¦¬ λ°©μμ ν΅μΌνκ° νμν©λλ€. μ€ν μ΄ κ΄λ¦¬ μλν¬μΈνΈλ€μμ λ€μκ³Ό κ°μ΄ μμ μ μ μλ립λλ€: 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());
}
|
||
} | ||
|
||
@Operation(summary = "κ°κ² μ 보 μ‘°ν", description = "κ°κ² μμΈ μ 보λ₯Ό μ‘°νν©λλ€.") | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
+ );
}
|
||||||||||||||||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π‘ Codebase verification DTO 맀ν ꡬνμ΄ λλ½λμ΄ μμ΅λλ€.
맀ν μ λ€μ νλλ€μ΄ μ¬λ°λ₯΄κ² λ³νλμ΄μΌ ν©λλ€:
π Analysis chainDTO λ³ν ꡬν νμΈμ΄ νμν©λλ€.
λ€μ μ€ν¬λ¦½νΈλ‘ DTO 맀ν ꡬνμ νμΈν΄λ³΄κ² μ΅λλ€: Let me gather more information about the DTO mapping implementation. π Scripts executedThe 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 |
||
} |
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.
π οΈ Refactor suggestion
ν¬μΈνΈ μ¦κ° λ©μλμ μ ν¨μ± κ²μ¬κ° νμν©λλ€.
μμ κ°μ΄ μ λ ₯λλ κ²μ λ°©μ§νκΈ° μν΄ ν¬μΈνΈ κ° κ²μ¦μ μΆκ°ν΄ μ£ΌμΈμ.
π Committable suggestion