Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
firefox1234123 committed Jul 30, 2024
2 parents 469b8ac + 15df63e commit 10bcbd4
Show file tree
Hide file tree
Showing 13 changed files with 211 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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<SelectColor, Long> {
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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<Color, Long> {
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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<Emotion, Long> {
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package net.skhu.likelion12thteam03be.survey.api;

import org.springframework.web.bind.annotation.RestController;

@RestController
public class SurveyController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package net.skhu.likelion12thteam03be.survey.application;

public class SurveyService {
}
Original file line number Diff line number Diff line change
@@ -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<SelectColor> selectColorList;

private int score;

@Builder
public Survey(Long id, User user, Emotion emotion, List<SelectColor> selectColorList, int score) {
this.id = id;
this.user = user;
this.emotion = emotion;
this.selectColorList = selectColorList;
this.score = score;
}
}
Original file line number Diff line number Diff line change
@@ -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<Survey, Long> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -30,16 +32,20 @@ public class User {
@Enumerated(EnumType.STRING)
private Role role;

@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Survey> surveys;

/* @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Post> 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<Survey> surveys) {
validateNickname(nickname);
this.loginId = loginId;
this.password = password;
this.nickname = nickname;
this.role = role;
this.surveys = surveys;
}

private void validateNickname(String nickname) {
Expand Down

0 comments on commit 10bcbd4

Please sign in to comment.