Skip to content

Commit

Permalink
Merge pull request #11 from Kusitms-28th-Kukathon-F/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
OJOJIN authored Oct 7, 2023
2 parents 5fa6fae + 57744a1 commit 1d77263
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/main/java/kusitms/server/domain/cafe/entity/Cafe.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import kusitms.server.domain.user.entity.User;
import lombok.*;

import java.util.ArrayList;
import java.util.List;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
Expand All @@ -29,4 +32,7 @@ public class Cafe {
@JoinColumn(name = "user_id")
private User user;

@OneToMany(mappedBy = "cafe", fetch = FetchType.LAZY)
private List<CafeCompany> cafeCompanies = new ArrayList<>();

}
28 changes: 28 additions & 0 deletions src/main/java/kusitms/server/domain/cafe/entity/CafeCompany.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package kusitms.server.domain.cafe.entity;


import jakarta.persistence.*;
import kusitms.server.domain.company.entity.Company;
import kusitms.server.domain.user.entity.User;
import lombok.*;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Builder
@Entity
public class CafeCompany {
@Id
@Column(name = "cafe_company_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne
@JoinColumn(name = "cafe_id")
private Cafe cafe;

@ManyToOne
@JoinColumn(name = "company_id")
private Company company;

}
11 changes: 9 additions & 2 deletions src/main/java/kusitms/server/domain/company/entity/Company.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import jakarta.persistence.*;
import kusitms.server.domain.department.entity.Department;
import kusitms.server.domain.cafe.entity.CafeCompany;
import kusitms.server.domain.user.entity.User;
import lombok.*;

import java.util.ArrayList;
import java.util.List;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
Expand All @@ -27,7 +31,10 @@ public class Company {
@JoinColumn(name = "user_id")
private User user;

@OneToOne(mappedBy = "company", cascade = CascadeType.ALL, orphanRemoval = true)
private Department department;
@OneToMany(mappedBy = "company", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Department> departments = new ArrayList<>();

@OneToMany(mappedBy = "company", fetch = FetchType.LAZY)
private List<CafeCompany> cafeCompanies = new ArrayList<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class Department {
@JoinColumn(name = "user_id")
private User user; // 유저 id

@OneToOne(fetch = LAZY, cascade = CascadeType.ALL)
@ManyToOne(fetch = LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "company_id")
private Company company; // 회사 id

Expand Down

0 comments on commit 1d77263

Please sign in to comment.