diff --git a/backend/src/main/java/in/backend/core/interview/application/InterviewDetail.java b/backend/src/main/java/in/backend/core/interview/application/InterviewDetail.java index e7e0d1a..698464b 100644 --- a/backend/src/main/java/in/backend/core/interview/application/InterviewDetail.java +++ b/backend/src/main/java/in/backend/core/interview/application/InterviewDetail.java @@ -35,7 +35,7 @@ public record InterviewQuestionDetail( AnswerState answerState, String question, String answer, - String referenceLinks, + List referenceLinks, String feedback, int score, int remainTailQuestionCount, @@ -71,7 +71,8 @@ public record TailQuestionDetail( int score, String question, String answer, - String feedback + String feedback, + List referenceLinks ) { public static TailQuestionDetail from(TailQuestionEntity tailQuestion) { return TailQuestionDetail.builder() @@ -81,6 +82,7 @@ public static TailQuestionDetail from(TailQuestionEntity tailQuestion) { .answer(tailQuestion.getAnswer()) .feedback(tailQuestion.getFeedback()) .score(tailQuestion.getScore()) + .referenceLinks(tailQuestion.getReferenceLinks()) .build(); } diff --git a/backend/src/main/java/in/backend/core/interview/application/InterviewSubmitCommand.java b/backend/src/main/java/in/backend/core/interview/application/InterviewSubmitCommand.java index cff7c89..4a8ad14 100644 --- a/backend/src/main/java/in/backend/core/interview/application/InterviewSubmitCommand.java +++ b/backend/src/main/java/in/backend/core/interview/application/InterviewSubmitCommand.java @@ -1,6 +1,7 @@ package in.backend.core.interview.application; import in.backend.core.question.entity.AnswerState; +import java.util.List; import lombok.Builder; @Builder @@ -8,7 +9,6 @@ public record InterviewSubmitCommand( Long interviewId, Long interviewQuestionId, int currentIndex, - AnswerState answerState, FeedbackInfo feedback, AnswerInfo answer @@ -27,6 +27,7 @@ public record AnswerInfo( public record FeedbackInfo( String aiFeedback, String tailQuestion, + List referenceLinks, int score ) { } diff --git a/backend/src/main/java/in/backend/core/interview/entity/AIFeedback.java b/backend/src/main/java/in/backend/core/interview/entity/AIFeedback.java index 16ee726..ab65a37 100644 --- a/backend/src/main/java/in/backend/core/interview/entity/AIFeedback.java +++ b/backend/src/main/java/in/backend/core/interview/entity/AIFeedback.java @@ -2,8 +2,11 @@ import in.backend.core.interview.application.InterviewSubmitCommand.FeedbackInfo; +import in.backend.global.converter.ReferenceLinksConverter; import jakarta.persistence.Column; +import jakarta.persistence.Convert; import jakarta.persistence.Embeddable; +import java.util.List; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -21,11 +24,17 @@ public class AIFeedback { private int score; + @Column(length = 1000) + @Convert(converter = ReferenceLinksConverter.class) + private List referenceLinks; + + @Builder(access = AccessLevel.PROTECTED) - protected AIFeedback(String tailQuestion, String feedbackContent, int score) { + protected AIFeedback(String tailQuestion, String feedbackContent, int score, List referenceLinks) { this.tailQuestion = tailQuestion; this.feedbackContent = feedbackContent; this.score = score; + this.referenceLinks = referenceLinks; } public static AIFeedback empty() { @@ -37,6 +46,7 @@ public static AIFeedback from(FeedbackInfo feedbackInfo) { .feedbackContent(feedbackInfo.aiFeedback()) .score(feedbackInfo.score()) .tailQuestion(feedbackInfo.tailQuestion()) + .referenceLinks(feedbackInfo.referenceLinks()) .build(); } diff --git a/backend/src/main/java/in/backend/core/interview/entity/InterviewQuestionEntity.java b/backend/src/main/java/in/backend/core/interview/entity/InterviewQuestionEntity.java index c485c61..cfc551a 100644 --- a/backend/src/main/java/in/backend/core/interview/entity/InterviewQuestionEntity.java +++ b/backend/src/main/java/in/backend/core/interview/entity/InterviewQuestionEntity.java @@ -14,6 +14,7 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.Table; +import java.util.List; import java.util.Optional; import lombok.AccessLevel; import lombok.Builder; @@ -133,8 +134,8 @@ public AnswerState getAnswerState() { return answer.getAnswerState(); } - public String getReferenceLinks() { - return ""; + public List getReferenceLinks() { + return aiFeedback.getReferenceLinks(); } public String getFeedback() { @@ -148,5 +149,6 @@ public String getAnswer() { public int getScore() { return aiFeedback.getScore(); } + } diff --git a/backend/src/main/java/in/backend/core/interview/presentation/payload/InterviewSubmitRequest.java b/backend/src/main/java/in/backend/core/interview/presentation/payload/InterviewSubmitRequest.java index 396c436..ed7c0f6 100644 --- a/backend/src/main/java/in/backend/core/interview/presentation/payload/InterviewSubmitRequest.java +++ b/backend/src/main/java/in/backend/core/interview/presentation/payload/InterviewSubmitRequest.java @@ -4,6 +4,7 @@ import in.backend.core.interview.application.InterviewSubmitCommand.AnswerInfo; import in.backend.core.interview.application.InterviewSubmitCommand.FeedbackInfo; import in.backend.core.question.entity.AnswerState; +import java.util.List; import lombok.Builder; import lombok.extern.slf4j.Slf4j; @@ -18,13 +19,14 @@ public record InterviewSubmitRequest( String tailQuestion, Integer timeToAnswer, String answerContent, - Integer score + Integer score, + List referenceLinks ) { public InterviewSubmitCommand to() { - log.info("{}", this); var feedback = FeedbackInfo.builder() .aiFeedback(aiFeedback) .tailQuestion(tailQuestion) + .referenceLinks(referenceLinks) .score(score) .build(); diff --git a/backend/src/main/java/in/backend/core/question/entity/TailQuestionEntity.java b/backend/src/main/java/in/backend/core/question/entity/TailQuestionEntity.java index a3ae808..2dfdb87 100644 --- a/backend/src/main/java/in/backend/core/question/entity/TailQuestionEntity.java +++ b/backend/src/main/java/in/backend/core/question/entity/TailQuestionEntity.java @@ -13,6 +13,7 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.Table; +import java.util.List; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -96,4 +97,8 @@ public AnswerState getAnswerState() { public int getScore() { return aiFeedback.getScore(); } + + public List getReferenceLinks() { + return aiFeedback.getReferenceLinks(); + } } diff --git a/backend/src/main/java/in/backend/core/question/presentation/payload/TailQuestionSubmitRequest.java b/backend/src/main/java/in/backend/core/question/presentation/payload/TailQuestionSubmitRequest.java index 460c370..33023fd 100644 --- a/backend/src/main/java/in/backend/core/question/presentation/payload/TailQuestionSubmitRequest.java +++ b/backend/src/main/java/in/backend/core/question/presentation/payload/TailQuestionSubmitRequest.java @@ -5,6 +5,7 @@ import in.backend.core.question.application.TailQuestionSubmitCommand; import in.backend.core.question.entity.AnswerState; import jakarta.validation.constraints.NotNull; +import java.util.List; import lombok.Builder; @Builder @@ -16,15 +17,16 @@ public record TailQuestionSubmitRequest( @NotNull String tailQuestion, @NotNull Integer timeToAnswer, @NotNull String answerContent, - @NotNull Integer score + @NotNull Integer score, + List referenceLinks ) { public TailQuestionSubmitCommand to() { - var feedback = FeedbackInfo.builder() .aiFeedback(aiFeedback) .tailQuestion(tailQuestion) .score(score) + .referenceLinks(referenceLinks) .build(); var answer = AnswerInfo.builder() diff --git a/backend/src/main/java/in/backend/global/converter/ReferenceLinksConverter.java b/backend/src/main/java/in/backend/global/converter/ReferenceLinksConverter.java new file mode 100644 index 0000000..2477ad3 --- /dev/null +++ b/backend/src/main/java/in/backend/global/converter/ReferenceLinksConverter.java @@ -0,0 +1,29 @@ +package in.backend.global.converter; + +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import org.apache.logging.log4j.util.Strings; + +@Converter +public class ReferenceLinksConverter implements AttributeConverter, String> { + + private static final char DELIMITER = ','; + + @Override + public String convertToDatabaseColumn(List strings) { + return Strings.join(strings, DELIMITER); + } + + @Override + public List convertToEntityAttribute(String s) { + if (Objects.isNull(s)) { + return Collections.emptyList(); + } + return Arrays.stream(s.split(",")) + .toList(); + } +} diff --git a/backend/src/main/resources/db/migration/V2__add_reference_links.sql b/backend/src/main/resources/db/migration/V2__add_reference_links.sql new file mode 100644 index 0000000..5e370b6 --- /dev/null +++ b/backend/src/main/resources/db/migration/V2__add_reference_links.sql @@ -0,0 +1,7 @@ +alter table interview_items + add column + reference_links varchar(1000); + +alter table tail_questions + add column + reference_links varchar(1000); \ No newline at end of file