Skip to content

Commit

Permalink
feat: Program객체에서 상속한 Volunteering엔티티, Employment 엔티티 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
kseysh committed Nov 25, 2023
1 parent 8e35a10 commit 85d8672
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.sopt.sopkerton.common.domain;

import jakarta.persistence.Column;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import java.time.LocalDateTime;
Expand All @@ -14,10 +13,8 @@
@EntityListeners(AuditingEntityListener.class)
public class BaseEntity {
@CreatedDate
@Column(name = "register_at")
private LocalDateTime registerAt;

@LastModifiedDate
@Column(name = "done_at")
private LocalDateTime doneAt;
}
14 changes: 14 additions & 0 deletions src/main/java/org/sopt/sopkerton/program/domain/Category.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.sopt.sopkerton.program.domain;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public enum Category {
VOLUNTEERING("봉사"),
EMPLOYMENT("취업");

private final String value;
}
15 changes: 15 additions & 0 deletions src/main/java/org/sopt/sopkerton/program/domain/Employment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.sopt.sopkerton.program.domain;

import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;


@Entity
@DiscriminatorValue("EMPLOYMENT")
@NoArgsConstructor
@AllArgsConstructor
public class Employment extends Program{
private int salary;
}
47 changes: 47 additions & 0 deletions src/main/java/org/sopt/sopkerton/program/domain/Program.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.sopt.sopkerton.program.domain;

import jakarta.persistence.Column;
import jakarta.persistence.DiscriminatorColumn;
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 jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.sopt.sopkerton.common.domain.BaseEntity;

@Getter
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "programs")
public abstract class Program extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false)
private String title;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
private Category category;

@Column(nullable = false)
private String organizationName;

@Column(nullable = false)
private String region;

@Column(nullable = false)
private String content;
}
14 changes: 14 additions & 0 deletions src/main/java/org/sopt/sopkerton/program/domain/Volunteering.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.sopt.sopkerton.program.domain;

import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

@Entity
@DiscriminatorValue("VOLUNTEERING")
@NoArgsConstructor
@AllArgsConstructor
public class Volunteering extends Program{
private int volunteerHours;
}

0 comments on commit 85d8672

Please sign in to comment.