From d8a20b19961a4a42df4ae996be8372a14ec3661a Mon Sep 17 00:00:00 2001 From: bbbang105 <2018111366@dgu.ac.kr> Date: Fri, 7 Jun 2024 04:28:07 +0900 Subject: [PATCH 1/4] =?UTF-8?q?#74=20[rename]=20:=20Question=EA=B3=BC=20?= =?UTF-8?q?=EA=B5=AC=EB=B6=84=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../persona/constant/{Question.java => Conversation.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/main/java/kusitms/jangkku/domain/persona/constant/{Question.java => Conversation.java} (98%) diff --git a/src/main/java/kusitms/jangkku/domain/persona/constant/Question.java b/src/main/java/kusitms/jangkku/domain/persona/constant/Conversation.java similarity index 98% rename from src/main/java/kusitms/jangkku/domain/persona/constant/Question.java rename to src/main/java/kusitms/jangkku/domain/persona/constant/Conversation.java index 1ebb861..a152e83 100644 --- a/src/main/java/kusitms/jangkku/domain/persona/constant/Question.java +++ b/src/main/java/kusitms/jangkku/domain/persona/constant/Conversation.java @@ -1,6 +1,6 @@ package kusitms.jangkku.domain.persona.constant; -public enum Question { +public enum Conversation { HEALTH_Q1(1, "건강", """ 안녕 나는 마음의 건강이라는 주제로 너와 대화하며, 너의 건강한 내면을 발견하고 너의 기둥을 찾을 수 있도록 도와주는 셀퍼야. 앞으로 내가 3가지 질문을 할건데, 잘 대답해봐. @@ -62,7 +62,7 @@ public enum Question { private String category; private String content; - Question(int number, String category, String content) { + Conversation(int number, String category, String content) { this.number = number; this.category = category; this.content = content; From 55508e2afb89841ca81f79877cd4c5f752c097aa Mon Sep 17 00:00:00 2001 From: bbbang105 <2018111366@dgu.ac.kr> Date: Fri, 7 Jun 2024 04:28:32 +0900 Subject: [PATCH 2/4] =?UTF-8?q?#74=20[feat]=20:=20=EC=A7=88=EB=AC=B8=20?= =?UTF-8?q?=EB=82=B4=EC=9A=A9=EB=A7=8C=EC=9D=84=20=EB=8B=B4=EC=9D=80=20Enu?= =?UTF-8?q?m=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/persona/constant/Question.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/java/kusitms/jangkku/domain/persona/constant/Question.java diff --git a/src/main/java/kusitms/jangkku/domain/persona/constant/Question.java b/src/main/java/kusitms/jangkku/domain/persona/constant/Question.java new file mode 100644 index 0000000..80f5d09 --- /dev/null +++ b/src/main/java/kusitms/jangkku/domain/persona/constant/Question.java @@ -0,0 +1,39 @@ +package kusitms.jangkku.domain.persona.constant; + +public enum Question { + HEALTH_Q1(1, "건강", "좋아하는 운동이 있어? 그 운동이 왜 좋아?"), + HEALTH_Q2(2, "건강", "너는 평소에 더 행복하게, 건강하게 살기 위해서 남는 시간에 노력하는게 있어?"), + HEALTH_Q3(3, "건강", "마음이 건강하다는 건 어떤 뜻인거 같아? 너가 중요하다고 생각하는 가치(정직, 책임, 인간관계, 명예 등)를 떠올리면서 답변하면 더 좋을 거 같아."), + CAREER_Q1(1, "커리어", "너는 어떤 미래를 그리고 있어? 꼭 직업이 아니여도 되고, 어떤 모습으로 하루하루를 살고 싶은지 말해줘."), + CAREER_Q2(2, "커리어", "삶에서 겪은 성취 중에 가장 큰 성취라면 뭐가 있을까? 혹은 아직 이루지 않은 너의 성취를 말해줘도 좋아."), + CAREER_Q3(3, "커리어", "그러면 그 성취와 유사한 혹은 그 성취를 이루기 위해서는 무엇을 해볼 수 있을까?"), + LOVE_Q1(1, "사랑", "너는 사랑에 이유가 있다고 생각해? 있다면 왜 있는지, 없다면 왜 없다고 생각하는지 말해줘!"), + LOVE_Q2(2, "사랑", "네 인생에서 사랑은 몇순위야? 다른 일이나 인간관계와 사랑을 비교했을때 뭐가 더 먼저라고 생각해?"), + LOVE_Q3(3, "사랑", "너는 사랑을 주는 걸 좋아해 아님 받는걸 좋아해?"), + LEISURE_Q1(1, "여가", "하루에 꼭 하는 습관이나 매일매일 느끼는 소소한 행복이 있어? 정말 소소한 것도 괜찮아."), + LEISURE_Q2(2, "여가", "그러면 지금 너에게 일이나 공부 등 방해요인이 다 사라지고, 너만을 위한 1주일이 생긴다면 뭘 하고 싶어?"), + LEISURE_Q3(3, "여가", "마지막으로, 바쁜 일상 속에서 소소한 행복을 위해 즐기는 것들이 있으면 나에게 소개해줘."); + + private int number; + private String category; + private String content; + + Question(int number, String category, String content) { + this.number = number; + this.category = category; + this.content = content; + + } + + public int getNumber() { + return number; + } + + public String getCategory() { + return category; + } + + public String getContent() { + return content; + } +} \ No newline at end of file From 1490e200c18b50b9fc2120d92d8f888d7482359c Mon Sep 17 00:00:00 2001 From: bbbang105 <2018111366@dgu.ac.kr> Date: Fri, 7 Jun 2024 04:28:56 +0900 Subject: [PATCH 3/4] =?UTF-8?q?#74=20[feat]=20:=20=EB=8B=89=EB=84=A4?= =?UTF-8?q?=EC=9E=84=20=EA=B8=B8=EC=9D=B4=2020=EC=9E=90=20=EC=A0=9C?= =?UTF-8?q?=ED=95=9C=20=EC=97=90=EB=9F=AC=20=EC=B2=98=EB=A6=AC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jangkku/domain/user/application/UserServiceImpl.java | 6 ++++++ .../jangkku/domain/user/exception/UserErrorResult.java | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/kusitms/jangkku/domain/user/application/UserServiceImpl.java b/src/main/java/kusitms/jangkku/domain/user/application/UserServiceImpl.java index cbb5fce..f7c0eb5 100644 --- a/src/main/java/kusitms/jangkku/domain/user/application/UserServiceImpl.java +++ b/src/main/java/kusitms/jangkku/domain/user/application/UserServiceImpl.java @@ -22,6 +22,8 @@ import kusitms.jangkku.domain.user.domain.UserInterest; import kusitms.jangkku.domain.user.dao.UserKeywordRepository; import kusitms.jangkku.domain.user.domain.UserKeyword; +import kusitms.jangkku.domain.user.exception.UserErrorResult; +import kusitms.jangkku.domain.user.exception.UserException; import kusitms.jangkku.global.util.CookieUtil; import kusitms.jangkku.global.util.JwtUtil; import kusitms.jangkku.global.util.S3Util; @@ -68,6 +70,10 @@ public UserDto.UserRegisterResponse registerUser(HttpServletResponse response, S String providerId = jwtUtil.getProviderIdFromToken(registerToken); String name = jwtUtil.getNameFromToken(registerToken); + if (userRegisterRequest.getNickname().length() > 20) { + throw new UserException(UserErrorResult.NICKNAME_TOO_LONG); + } + log.info("유저 등록을 진행합니다."); User user = User.builder() diff --git a/src/main/java/kusitms/jangkku/domain/user/exception/UserErrorResult.java b/src/main/java/kusitms/jangkku/domain/user/exception/UserErrorResult.java index e61c71f..f697368 100644 --- a/src/main/java/kusitms/jangkku/domain/user/exception/UserErrorResult.java +++ b/src/main/java/kusitms/jangkku/domain/user/exception/UserErrorResult.java @@ -11,7 +11,8 @@ @RequiredArgsConstructor public enum UserErrorResult implements BaseErrorCode { NOT_FOUND_USER(HttpStatus.NOT_FOUND, "404", "존재하지 않는 유저입니다."), - IS_DUPLICATE_NICKNAME(HttpStatus.CONFLICT, "409", "중복된 닉네임이 존재합니다."); + IS_DUPLICATE_NICKNAME(HttpStatus.CONFLICT, "409", "중복된 닉네임이 존재합니다."), + NICKNAME_TOO_LONG(HttpStatus.CONFLICT, "409", "닉네임은 20자를 넘을 수 없습니다."); private final HttpStatus httpStatus; private final String code; From cdb27b5f01053f466f7f397c00ee06af84859b3f Mon Sep 17 00:00:00 2001 From: bbbang105 <2018111366@dgu.ac.kr> Date: Fri, 7 Jun 2024 04:29:30 +0900 Subject: [PATCH 4/4] =?UTF-8?q?#74=20[refactor]=20:=20=EB=8B=B5=EB=B3=80?= =?UTF-8?q?=20=EC=9A=94=EC=95=BD=20=EB=82=B4=EC=97=AD=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=20=EC=8B=9C,=20=EC=A7=88=EB=AC=B8=EB=8F=84=20=ED=8F=AC?= =?UTF-8?q?=ED=95=A8=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DiscoverPersonaServiceImpl.java | 35 +++++++++++++------ .../domain/DiscoverPersonaChatting.java | 12 ++++--- .../persona/dto/DiscoverPersonaDto.java | 28 ++++++++++++--- 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/src/main/java/kusitms/jangkku/domain/persona/application/DiscoverPersonaServiceImpl.java b/src/main/java/kusitms/jangkku/domain/persona/application/DiscoverPersonaServiceImpl.java index 4e5ffc0..ec8eec2 100644 --- a/src/main/java/kusitms/jangkku/domain/persona/application/DiscoverPersonaServiceImpl.java +++ b/src/main/java/kusitms/jangkku/domain/persona/application/DiscoverPersonaServiceImpl.java @@ -2,6 +2,7 @@ import jakarta.transaction.Transactional; import kusitms.jangkku.domain.clova.application.ClovaService; +import kusitms.jangkku.domain.persona.constant.Conversation; import kusitms.jangkku.domain.persona.constant.Question; import kusitms.jangkku.domain.persona.dao.DiscoverPersonaChattingRepository; import kusitms.jangkku.domain.persona.dao.DiscoverPersonaKeywordRepository; @@ -59,11 +60,12 @@ public DiscoverPersonaDto.QuestionResponse getNewQuestion(String authorizationHe discoverPersona.updateComplete(true); // 완료 처리 discoverPersonaRepository.save(discoverPersona); } - String newQuestionContent = getQuestionContent(category, newQuestionNumber); + String newQuestionContent = getConversation(category, newQuestionNumber); DiscoverPersonaChatting newDiscoverPersonaChatting = DiscoverPersonaChatting.builder() .discoverPersona(discoverPersona) .questionNumber(newQuestionNumber) + .question(getQuestion(category, newQuestionNumber)) .build(); discoverPersonaChattingRepository.save(newDiscoverPersonaChatting); @@ -84,7 +86,7 @@ public DiscoverPersonaDto.AnswerResponse getReactionAndSummary(String authorizat // 마지막 대화인 경우 마무리 멘트 추가 if (discoverPersona.getIsComplete()) { String category = discoverPersona.getCategory(); - String finalComment = getQuestionContent(category, 0); + String finalComment = getConversation(category, 0); reaction += finalComment; } String summary = clovaService.createDiscoverPersonaSummary(answerRequest.getAnswer()); @@ -142,10 +144,10 @@ public DiscoverPersonaDto.SummaryResponse getSummaries(String authorizationHeade DiscoverPersona loveDiscoverPersona = getDiscoverPersona(user, "사랑"); DiscoverPersona leisureDiscoverPersona = getDiscoverPersona(user, "여가"); - List healthSummaries = createSummaries(healthDiscoverPersona); - List careerSummaries = createSummaries(careerDiscoverPersona); - List loveSummaries = createSummaries(loveDiscoverPersona); - List leisureSummaries = createSummaries(leisureDiscoverPersona); + List healthSummaries = createSummaries(healthDiscoverPersona); + List careerSummaries = createSummaries(careerDiscoverPersona); + List loveSummaries = createSummaries(loveDiscoverPersona); + List leisureSummaries = createSummaries(leisureDiscoverPersona); return DiscoverPersonaDto.SummaryResponse.of(healthSummaries, careerSummaries, loveSummaries, leisureSummaries); } @@ -257,8 +259,19 @@ private int createNewQuestionNumber(List questionNumbers) { return randomQuestionNumber; } */ + // Enum에서 대화 내용을 가져오는 메서드 + private String getConversation(String category, int number) { + for (Conversation conversation : Conversation.values()) { + if (conversation.getCategory().equals(category) && conversation.getNumber() == number) { + return conversation.getContent(); + } + } + + throw new PersonaException(PersonaErrorResult.NOT_FOUND_QUESTION); + } + // Enum에서 질문 내용을 가져오는 메서드 - private String getQuestionContent(String category, int number) { + private String getQuestion(String category, int number) { for (Question question : Question.values()) { if (question.getCategory().equals(category) && question.getNumber() == number) { return question.getContent(); @@ -272,18 +285,18 @@ private String getQuestionContent(String category, int number) { private List createStageQuestions(String category, List chattings) { List stageQuestions = new ArrayList<>(); for (DiscoverPersonaChatting discoverPersonaChatting : chattings) { - stageQuestions.add(getQuestionContent(category, discoverPersonaChatting.getQuestionNumber())); + stageQuestions.add(getConversation(category, discoverPersonaChatting.getQuestionNumber())); } return stageQuestions; } // 답변 요약 목록을 반환하는 메서드 - protected List createSummaries(DiscoverPersona discoverPersona) { + protected List createSummaries(DiscoverPersona discoverPersona) { List chattings = discoverPersonaChattingRepository.findAllByDiscoverPersonaOrderByCreatedDateAsc(discoverPersona); - List summaries = new ArrayList<>(); + List summaries = new ArrayList<>(); for (DiscoverPersonaChatting discoverPersonaChatting : chattings) { - summaries.add(discoverPersonaChatting.getSummary()); + summaries.add(DiscoverPersonaDto.QnA.of(discoverPersonaChatting)); } return summaries; diff --git a/src/main/java/kusitms/jangkku/domain/persona/domain/DiscoverPersonaChatting.java b/src/main/java/kusitms/jangkku/domain/persona/domain/DiscoverPersonaChatting.java index d832433..d04098d 100644 --- a/src/main/java/kusitms/jangkku/domain/persona/domain/DiscoverPersonaChatting.java +++ b/src/main/java/kusitms/jangkku/domain/persona/domain/DiscoverPersonaChatting.java @@ -19,19 +19,23 @@ public class DiscoverPersonaChatting extends BaseEntity { @Column(name = "question_number", nullable = false) private int questionNumber; - @Column(name = "answer") + @Column(name = "question", columnDefinition = "TEXT") + private String question; + + @Column(name = "answer", columnDefinition = "TEXT") private String answer; - @Column(name = "reaction") + @Column(name = "reaction", columnDefinition = "TEXT") private String reaction; - @Column(name = "summary") + @Column(name = "summary", columnDefinition = "TEXT") private String summary; @Builder - public DiscoverPersonaChatting(DiscoverPersona discoverPersona, int questionNumber, String answer, String reaction, String summary) { + public DiscoverPersonaChatting(DiscoverPersona discoverPersona, int questionNumber, String question, String answer, String reaction, String summary) { this.discoverPersona = discoverPersona; this.questionNumber = questionNumber; + this.question = question; this.answer = answer; this.reaction = reaction; this.summary = summary; diff --git a/src/main/java/kusitms/jangkku/domain/persona/dto/DiscoverPersonaDto.java b/src/main/java/kusitms/jangkku/domain/persona/dto/DiscoverPersonaDto.java index b509840..5961c66 100644 --- a/src/main/java/kusitms/jangkku/domain/persona/dto/DiscoverPersonaDto.java +++ b/src/main/java/kusitms/jangkku/domain/persona/dto/DiscoverPersonaDto.java @@ -111,12 +111,12 @@ public static DiscoverPersonaDto.Stage of(String question, String answer, String @JsonNaming(value = PropertyNamingStrategies.SnakeCaseStrategy.class) @JsonInclude(JsonInclude.Include.NON_NULL) public static class SummaryResponse { - private List health; - private List career; - private List love; - private List leisure; + private List health; + private List career; + private List love; + private List leisure; - public static DiscoverPersonaDto.SummaryResponse of(List healthSummaries, List careerSummaries, List loveSummaries, List leisureSummaries) { + public static DiscoverPersonaDto.SummaryResponse of(List healthSummaries, List careerSummaries, List loveSummaries, List leisureSummaries) { return SummaryResponse.builder() .health(healthSummaries) .career(careerSummaries) @@ -126,6 +126,24 @@ public static DiscoverPersonaDto.SummaryResponse of(List healthSummaries } } + @Builder + @Getter + @NoArgsConstructor + @AllArgsConstructor + @JsonNaming(value = PropertyNamingStrategies.SnakeCaseStrategy.class) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class QnA { + private String question; + private String answer; + + public static DiscoverPersonaDto.QnA of(DiscoverPersonaChatting discoverPersonaChatting) { + return QnA.builder() + .question(discoverPersonaChatting.getQuestion()) + .answer(discoverPersonaChatting.getSummary()) + .build(); + } + } + @Builder @Getter @NoArgsConstructor