Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 학습 참고 링크 추가 #68

Merged
merged 4 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public record InterviewQuestionDetail(
AnswerState answerState,
String question,
String answer,
String referenceLinks,
List<String> referenceLinks,
String feedback,
int score,
int remainTailQuestionCount,
Expand Down Expand Up @@ -71,7 +71,8 @@ public record TailQuestionDetail(
int score,
String question,
String answer,
String feedback
String feedback,
List<String> referenceLinks
) {
public static TailQuestionDetail from(TailQuestionEntity tailQuestion) {
return TailQuestionDetail.builder()
Expand All @@ -81,6 +82,7 @@ public static TailQuestionDetail from(TailQuestionEntity tailQuestion) {
.answer(tailQuestion.getAnswer())
.feedback(tailQuestion.getFeedback())
.score(tailQuestion.getScore())
.referenceLinks(tailQuestion.getReferenceLinks())
.build();

}
Expand Down
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 All @@ -37,6 +46,7 @@ public static AIFeedback from(FeedbackInfo feedbackInfo) {
.feedbackContent(feedbackInfo.aiFeedback())
.score(feedbackInfo.score())
.tailQuestion(feedbackInfo.tailQuestion())
.referenceLinks(feedbackInfo.referenceLinks())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -133,8 +134,8 @@ public AnswerState getAnswerState() {
return answer.getAnswerState();
}

public String getReferenceLinks() {
return "";
public List<String> getReferenceLinks() {
return aiFeedback.getReferenceLinks();
}

public String getFeedback() {
Expand All @@ -148,5 +149,6 @@ public String getAnswer() {
public int getScore() {
return aiFeedback.getScore();
}

}

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 @@ -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;
Expand Down Expand Up @@ -96,4 +97,8 @@ public AnswerState getAnswerState() {
public int getScore() {
return aiFeedback.getScore();
}

public List<String> getReferenceLinks() {
return aiFeedback.getReferenceLinks();
}
}
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();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
alter table interview_items
add column
reference_links varchar(1000);

alter table tail_questions
add column
reference_links varchar(1000);
Loading