Skip to content

Commit

Permalink
Merge pull request 9oormthon-univ#16 from 9oormthon-univ/feat/paymentโ€ฆ
Browse files Browse the repository at this point in the history
โ€ฆ/owner

Feat/payment/owner
  • Loading branch information
HyunWoo9930 authored Nov 18, 2024
2 parents 863c2c0 + 8550096 commit 940fd85
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/main/java/com/jangburich/domain/team/domain/Team.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -29,6 +35,9 @@ public class Team extends BaseEntity {
@Column(name = "member_limit")
private Integer memberLimit;

@ManyToMany(mappedBy = "teams")
private Set<User> users = new HashSet<>();

public void updatePoint(Integer point) {
this.point += point;
}
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/com/jangburich/domain/user/domain/User.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -50,9 +55,14 @@ 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<Team> teams = new HashSet<>();

public static User create(String userId, String nickname, String image, String role) {
User newUser = new User();
Expand Down

0 comments on commit 940fd85

Please sign in to comment.