diff --git a/src/main/java/net/skhu/likelion12thteam03be/SelectColor/domain/SelectColor.java b/src/main/java/net/skhu/likelion12thteam03be/SelectColor/domain/SelectColor.java new file mode 100644 index 0000000..150da26 --- /dev/null +++ b/src/main/java/net/skhu/likelion12thteam03be/SelectColor/domain/SelectColor.java @@ -0,0 +1,33 @@ +package net.skhu.likelion12thteam03be.SelectColor.domain; + +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import net.skhu.likelion12thteam03be.survey.domain.Survey; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class SelectColor { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "selectColor_id") + private Long id; + + @ManyToOne + @JoinColumn(name = "survey_id") + Survey survey; + + @ManyToOne + @JoinColumn(name = "color_id") + SelectColor selectColor; + + @Builder + public SelectColor(Long id, Survey survey, SelectColor selectColor) { + this.id = id; + this.survey = survey; + this.selectColor = selectColor; + } +} diff --git a/src/main/java/net/skhu/likelion12thteam03be/SelectColor/domain/repository/SelectColorRepository.java b/src/main/java/net/skhu/likelion12thteam03be/SelectColor/domain/repository/SelectColorRepository.java new file mode 100644 index 0000000..d27c271 --- /dev/null +++ b/src/main/java/net/skhu/likelion12thteam03be/SelectColor/domain/repository/SelectColorRepository.java @@ -0,0 +1,7 @@ +package net.skhu.likelion12thteam03be.SelectColor.domain.repository; + +import net.skhu.likelion12thteam03be.SelectColor.domain.SelectColor; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface SelectColorRepository extends JpaRepository { +} diff --git a/src/main/java/net/skhu/likelion12thteam03be/color/domian/Color.java b/src/main/java/net/skhu/likelion12thteam03be/color/domian/Color.java new file mode 100644 index 0000000..ba2c4ca --- /dev/null +++ b/src/main/java/net/skhu/likelion12thteam03be/color/domian/Color.java @@ -0,0 +1,29 @@ +package net.skhu.likelion12thteam03be.color.domian; + +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Color { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "color_id") + private Long id; + + private String name; + private String mood; + private String comment; + + @Builder + public Color(Long id, String name, String mood, String comment) { + this.id = id; + this.name = name; + this.mood = mood; + this.comment = comment; + } +} diff --git a/src/main/java/net/skhu/likelion12thteam03be/color/domian/repository/ColorRepository.java b/src/main/java/net/skhu/likelion12thteam03be/color/domian/repository/ColorRepository.java new file mode 100644 index 0000000..bd9f0f4 --- /dev/null +++ b/src/main/java/net/skhu/likelion12thteam03be/color/domian/repository/ColorRepository.java @@ -0,0 +1,7 @@ +package net.skhu.likelion12thteam03be.color.domian.repository; + +import net.skhu.likelion12thteam03be.color.domian.Color; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ColorRepository extends JpaRepository { +} diff --git a/src/main/java/net/skhu/likelion12thteam03be/emotion/domain/Emotion.java b/src/main/java/net/skhu/likelion12thteam03be/emotion/domain/Emotion.java new file mode 100644 index 0000000..e5c932f --- /dev/null +++ b/src/main/java/net/skhu/likelion12thteam03be/emotion/domain/Emotion.java @@ -0,0 +1,32 @@ +package net.skhu.likelion12thteam03be.emotion.domain; + +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Emotion { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Enumerated(EnumType.STRING) + Emotions emotions; + + private String furniture; + private String type; + private String animalPic; + + @Builder + public Emotion(Long id, Emotions emotions, String furniture, String type, String animalPic) { + this.id = id; + this.emotions = emotions; + this.furniture = furniture; + this.type = type; + this.animalPic = animalPic; + } +} diff --git a/src/main/java/net/skhu/likelion12thteam03be/emotion/domain/Emotions.java b/src/main/java/net/skhu/likelion12thteam03be/emotion/domain/Emotions.java new file mode 100644 index 0000000..c9da5fd --- /dev/null +++ b/src/main/java/net/skhu/likelion12thteam03be/emotion/domain/Emotions.java @@ -0,0 +1,26 @@ +package net.skhu.likelion12thteam03be.emotion.domain; + +public enum Emotions { // converter + HAPPY("행복한"), + HURRIED("괴로운"), + DULL("암울한"), + TOUCHED("감동적인"), + EXCITING("신나는"), + RELAXED("편안한"), + FEARFUL("두려운"), + INTERESTING("흥미로운"), + NERVOUS("긴장한"), + ANXIOUS("불안한"), + JOYFUL("기쁜"), + CONCERNED("걱정되는"), + EXCITED("설레는"), + WEAPON("무기력한"), + FRUSTRATED("답답한"), + FRESH("상쾌한"); + + private final String name; + + Emotions(String name) { + this.name = name; + } +} diff --git a/src/main/java/net/skhu/likelion12thteam03be/emotion/domain/repository/EmotionRepository.java b/src/main/java/net/skhu/likelion12thteam03be/emotion/domain/repository/EmotionRepository.java new file mode 100644 index 0000000..5374d78 --- /dev/null +++ b/src/main/java/net/skhu/likelion12thteam03be/emotion/domain/repository/EmotionRepository.java @@ -0,0 +1,7 @@ +package net.skhu.likelion12thteam03be.emotion.domain.repository; + +import net.skhu.likelion12thteam03be.emotion.domain.Emotion; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface EmotionRepository extends JpaRepository { +} diff --git a/src/main/java/net/skhu/likelion12thteam03be/global/config/SecurityConfig.java b/src/main/java/net/skhu/likelion12thteam03be/global/config/SecurityConfig.java index 52e52e3..aa2897e 100644 --- a/src/main/java/net/skhu/likelion12thteam03be/global/config/SecurityConfig.java +++ b/src/main/java/net/skhu/likelion12thteam03be/global/config/SecurityConfig.java @@ -1,6 +1,6 @@ package net.skhu.likelion12thteam03be.global.config; -import lombok.RequiredArgsConstructor; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import net.skhu.likelion12thteam03be.global.jwt.JwtAuthorizationFilter; import org.springframework.context.annotation.Bean; diff --git a/src/main/java/net/skhu/likelion12thteam03be/survey/api/SurveyController.java b/src/main/java/net/skhu/likelion12thteam03be/survey/api/SurveyController.java new file mode 100644 index 0000000..7c6a4e6 --- /dev/null +++ b/src/main/java/net/skhu/likelion12thteam03be/survey/api/SurveyController.java @@ -0,0 +1,7 @@ +package net.skhu.likelion12thteam03be.survey.api; + +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class SurveyController { +} diff --git a/src/main/java/net/skhu/likelion12thteam03be/survey/application/SurveyService.java b/src/main/java/net/skhu/likelion12thteam03be/survey/application/SurveyService.java new file mode 100644 index 0000000..e641927 --- /dev/null +++ b/src/main/java/net/skhu/likelion12thteam03be/survey/application/SurveyService.java @@ -0,0 +1,4 @@ +package net.skhu.likelion12thteam03be.survey.application; + +public class SurveyService { +} diff --git a/src/main/java/net/skhu/likelion12thteam03be/survey/domain/Survey.java b/src/main/java/net/skhu/likelion12thteam03be/survey/domain/Survey.java new file mode 100644 index 0000000..30e02a8 --- /dev/null +++ b/src/main/java/net/skhu/likelion12thteam03be/survey/domain/Survey.java @@ -0,0 +1,44 @@ +package net.skhu.likelion12thteam03be.survey.domain; + +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import net.skhu.likelion12thteam03be.SelectColor.domain.SelectColor; +import net.skhu.likelion12thteam03be.emotion.domain.Emotion; +import net.skhu.likelion12thteam03be.user.domain.User; + +import java.util.List; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Survey { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "survey_id") + private Long id; + + @ManyToOne + @JoinColumn(name = "user_id") + private User user; + + @ManyToOne + @JoinColumn(name = "emotion_id") // 외래키 join + Emotion emotion; + + @OneToMany(mappedBy = "survey") // color랑 manytomany 중간테이블 생성 + private List selectColorList; + + private int score; + + @Builder + public Survey(Long id, User user, Emotion emotion, List selectColorList, int score) { + this.id = id; + this.user = user; + this.emotion = emotion; + this.selectColorList = selectColorList; + this.score = score; + } +} diff --git a/src/main/java/net/skhu/likelion12thteam03be/survey/domain/repository/SurveyRepository.java b/src/main/java/net/skhu/likelion12thteam03be/survey/domain/repository/SurveyRepository.java new file mode 100644 index 0000000..82809e4 --- /dev/null +++ b/src/main/java/net/skhu/likelion12thteam03be/survey/domain/repository/SurveyRepository.java @@ -0,0 +1,7 @@ +package net.skhu.likelion12thteam03be.survey.domain.repository; + +import net.skhu.likelion12thteam03be.survey.domain.Survey; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface SurveyRepository extends JpaRepository { +} diff --git a/src/main/java/net/skhu/likelion12thteam03be/user/domain/User.java b/src/main/java/net/skhu/likelion12thteam03be/user/domain/User.java index a49767f..738d09a 100644 --- a/src/main/java/net/skhu/likelion12thteam03be/user/domain/User.java +++ b/src/main/java/net/skhu/likelion12thteam03be/user/domain/User.java @@ -5,9 +5,11 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import net.skhu.likelion12thteam03be.survey.domain.Survey; import net.skhu.likelion12thteam03be.user.exception.InvalidNickNameAddressException; import net.skhu.likelion12thteam03be.user.exception.InvalidUserException; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -30,16 +32,20 @@ public class User { @Enumerated(EnumType.STRING) private Role role; + @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true) + private List surveys; + /* @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true) private List posts = new ArrayList<>();*/ @Builder - public User(String loginId, String password, String nickname, Role role) { + public User(String loginId, String password, String nickname, Role role, List surveys) { validateNickname(nickname); this.loginId = loginId; this.password = password; this.nickname = nickname; this.role = role; + this.surveys = surveys; } private void validateNickname(String nickname) {