Skip to content

Commit

Permalink
Merge pull request #9 from Kusitms-28th-Kukathon-F/feat/3-domains
Browse files Browse the repository at this point in the history
Feat/3 domains
  • Loading branch information
hojeong2747 authored Oct 7, 2023
2 parents 1f08418 + 3e64755 commit 4061204
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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.*;

Expand All @@ -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;

}
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<>();
}
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> {

}
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; // 이번달 부서별 텀블러 등급

}
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> {

}
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; // 월별 부서 텀블러 등급
}
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> {

}
4 changes: 4 additions & 0 deletions src/main/java/kusitms/server/domain/user/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

0 comments on commit 4061204

Please sign in to comment.