From f81167559621429b7ce339452ba311ecdbc61368 Mon Sep 17 00:00:00 2001 From: shinheekim Date: Tue, 30 Jul 2024 16:01:34 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20Survey,=20Emotion,=20Color,=20Selec?= =?UTF-8?q?tColor=20=EB=8F=84=EB=A9=94=EC=9D=B8=20=EB=B0=8F=20repository?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SelectColor/domain/SelectColor.java | 33 ++++++++++++++ .../repository/SelectColorRepository.java | 7 +++ .../color/domian/Color.java | 29 ++++++++++++ .../domian/repository/ColorRepository.java | 7 +++ .../emotion/domain/Emotion.java | 30 +++++++++++++ .../domain/repository/EmotionRepository.java | 7 +++ .../global/config/SecurityConfig.java | 2 +- .../survey/api/SurveyController.java | 7 +++ .../survey/application/SurveyService.java | 4 ++ .../survey/domain/Survey.java | 44 +++++++++++++++++++ .../domain/repository/SurveyRepository.java | 7 +++ .../user/domain/User.java | 5 +++ 12 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 src/main/java/net/skhu/likelion12thteam03be/SelectColor/domain/SelectColor.java create mode 100644 src/main/java/net/skhu/likelion12thteam03be/SelectColor/domain/repository/SelectColorRepository.java create mode 100644 src/main/java/net/skhu/likelion12thteam03be/color/domian/Color.java create mode 100644 src/main/java/net/skhu/likelion12thteam03be/color/domian/repository/ColorRepository.java create mode 100644 src/main/java/net/skhu/likelion12thteam03be/emotion/domain/Emotion.java create mode 100644 src/main/java/net/skhu/likelion12thteam03be/emotion/domain/repository/EmotionRepository.java create mode 100644 src/main/java/net/skhu/likelion12thteam03be/survey/api/SurveyController.java create mode 100644 src/main/java/net/skhu/likelion12thteam03be/survey/application/SurveyService.java create mode 100644 src/main/java/net/skhu/likelion12thteam03be/survey/domain/Survey.java create mode 100644 src/main/java/net/skhu/likelion12thteam03be/survey/domain/repository/SurveyRepository.java 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..2eec571 --- /dev/null +++ b/src/main/java/net/skhu/likelion12thteam03be/emotion/domain/Emotion.java @@ -0,0 +1,30 @@ +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; + + private String name; + private String furniture; + private String type; + private String animalPic; + + @Builder + public Emotion(Long id, String name, String furniture, String type, String animalPic) { + this.id = id; + this.name = name; + this.furniture = furniture; + this.type = type; + this.animalPic = animalPic; + } +} 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..2d0925b --- /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; + + @OneToOne(mappedBy = "user") + @Column(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..e95efd9 100644 --- a/src/main/java/net/skhu/likelion12thteam03be/user/domain/User.java +++ b/src/main/java/net/skhu/likelion12thteam03be/user/domain/User.java @@ -5,6 +5,7 @@ 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; @@ -30,6 +31,10 @@ public class User { @Enumerated(EnumType.STRING) private Role role; + @OneToOne + @JoinColumn(name = "survey_id") + private Survey survey; + /* @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true) private List posts = new ArrayList<>();*/ From 128a1708e470f353ba5ec149f2d2667dc9416f30 Mon Sep 17 00:00:00 2001 From: shinheekim Date: Tue, 30 Jul 2024 18:04:17 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20user,=20survey=20=EC=97=B0=EA=B4=80?= =?UTF-8?q?=EA=B4=80=EA=B3=84=20=EC=88=98=EC=A0=95(#6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 5 +--- .../emotion/domain/Emotion.java | 8 +++--- .../emotion/domain/Emotions.java | 26 +++++++++++++++++++ .../survey/domain/Survey.java | 4 +-- .../user/domain/User.java | 9 ++++--- src/main/resources/application.yml | 7 ----- 6 files changed, 39 insertions(+), 20 deletions(-) create mode 100644 src/main/java/net/skhu/likelion12thteam03be/emotion/domain/Emotions.java diff --git a/build.gradle b/build.gradle index addd84b..8c602a6 100644 --- a/build.gradle +++ b/build.gradle @@ -40,10 +40,7 @@ dependencies { implementation 'io.jsonwebtoken:jjwt-api:0.11.5' runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5' runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5' - // jwt - implementation 'io.jsonwebtoken:jjwt-api:0.11.5' - runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5' - runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5' + //aws implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0' diff --git a/src/main/java/net/skhu/likelion12thteam03be/emotion/domain/Emotion.java b/src/main/java/net/skhu/likelion12thteam03be/emotion/domain/Emotion.java index 2eec571..e5c932f 100644 --- a/src/main/java/net/skhu/likelion12thteam03be/emotion/domain/Emotion.java +++ b/src/main/java/net/skhu/likelion12thteam03be/emotion/domain/Emotion.java @@ -14,15 +14,17 @@ public class Emotion { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - private String name; + @Enumerated(EnumType.STRING) + Emotions emotions; + private String furniture; private String type; private String animalPic; @Builder - public Emotion(Long id, String name, String furniture, String type, String animalPic) { + public Emotion(Long id, Emotions emotions, String furniture, String type, String animalPic) { this.id = id; - this.name = name; + 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/survey/domain/Survey.java b/src/main/java/net/skhu/likelion12thteam03be/survey/domain/Survey.java index 2d0925b..30e02a8 100644 --- a/src/main/java/net/skhu/likelion12thteam03be/survey/domain/Survey.java +++ b/src/main/java/net/skhu/likelion12thteam03be/survey/domain/Survey.java @@ -20,8 +20,8 @@ public class Survey { @Column(name = "survey_id") private Long id; - @OneToOne(mappedBy = "user") - @Column(name = "user_id") + @ManyToOne + @JoinColumn(name = "user_id") private User user; @ManyToOne 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 e95efd9..738d09a 100644 --- a/src/main/java/net/skhu/likelion12thteam03be/user/domain/User.java +++ b/src/main/java/net/skhu/likelion12thteam03be/user/domain/User.java @@ -9,6 +9,7 @@ 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; @@ -31,20 +32,20 @@ public class User { @Enumerated(EnumType.STRING) private Role role; - @OneToOne - @JoinColumn(name = "survey_id") - private Survey survey; + @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) { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 0d82115..7dde435 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -15,16 +15,9 @@ spring: hibernate: format_sql: false use_sql_comments: true -#logging: -# level: -# org.hibernate.sql: debug -# org.hibernate.type: trace jwt: secret: ${jwt.secret} access-token-validity-in-milliseconds: ${JWT_ACCESS_TOKEN_VALIDITY_IN_MILLISECONDS} -#token: -# expire: -# time: ${token.expire.time} #cloud: # aws: # credentials: From 89b3e119532ebd1f5ab2411ce0d7959c2462da5f Mon Sep 17 00:00:00 2001 From: shinheekim Date: Tue, 30 Jul 2024 18:27:17 +0900 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20yml,=20gradle=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 5 +---- src/main/resources/application.yml | 31 ++++++++++++------------------ 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/build.gradle b/build.gradle index addd84b..8c602a6 100644 --- a/build.gradle +++ b/build.gradle @@ -40,10 +40,7 @@ dependencies { implementation 'io.jsonwebtoken:jjwt-api:0.11.5' runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5' runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5' - // jwt - implementation 'io.jsonwebtoken:jjwt-api:0.11.5' - runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5' - runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5' + //aws implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0' diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 0d82115..d0925c2 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -5,7 +5,7 @@ spring: url: ${spring.datasource.url} username: ${spring.datasource.username} password: ${spring.datasource.password} - driver-class-name: ${spring.datasource.driver-class-name} + driver-class-name: com.mysql.cj.jdbc.Driver jpa: database: mysql hibernate: @@ -15,24 +15,17 @@ spring: hibernate: format_sql: false use_sql_comments: true -#logging: -# level: -# org.hibernate.sql: debug -# org.hibernate.type: trace jwt: secret: ${jwt.secret} access-token-validity-in-milliseconds: ${JWT_ACCESS_TOKEN_VALIDITY_IN_MILLISECONDS} -#token: -# expire: -# time: ${token.expire.time} -#cloud: -# aws: -# credentials: -# access-key: ${ACCESS_KEY} -# secret-key: ${S3_SECRET_KEY} -# s3: -# bucket: projectrere -# region: -# static: ap-northeast-2 -# stack: -# auto: false \ No newline at end of file +cloud: + aws: + credentials: + access-key: ${ACCESS_KEY} + secret-key: ${S3_SECRET_KEY} + s3: + bucket: projectrere + region: + static: ap-northeast-2 + stack: + auto: false \ No newline at end of file