From eecbdfd37a5780decb1a96041b12fc00e365ef0b Mon Sep 17 00:00:00 2001 From: hojeong2747 Date: Sat, 7 Oct 2023 18:02:47 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=EB=B6=80=EC=84=9C=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0,=20=EB=A0=88=ED=8F=AC=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/domain/company/entity/Company.java | 4 ++ .../domain/department/entity/Department.java | 37 +++++++++++++++++++ .../repository/DepartmentRepository.java | 2 + .../server/domain/user/entity/User.java | 4 ++ 4 files changed, 47 insertions(+) create mode 100644 src/main/java/kusitms/server/domain/department/entity/Department.java create mode 100644 src/main/java/kusitms/server/domain/department/repository/DepartmentRepository.java diff --git a/src/main/java/kusitms/server/domain/company/entity/Company.java b/src/main/java/kusitms/server/domain/company/entity/Company.java index a339791..96ea0b8 100644 --- a/src/main/java/kusitms/server/domain/company/entity/Company.java +++ b/src/main/java/kusitms/server/domain/company/entity/Company.java @@ -1,6 +1,7 @@ package kusitms.server.domain.company.entity; import jakarta.persistence.*; +import kusitms.server.domain.department.entity.Department; import kusitms.server.domain.user.entity.User; import lombok.*; @@ -26,4 +27,7 @@ public class Company { @JoinColumn(name = "user_id") private User user; + @OneToOne(mappedBy = "company", cascade = CascadeType.ALL, orphanRemoval = true) + private Department department; + } diff --git a/src/main/java/kusitms/server/domain/department/entity/Department.java b/src/main/java/kusitms/server/domain/department/entity/Department.java new file mode 100644 index 0000000..7078f89 --- /dev/null +++ b/src/main/java/kusitms/server/domain/department/entity/Department.java @@ -0,0 +1,37 @@ +package kusitms.server.domain.department.entity; + +import jakarta.persistence.*; +import kusitms.server.domain.company.entity.Company; +import kusitms.server.domain.user.entity.User; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import static jakarta.persistence.FetchType.LAZY; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "Department") +@Entity +public class Department { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "dept_id") + private Long id; // 부서 id + + @OneToOne(fetch = LAZY, cascade = CascadeType.ALL) + @JoinColumn(name = "user_id") + private User user; // 유저 id + + @OneToOne(fetch = LAZY, cascade = CascadeType.ALL) + @JoinColumn(name = "company_id") + private Company company; // 회사 id + + @Column(name = "dept_name", nullable = false) + private String deptName; // 부서 이름 + + @Column(name = "member_count", nullable = false) + private Integer memberCount; // 부서 사원 수 + +} diff --git a/src/main/java/kusitms/server/domain/department/repository/DepartmentRepository.java b/src/main/java/kusitms/server/domain/department/repository/DepartmentRepository.java new file mode 100644 index 0000000..66d2b16 --- /dev/null +++ b/src/main/java/kusitms/server/domain/department/repository/DepartmentRepository.java @@ -0,0 +1,2 @@ +package kusitms.server.domain.department.repository;public interface DepartmentRepository { +} diff --git a/src/main/java/kusitms/server/domain/user/entity/User.java b/src/main/java/kusitms/server/domain/user/entity/User.java index da6660a..92dee74 100644 --- a/src/main/java/kusitms/server/domain/user/entity/User.java +++ b/src/main/java/kusitms/server/domain/user/entity/User.java @@ -3,6 +3,7 @@ import jakarta.persistence.*; import kusitms.server.domain.cafe.entity.Cafe; import kusitms.server.domain.company.entity.Company; +import kusitms.server.domain.department.entity.Department; import lombok.*; @Getter @@ -33,4 +34,7 @@ public class User { @OneToOne(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true) private Company company; + + @OneToOne(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true) + private Department department; } From bbb2b856c42d2e597ec762990ddb1a16cfd008e0 Mon Sep 17 00:00:00 2001 From: hojeong2747 Date: Sat, 7 Oct 2023 18:22:28 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=ED=85=80=EB=B8=94=EB=9F=AC-?= =?UTF-8?q?=ED=98=84=EC=9E=AC=20=EC=97=94=ED=8B=B0=ED=8B=B0,=20=EB=A0=88?= =?UTF-8?q?=ED=8F=AC=20=EC=83=9D=EC=84=B1=20(#3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/department/entity/Department.java | 6 ++- .../repository/DepartmentRepository.java | 8 +++- .../current/entity/TumblerCurrent.java | 41 +++++++++++++++++++ .../repository/TumblerCurrentRepository.java | 8 ++++ 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 src/main/java/kusitms/server/domain/tumbler/current/entity/TumblerCurrent.java create mode 100644 src/main/java/kusitms/server/domain/tumbler/current/repository/TumblerCurrentRepository.java diff --git a/src/main/java/kusitms/server/domain/department/entity/Department.java b/src/main/java/kusitms/server/domain/department/entity/Department.java index 7078f89..e414e9a 100644 --- a/src/main/java/kusitms/server/domain/department/entity/Department.java +++ b/src/main/java/kusitms/server/domain/department/entity/Department.java @@ -2,6 +2,7 @@ import jakarta.persistence.*; import kusitms.server.domain.company.entity.Company; +import kusitms.server.domain.tumbler.current.entity.TumblerCurrent; import kusitms.server.domain.user.entity.User; import lombok.AccessLevel; import lombok.Getter; @@ -11,7 +12,7 @@ @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -@Table(name = "Department") +@Table(name = "DEPARTMENT") @Entity public class Department { @@ -34,4 +35,7 @@ public class Department { @Column(name = "member_count", nullable = false) private Integer memberCount; // 부서 사원 수 + @OneToOne(mappedBy = "department", cascade = CascadeType.ALL, orphanRemoval = true) + private TumblerCurrent tumblerCurrent; + } diff --git a/src/main/java/kusitms/server/domain/department/repository/DepartmentRepository.java b/src/main/java/kusitms/server/domain/department/repository/DepartmentRepository.java index 66d2b16..bbad8f0 100644 --- a/src/main/java/kusitms/server/domain/department/repository/DepartmentRepository.java +++ b/src/main/java/kusitms/server/domain/department/repository/DepartmentRepository.java @@ -1,2 +1,8 @@ -package kusitms.server.domain.department.repository;public interface DepartmentRepository { +package kusitms.server.domain.department.repository; + +import kusitms.server.domain.department.entity.Department; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface DepartmentRepository extends JpaRepository { + } diff --git a/src/main/java/kusitms/server/domain/tumbler/current/entity/TumblerCurrent.java b/src/main/java/kusitms/server/domain/tumbler/current/entity/TumblerCurrent.java new file mode 100644 index 0000000..f57b29d --- /dev/null +++ b/src/main/java/kusitms/server/domain/tumbler/current/entity/TumblerCurrent.java @@ -0,0 +1,41 @@ +package kusitms.server.domain.tumbler.current.entity; + +import jakarta.persistence.*; +import kusitms.server.domain.department.entity.Department; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import static jakarta.persistence.FetchType.LAZY; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "TUMBLER_CURRENT") +@Entity +public class TumblerCurrent { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "tumbler_cur_id") + private Long id; // 현재 부서별 텀블러 id + + @OneToOne(fetch = LAZY, cascade = CascadeType.ALL) + @JoinColumn(name = "dept_id") + private Department department; // 부서 id + + @Column(name = "tumbler_name", nullable = false) + private String tumblerName; // 이번달 부서별 텀블러 이름 + + @Column(name = "tumbler_goal", nullable = false) + private Integer tumblerGoal; // 이번달 부서별 텀블러 목표 수 (사원 수 * 하루 2잔 * 20일) + + @Column(name = "tumbler_count", nullable = false) + private Integer tumblerCount; // 이번달 부서별 텀블러 적립 수 + + @Column(name = "tumbler_percent", nullable = false) + private Double tumblerPercent; // 이번달 부서별 텀블러 퍼센트 (적립 수 / 목표 수) + + @Column(name = "tumbler_grade", nullable = false) + private String tumblerGrade; // 이번달 부서별 텀블러 등급 + +} diff --git a/src/main/java/kusitms/server/domain/tumbler/current/repository/TumblerCurrentRepository.java b/src/main/java/kusitms/server/domain/tumbler/current/repository/TumblerCurrentRepository.java new file mode 100644 index 0000000..eaf8f40 --- /dev/null +++ b/src/main/java/kusitms/server/domain/tumbler/current/repository/TumblerCurrentRepository.java @@ -0,0 +1,8 @@ +package kusitms.server.domain.tumbler.current.repository; + +import kusitms.server.domain.tumbler.current.entity.TumblerCurrent; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface TumblerCurrentRepository extends JpaRepository { + +} From 3e6475567a69cc6e855eed51e0ea885c43a3ef67 Mon Sep 17 00:00:00 2001 From: hojeong2747 Date: Sat, 7 Oct 2023 18:43:01 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=ED=85=80=EB=B8=94=EB=9F=AC-?= =?UTF-8?q?=EB=82=B4=EC=97=AD=20=EC=97=94=ED=8B=B0=ED=8B=B0,=20=EB=A0=88?= =?UTF-8?q?=ED=8F=AC=20=EC=83=9D=EC=84=B1=20(#3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/department/entity/Department.java | 6 +++ .../history/entity/TumblerHistory.java | 39 +++++++++++++++++++ .../repository/TumblerHistoryRepository.java | 8 ++++ 3 files changed, 53 insertions(+) create mode 100644 src/main/java/kusitms/server/domain/tumbler/history/entity/TumblerHistory.java create mode 100644 src/main/java/kusitms/server/domain/tumbler/history/repository/TumblerHistoryRepository.java diff --git a/src/main/java/kusitms/server/domain/department/entity/Department.java b/src/main/java/kusitms/server/domain/department/entity/Department.java index e414e9a..9b20619 100644 --- a/src/main/java/kusitms/server/domain/department/entity/Department.java +++ b/src/main/java/kusitms/server/domain/department/entity/Department.java @@ -3,11 +3,15 @@ import jakarta.persistence.*; import kusitms.server.domain.company.entity.Company; import kusitms.server.domain.tumbler.current.entity.TumblerCurrent; +import kusitms.server.domain.tumbler.history.entity.TumblerHistory; import kusitms.server.domain.user.entity.User; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.ArrayList; +import java.util.List; + import static jakarta.persistence.FetchType.LAZY; @Getter @@ -38,4 +42,6 @@ public class Department { @OneToOne(mappedBy = "department", cascade = CascadeType.ALL, orphanRemoval = true) private TumblerCurrent tumblerCurrent; + @OneToMany(mappedBy = "department", cascade = CascadeType.ALL, orphanRemoval = true) + private List tumblerHistories = new ArrayList<>(); } diff --git a/src/main/java/kusitms/server/domain/tumbler/history/entity/TumblerHistory.java b/src/main/java/kusitms/server/domain/tumbler/history/entity/TumblerHistory.java new file mode 100644 index 0000000..d7be916 --- /dev/null +++ b/src/main/java/kusitms/server/domain/tumbler/history/entity/TumblerHistory.java @@ -0,0 +1,39 @@ +package kusitms.server.domain.tumbler.history.entity; + +import jakarta.persistence.*; +import kusitms.server.domain.department.entity.Department; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +import static jakarta.persistence.FetchType.LAZY; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "TUMBLER_HISTORY") +@Entity +public class TumblerHistory { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "tumbler_his_id") + private Long id; // 부서별 텀블러 내역 id + + @ManyToOne(fetch = LAZY, cascade = CascadeType.ALL) + @JoinColumn(name = "dept_id") + private Department department; // 부서 id + + @Column(name = "created_at", nullable = false) + private LocalDateTime createdAt; // 생성 날짜 (월 구분) + + @Column(name = "tumbler_name", nullable = false) + private String tumblerName; // 월별 부서 텀블러 이름 + + @Column(name = "tumbler_percent", nullable = false) + private Double tumblerPercent; // 월별 부서 텀블러 퍼센트 + + @Column(name = "tumbler_grade", nullable = false) + private String tumblerGrade; // 월별 부서 텀블러 등급 +} diff --git a/src/main/java/kusitms/server/domain/tumbler/history/repository/TumblerHistoryRepository.java b/src/main/java/kusitms/server/domain/tumbler/history/repository/TumblerHistoryRepository.java new file mode 100644 index 0000000..e9cb3e5 --- /dev/null +++ b/src/main/java/kusitms/server/domain/tumbler/history/repository/TumblerHistoryRepository.java @@ -0,0 +1,8 @@ +package kusitms.server.domain.tumbler.history.repository; + +import kusitms.server.domain.tumbler.history.entity.TumblerHistory; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface TumblerHistoryRepository extends JpaRepository { + +}