Skip to content

Commit

Permalink
refactor: 참고 링크를 반환하는 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
JaeHongDev committed Jul 8, 2024
1 parent 54bb7c0 commit 3d76018
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package in.backend.core.interview.application;

import in.backend.core.question.entity.AnswerState;
import java.util.List;
import lombok.Builder;

@Builder
public record InterviewSubmitCommand(
Long interviewId,
Long interviewQuestionId,
int currentIndex,

AnswerState answerState,
FeedbackInfo feedback,
AnswerInfo answer
Expand All @@ -27,6 +27,7 @@ public record AnswerInfo(
public record FeedbackInfo(
String aiFeedback,
String tailQuestion,
List<String> referenceLinks,
int score
) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,11 +24,17 @@ public class AIFeedback {

private int score;

@Column(length = 1000)
@Convert(converter = ReferenceLinksConverter.class)
private List<String> referenceLinks;


@Builder(access = AccessLevel.PROTECTED)
protected AIFeedback(String tailQuestion, String feedbackContent, int score) {
protected AIFeedback(String tailQuestion, String feedbackContent, int score, List<String> referenceLinks) {
this.tailQuestion = tailQuestion;
this.feedbackContent = feedbackContent;
this.score = score;
this.referenceLinks = referenceLinks;
}

public static AIFeedback empty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -18,13 +19,14 @@ public record InterviewSubmitRequest(
String tailQuestion,
Integer timeToAnswer,
String answerContent,
Integer score
Integer score,
List<String> referenceLinks
) {
public InterviewSubmitCommand to() {
log.info("{}", this);
var feedback = FeedbackInfo.builder()
.aiFeedback(aiFeedback)
.tailQuestion(tailQuestion)
.referenceLinks(referenceLinks)
.score(score)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,15 +17,16 @@ public record TailQuestionSubmitRequest(
@NotNull String tailQuestion,
@NotNull Integer timeToAnswer,
@NotNull String answerContent,
@NotNull Integer score
@NotNull Integer score,
List<String> referenceLinks

) {
public TailQuestionSubmitCommand to() {

var feedback = FeedbackInfo.builder()
.aiFeedback(aiFeedback)
.tailQuestion(tailQuestion)
.score(score)
.referenceLinks(referenceLinks)
.build();

var answer = AnswerInfo.builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -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<List<String>, String> {

private static final char DELIMITER = ',';

@Override
public String convertToDatabaseColumn(List<String> strings) {
return Strings.join(strings, DELIMITER);
}

@Override
public List<String> convertToEntityAttribute(String s) {
if (Objects.isNull(s)) {
return Collections.emptyList();
}
return Arrays.stream(s.split(","))
.toList();
}
}

0 comments on commit 3d76018

Please sign in to comment.