From 34d521d206f2646d31af065a2eade082485f362c Mon Sep 17 00:00:00 2001 From: Kang Duoh Date: Wed, 30 Oct 2024 12:07:38 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EB=8D=B0=EC=9D=B4=ED=84=B0=EB=B2=A0?= =?UTF-8?q?=EC=9D=B4=EC=8A=A4=20=EC=84=A4=EA=B3=84=20(#3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/config/JpaAuditingConfig.java | 9 +++ .../com/hackathon/momento/member/Member.java | 52 +++++++++++++++++ .../hackathon/momento/member/RoleType.java | 5 ++ .../momento/notification/Notification.java | 52 +++++++++++++++++ .../hackathon/momento/team/TeamBuilding.java | 56 +++++++++++++++++++ .../momento/team/TeamBuildingMember.java | 40 +++++++++++++ .../com/hackathon/momento/team/TeamInfo.java | 47 ++++++++++++++++ .../momento/team/TeamInfoMember.java | 40 +++++++++++++ 8 files changed, 301 insertions(+) create mode 100644 src/main/java/com/hackathon/momento/global/config/JpaAuditingConfig.java create mode 100644 src/main/java/com/hackathon/momento/member/Member.java create mode 100644 src/main/java/com/hackathon/momento/member/RoleType.java create mode 100644 src/main/java/com/hackathon/momento/notification/Notification.java create mode 100644 src/main/java/com/hackathon/momento/team/TeamBuilding.java create mode 100644 src/main/java/com/hackathon/momento/team/TeamBuildingMember.java create mode 100644 src/main/java/com/hackathon/momento/team/TeamInfo.java create mode 100644 src/main/java/com/hackathon/momento/team/TeamInfoMember.java diff --git a/src/main/java/com/hackathon/momento/global/config/JpaAuditingConfig.java b/src/main/java/com/hackathon/momento/global/config/JpaAuditingConfig.java new file mode 100644 index 0000000..e0d1a02 --- /dev/null +++ b/src/main/java/com/hackathon/momento/global/config/JpaAuditingConfig.java @@ -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 { +} diff --git a/src/main/java/com/hackathon/momento/member/Member.java b/src/main/java/com/hackathon/momento/member/Member.java new file mode 100644 index 0000000..a1e022c --- /dev/null +++ b/src/main/java/com/hackathon/momento/member/Member.java @@ -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; + } +} diff --git a/src/main/java/com/hackathon/momento/member/RoleType.java b/src/main/java/com/hackathon/momento/member/RoleType.java new file mode 100644 index 0000000..3f24419 --- /dev/null +++ b/src/main/java/com/hackathon/momento/member/RoleType.java @@ -0,0 +1,5 @@ +package com.hackathon.momento.member; + +public enum RoleType { + ROLE_USER, ROLE_ADMIN +} diff --git a/src/main/java/com/hackathon/momento/notification/Notification.java b/src/main/java/com/hackathon/momento/notification/Notification.java new file mode 100644 index 0000000..e45120c --- /dev/null +++ b/src/main/java/com/hackathon/momento/notification/Notification.java @@ -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; + } +} diff --git a/src/main/java/com/hackathon/momento/team/TeamBuilding.java b/src/main/java/com/hackathon/momento/team/TeamBuilding.java new file mode 100644 index 0000000..6c81093 --- /dev/null +++ b/src/main/java/com/hackathon/momento/team/TeamBuilding.java @@ -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; + } +} diff --git a/src/main/java/com/hackathon/momento/team/TeamBuildingMember.java b/src/main/java/com/hackathon/momento/team/TeamBuildingMember.java new file mode 100644 index 0000000..e9df21a --- /dev/null +++ b/src/main/java/com/hackathon/momento/team/TeamBuildingMember.java @@ -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; + } +} diff --git a/src/main/java/com/hackathon/momento/team/TeamInfo.java b/src/main/java/com/hackathon/momento/team/TeamInfo.java new file mode 100644 index 0000000..8153353 --- /dev/null +++ b/src/main/java/com/hackathon/momento/team/TeamInfo.java @@ -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; + } +} diff --git a/src/main/java/com/hackathon/momento/team/TeamInfoMember.java b/src/main/java/com/hackathon/momento/team/TeamInfoMember.java new file mode 100644 index 0000000..3b2bd4e --- /dev/null +++ b/src/main/java/com/hackathon/momento/team/TeamInfoMember.java @@ -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; + } +}