Skip to content

Commit

Permalink
Merge pull request #5 from kduoh99/Feat/#3
Browse files Browse the repository at this point in the history
Feat: 데이터베이스 설계
  • Loading branch information
kduoh99 authored Oct 30, 2024
2 parents 711b5ef + 34d521d commit 5f019cb
Show file tree
Hide file tree
Showing 8 changed files with 301 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.hackathon.momento.global.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@Configuration
@EnableJpaAuditing
public class JpaAuditingConfig {
}
52 changes: 52 additions & 0 deletions src/main/java/com/hackathon/momento/member/Member.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.hackathon.momento.member;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Member {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "member_id")
private Long id;

@Column(nullable = false)
private String email;

@Column(nullable = false)
private String name;

@Column(length = 1024)
private String stack;

@Column(length = 1024)
private String persona;

private String ability;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
private RoleType roleType;

@Builder
private Member(String email, String name, String stack, String persona, String ability, RoleType roleType) {
this.email = email;
this.name = name;
this.stack = stack;
this.persona = persona;
this.ability = ability;
this.roleType = roleType;
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/hackathon/momento/member/RoleType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.hackathon.momento.member;

public enum RoleType {
ROLE_USER, ROLE_ADMIN
}
52 changes: 52 additions & 0 deletions src/main/java/com/hackathon/momento/notification/Notification.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.hackathon.momento.notification;

import com.hackathon.momento.member.Member;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import java.time.LocalDateTime;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@EntityListeners(AuditingEntityListener.class)
public class Notification {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "notification_id")
private Long id;

@Column(nullable = false)
private String title;

@Column(columnDefinition = "TEXT")
private String message;

@CreatedDate
@Column(nullable = false, updatable = false)
private LocalDateTime createdAt;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
private Member member;

@Builder
private Notification(String title, String message, Member member) {
this.title = title;
this.message = message;
this.member = member;
}
}
56 changes: 56 additions & 0 deletions src/main/java/com/hackathon/momento/team/TeamBuilding.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.hackathon.momento.team;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import java.time.LocalDate;
import java.time.LocalDateTime;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@EntityListeners(AuditingEntityListener.class)
public class TeamBuilding {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "team_building_id")
private Long id;

@Column(nullable = false)
private LocalDate startDate;

@Column(nullable = false)
private LocalDate endDate;

@Column(nullable = false)
private int teamSize;

@Column(nullable = false)
private String position;

@Column(nullable = false)
private String status;

@CreatedDate
@Column(nullable = false, updatable = false)
private LocalDateTime createdAt;

@Builder
private TeamBuilding(LocalDate startDate, LocalDate endDate, int teamSize, String position, String status) {
this.startDate = startDate;
this.endDate = endDate;
this.teamSize = teamSize;
this.position = position;
this.status = status;
}
}
40 changes: 40 additions & 0 deletions src/main/java/com/hackathon/momento/team/TeamBuildingMember.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.hackathon.momento.team;

import com.hackathon.momento.member.Member;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class TeamBuildingMember {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "team_building_member_id")
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "team_building_id", nullable = false)
private TeamBuilding teamBuilding;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id", nullable = false)
private Member member;

@Builder
private TeamBuildingMember(TeamBuilding teamBuilding, Member member) {
this.teamBuilding = teamBuilding;
this.member = member;
}
}
47 changes: 47 additions & 0 deletions src/main/java/com/hackathon/momento/team/TeamInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.hackathon.momento.team;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import java.time.LocalDateTime;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@EntityListeners(AuditingEntityListener.class)
public class TeamInfo {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "team_info_id")
private Long id;

@Column(nullable = false)
private String teamName;

@CreatedDate
@Column(nullable = false, updatable = false)
private LocalDateTime createdAt;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "team_building_id")
private TeamBuilding teamBuilding;

@Builder
private TeamInfo(String teamName, TeamBuilding teamBuilding) {
this.teamName = teamName;
this.teamBuilding = teamBuilding;
}
}
40 changes: 40 additions & 0 deletions src/main/java/com/hackathon/momento/team/TeamInfoMember.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.hackathon.momento.team;

import com.hackathon.momento.member.Member;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class TeamInfoMember {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "team_member_id")
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "team_info_id", nullable = false)
private TeamInfo teamInfo;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id", nullable = false)
private Member member;

@Builder
private TeamInfoMember(TeamInfo teamInfo, Member member) {
this.teamInfo = teamInfo;
this.member = member;
}
}

0 comments on commit 5f019cb

Please sign in to comment.