Skip to content

Commit

Permalink
Merge pull request #2 from Dev-TeamOne/feat/#1
Browse files Browse the repository at this point in the history
[feat/#1] Entity 생성
  • Loading branch information
isieun0908 authored Mar 27, 2023
2 parents ceb9310 + 8b57c8e commit 7f785fb
Show file tree
Hide file tree
Showing 13 changed files with 295 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package devteamOne.classmate.channel.domain;

import devteamOne.classmate.participant.domain.Participant;
import devteamOne.classmate.question.domain.Question;
import devteamOne.classmate.survey.domain.Survey;
import devteamOne.classmate.user.domain.User;
import jakarta.persistence.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Entity
public class Channel {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String name;

private String code;

private LocalDateTime createdAt;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;

@OneToMany(mappedBy = "channel")
private List<Question> questionList = new ArrayList<>();

@OneToMany(mappedBy = "channel")
private List<Survey> surveyList = new ArrayList<>();

@OneToMany(mappedBy = "channel")
private List<Participant> participantList = new ArrayList<>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package devteamOne.classmate.likes.domain;

import devteamOne.classmate.question.domain.Question;
import devteamOne.classmate.user.domain.User;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.IdClass;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

@Entity
@IdClass(LikesId.class)
public class Likes {

@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;

@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "question_id")
private Question question;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package devteamOne.classmate.likes.domain;

import devteamOne.classmate.question.domain.Question;
import devteamOne.classmate.user.domain.User;
import java.io.Serializable;

public class LikesId implements Serializable {
private User user;
private Question question;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package devteamOne.classmate.participant.domain;

import devteamOne.classmate.channel.domain.Channel;
import devteamOne.classmate.user.domain.User;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.IdClass;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

@Entity
@IdClass(ParticipantId.class)
public class Participant {

@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "channel_id")
private Channel channel;

@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;

private String nickname;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package devteamOne.classmate.participant.domain;

import devteamOne.classmate.channel.domain.Channel;
import devteamOne.classmate.user.domain.User;
import java.io.Serializable;

public class ParticipantId implements Serializable {
private Channel channel;
private User user;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package devteamOne.classmate.pinned.domain;

import devteamOne.classmate.channel.domain.Channel;
import devteamOne.classmate.question.domain.Question;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.IdClass;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;

@Entity
@IdClass(PinnedId.class)
public class Pinned {

@Id
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "channel_id")
private Channel channel;

@Id
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "question_id")
private Question question;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package devteamOne.classmate.pinned.domain;

import devteamOne.classmate.channel.domain.Channel;
import devteamOne.classmate.question.domain.Question;
import java.io.Serializable;

public class PinnedId implements Serializable {
private Channel channel;
private Question question;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package devteamOne.classmate.question.domain;

import devteamOne.classmate.channel.domain.Channel;
import devteamOne.classmate.user.domain.User;
import jakarta.persistence.*;
import java.time.LocalDateTime;

@Entity
public class Question {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String context;

private Boolean answered;

private LocalDateTime createdAt;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "channel_id")
private Channel channel;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package devteamOne.classmate.survey.domain;

import devteamOne.classmate.channel.domain.Channel;
import devteamOne.classmate.surveyOption.domain.SurveyOption;
import jakarta.persistence.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Entity
public class Survey {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String question;

private Boolean multipleCheck;

private Boolean opened;

private LocalDateTime createdAt;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "channel_id")
private Channel channel;

@OneToMany(mappedBy = "survey")
private List<SurveyOption> surveyOptionList = new ArrayList<>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package devteamOne.classmate.surveyAnswer.domain;

import devteamOne.classmate.survey.domain.Survey;
import devteamOne.classmate.surveyOption.domain.SurveyOption;
import devteamOne.classmate.user.domain.User;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.IdClass;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

@Entity
@IdClass(SurveyAnswerId.class)
public class SurveyAnswer {

@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;

@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "survey_id")
private Survey survey;

@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "survey_option_id")
private SurveyOption surveyOption;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package devteamOne.classmate.surveyAnswer.domain;

import devteamOne.classmate.survey.domain.Survey;
import devteamOne.classmate.surveyOption.domain.SurveyOption;
import devteamOne.classmate.user.domain.User;
import java.io.Serializable;

public class SurveyAnswerId implements Serializable {
private User user;
private Survey survey;
private SurveyOption surveyOption;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package devteamOne.classmate.surveyOption.domain;

import devteamOne.classmate.survey.domain.Survey;
import jakarta.persistence.*;

@Entity
public class SurveyOption {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String answer;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "survey_id")
private Survey survey;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package devteamOne.classmate.user.domain;

import devteamOne.classmate.channel.domain.Channel;
import devteamOne.classmate.question.domain.Question;
import jakarta.persistence.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import org.springframework.boot.autoconfigure.condition.ConditionalOnJava;

@Entity
public class User {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String nickname;

private String socialId;

private String provider;

private LocalDateTime createdAt;

@OneToMany(mappedBy = "user")
private List<Channel> channelList = new ArrayList<>();

@OneToMany(mappedBy = "user")
private List<Question> questionList = new ArrayList<>();
}

0 comments on commit 7f785fb

Please sign in to comment.