From 833f5e3aa9f32b71d20aab834108370b945952a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9E=AC=ED=98=81?= Date: Mon, 18 Nov 2024 21:01:16 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=EA=B2=B0=EC=A0=9C=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=9A=94=EA=B5=AC=EC=82=AC=ED=95=AD=20=EB=B0=98?= =?UTF-8?q?=EC=98=81=20(#14)=20(#15)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/application/KakaopayService.java | 4 +++- .../payment/domain/PaymentChargeStatus.java | 18 ++++-------------- .../payment/domain/TeamChargeHistory.java | 2 +- .../jangburich/domain/user/domain/User.java | 8 ++++++++ 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/jangburich/domain/payment/application/KakaopayService.java b/src/main/java/com/jangburich/domain/payment/application/KakaopayService.java index 96ca7d4..368af43 100644 --- a/src/main/java/com/jangburich/domain/payment/application/KakaopayService.java +++ b/src/main/java/com/jangburich/domain/payment/application/KakaopayService.java @@ -37,13 +37,14 @@ public class KakaopayService implements PaymentService { @Value("${kakaopay.fail-url}") private String failUrl; - private TeamRepository teamRepository; + private final TeamRepository teamRepository; @Override public String getType() { return "kakao"; } + @Transactional @Override public ReadyResponse payReady(Long userId, PayRequest payRequest) { Map parameters = new HashMap<>(); @@ -82,6 +83,7 @@ public ReadyResponse payReady(Long userId, PayRequest payRequest) { return readyResponseResponseEntity.getBody(); } + @Transactional @Override public ApproveResponse payApprove(Long userId, String tid, String pgToken) { Map parameters = new HashMap<>(); diff --git a/src/main/java/com/jangburich/domain/payment/domain/PaymentChargeStatus.java b/src/main/java/com/jangburich/domain/payment/domain/PaymentChargeStatus.java index 5ec6a6f..4ef9beb 100644 --- a/src/main/java/com/jangburich/domain/payment/domain/PaymentChargeStatus.java +++ b/src/main/java/com/jangburich/domain/payment/domain/PaymentChargeStatus.java @@ -1,18 +1,8 @@ package com.jangburich.domain.payment.domain; public enum PaymentChargeStatus { - PENDING("충전 대기"), - COMPLETED("충전 완료"), - CANCELLED("충전 취소"), - REFUNDED("충전 환불"); - - private final String description; - - PaymentChargeStatus(String description) { - this.description = description; - } - - public String getDescription() { - return description; - } + PENDING, + COMPLETED, + CANCELLED, + REFUNDED; } diff --git a/src/main/java/com/jangburich/domain/payment/domain/TeamChargeHistory.java b/src/main/java/com/jangburich/domain/payment/domain/TeamChargeHistory.java index 988c80d..0732f6f 100644 --- a/src/main/java/com/jangburich/domain/payment/domain/TeamChargeHistory.java +++ b/src/main/java/com/jangburich/domain/payment/domain/TeamChargeHistory.java @@ -35,7 +35,7 @@ public class TeamChargeHistory extends BaseEntity { private Integer paymentAmount; @Enumerated(EnumType.STRING) - @Column(name = "payment_charge_status") + @Column(name = "payment_charge_status", length = 20) private PaymentChargeStatus paymentChargeStatus; @ManyToOne(fetch = FetchType.LAZY) diff --git a/src/main/java/com/jangburich/domain/user/domain/User.java b/src/main/java/com/jangburich/domain/user/domain/User.java index 14b1f32..4079231 100644 --- a/src/main/java/com/jangburich/domain/user/domain/User.java +++ b/src/main/java/com/jangburich/domain/user/domain/User.java @@ -1,11 +1,15 @@ package com.jangburich.domain.user.domain; import com.jangburich.domain.common.BaseEntity; +import com.jangburich.domain.team.domain.Team; import jakarta.persistence.Column; import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -46,6 +50,10 @@ public class User extends BaseEntity { @Column(name = "role") private String role; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "team_id") + private Team team; + public static User create(String userId, String nickname, String image, String role) { User newUser = new User(); newUser.setProviderId(userId); From 43d7a920305029f84f07c18c2401678039c95c58 Mon Sep 17 00:00:00 2001 From: HyunWoo9930 Date: Mon, 18 Nov 2024 22:00:22 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat=20:=20team-user=20join=20=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EB=B8=94=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jangburich/domain/team/domain/Team.java | 9 +++++++++ .../com/jangburich/domain/user/domain/User.java | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/jangburich/domain/team/domain/Team.java b/src/main/java/com/jangburich/domain/team/domain/Team.java index 2cde16e..3634cb6 100644 --- a/src/main/java/com/jangburich/domain/team/domain/Team.java +++ b/src/main/java/com/jangburich/domain/team/domain/Team.java @@ -1,11 +1,17 @@ package com.jangburich.domain.team.domain; +import java.util.HashSet; +import java.util.Set; + import com.jangburich.domain.common.BaseEntity; +import com.jangburich.domain.user.domain.User; + import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.ManyToMany; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -29,6 +35,9 @@ public class Team extends BaseEntity { @Column(name = "member_limit") private Integer memberLimit; + @ManyToMany(mappedBy = "teams") + private Set users = new HashSet<>(); + public void updatePoint(Integer point) { this.point += point; } diff --git a/src/main/java/com/jangburich/domain/user/domain/User.java b/src/main/java/com/jangburich/domain/user/domain/User.java index 4079231..04c8093 100644 --- a/src/main/java/com/jangburich/domain/user/domain/User.java +++ b/src/main/java/com/jangburich/domain/user/domain/User.java @@ -1,5 +1,8 @@ package com.jangburich.domain.user.domain; +import java.util.HashSet; +import java.util.Set; + import com.jangburich.domain.common.BaseEntity; import com.jangburich.domain.team.domain.Team; import jakarta.persistence.Column; @@ -9,6 +12,8 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; import lombok.AccessLevel; import lombok.Getter; @@ -50,9 +55,13 @@ public class User extends BaseEntity { @Column(name = "role") private String role; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "team_id") - private Team team; + @ManyToMany + @JoinTable( + name = "user_team", + joinColumns = @JoinColumn(name = "user_id"), + inverseJoinColumns = @JoinColumn(name = "team_id") + ) + private Set teams = new HashSet<>(); public static User create(String userId, String nickname, String image, String role) { User newUser = new User();