-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Kusitms-28th-Kukathon-F/feat/3-domains
Feat/3 domains
- Loading branch information
Showing
8 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/kusitms/server/domain/department/entity/Department.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package kusitms.server.domain.department.entity; | ||
|
||
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 | ||
@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; // 부서 사원 수 | ||
|
||
@OneToOne(mappedBy = "department", cascade = CascadeType.ALL, orphanRemoval = true) | ||
private TumblerCurrent tumblerCurrent; | ||
|
||
@OneToMany(mappedBy = "department", cascade = CascadeType.ALL, orphanRemoval = true) | ||
private List<TumblerHistory> tumblerHistories = new ArrayList<>(); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/kusitms/server/domain/department/repository/DepartmentRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
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<Department, Long> { | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/kusitms/server/domain/tumbler/current/entity/TumblerCurrent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; // 이번달 부서별 텀블러 등급 | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/kusitms/server/domain/tumbler/current/repository/TumblerCurrentRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<TumblerCurrent, Long> { | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/kusitms/server/domain/tumbler/history/entity/TumblerHistory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; // 월별 부서 텀블러 등급 | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/kusitms/server/domain/tumbler/history/repository/TumblerHistoryRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<TumblerHistory, Long> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters