diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1b6d8c2..0bff4d8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,7 +33,7 @@ jobs: echo "PR Description: $commit_message" env="" - module="PromptoLab" + module="" module_type="" version="" skip="" @@ -48,6 +48,10 @@ jobs: skip="${BASH_REMATCH[1]}" fi + if [[ "$commit_message" =~ -m:([^\ ]*) ]]; then + module="${BASH_REMATCH[1]}" + fi + if [[ "$commit_message" =~ -rp:([^\ ]*) ]]; then run_port="${BASH_REMATCH[1]}" fi diff --git a/prompto-lab-app/Dockerfile b/prompto-lab-app/Dockerfile index 0cb490e..da94c87 100644 --- a/prompto-lab-app/Dockerfile +++ b/prompto-lab-app/Dockerfile @@ -1,5 +1,5 @@ FROM adoptopenjdk:11-jre-hotspot -COPY *.jar /rvc-captcha.jar +COPY *.jar /prompto-lab.jar ARG SERVER_PORT ARG ACTIVE @@ -28,6 +28,6 @@ ENV UNIQUE_ID=${UNIQUE_ID} ENV JASYPT_PASSWORD = ${JASYPT_PASSWORD} EXPOSE ${SERVER_PORT} -ENTRYPOINT ["java","-jar","/.jar"] +ENTRYPOINT ["java","-jar","/prompto-lab.jar"] -# -e:test -type:single -m:rvc-captcha -v:1.0.2 -rp:8080 -de:<-e ACTIVE=test -e SERVER_PORT=8080> \ No newline at end of file +# -e:test -type:single -m:prompto-lab -v:1.0.2 -rp:8080 -de:<-e ACTIVE=test -e SERVER_PORT=8080> \ No newline at end of file diff --git a/prompto-lab-app/src/main/java/io/github/timemachinelab/constant/QATypeConstant.java b/prompto-lab-app/src/main/java/io/github/timemachinelab/constant/QATypeConstant.java new file mode 100644 index 0000000..fb9c4e7 --- /dev/null +++ b/prompto-lab-app/src/main/java/io/github/timemachinelab/constant/QATypeConstant.java @@ -0,0 +1,9 @@ +package io.github.timemachinelab.constant; + +public class QATypeConstant { + public static final String FORM_QA = "form"; + public static final String TEXT_QA = "text"; + + + +} diff --git a/prompto-lab-app/src/main/java/io/github/timemachinelab/core/qatree/QaTree.java b/prompto-lab-app/src/main/java/io/github/timemachinelab/core/qatree/QaTree.java index 906e84c..d0d5430 100644 --- a/prompto-lab-app/src/main/java/io/github/timemachinelab/core/qatree/QaTree.java +++ b/prompto-lab-app/src/main/java/io/github/timemachinelab/core/qatree/QaTree.java @@ -1,6 +1,5 @@ package io.github.timemachinelab.core.qatree; -import lombok.Data; import lombok.Getter; import java.util.HashMap; diff --git a/prompto-lab-app/src/main/java/io/github/timemachinelab/core/serializable/JsonNode.java b/prompto-lab-app/src/main/java/io/github/timemachinelab/core/serializable/JsonNode.java new file mode 100644 index 0000000..5d9c518 --- /dev/null +++ b/prompto-lab-app/src/main/java/io/github/timemachinelab/core/serializable/JsonNode.java @@ -0,0 +1,114 @@ +package io.github.timemachinelab.core.serializable; + +import io.github.timemachinelab.core.qatree.*; +import io.github.timemachinelab.core.question.*; +import lombok.Builder; +import lombok.Data; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import com.alibaba.fastjson2.JSONObject; +import com.fasterxml.jackson.core.JsonProcessingException; +import lombok.Getter; + +import java.util.*; + +@Getter +@Builder +public class JsonNode { + String nodeId; + String parentId; + String question; + String answer; + + public static JsonNode Convert2JsonNode(QaTreeNode node, String parentId) { + String question = ""; + String answer = ""; + + BaseQuestion qa = node.getQa(); + if (qa != null) { + question = qa.getQuestion() != null ? qa.getQuestion() : ""; + + // 根据问题类型获取答案 + QuestionType type = QuestionType.fromString(qa.getType()); + switch (type) { + case INPUT: + InputQuestion inputQA = (InputQuestion) qa; + answer = inputQA.getAnswer() != null ? inputQA.getAnswer() : ""; + break; + case SINGLE: + SingleChoiceQuestion singleQA = (SingleChoiceQuestion) qa; + if (singleQA.getAnswer() != null && !singleQA.getAnswer().isEmpty()) { + List answerLabels = new ArrayList<>(); + for (String answerId : singleQA.getAnswer()) { + String label = findOptionLabel(singleQA.getOptions(), answerId); + answerLabels.add(label != null ? label : answerId); + } + answer = String.join(",", answerLabels); + } + break; + case MULTI: + MultipleChoiceQuestion multiQA = (MultipleChoiceQuestion) qa; + if (multiQA.getAnswer() != null && !multiQA.getAnswer().isEmpty()) { + List answerLabels = new ArrayList<>(); + for (String answerId : multiQA.getAnswer()) { + String label = findOptionLabel(multiQA.getOptions(), answerId); + answerLabels.add(label != null ? label : answerId); + } + answer = String.join(",", answerLabels); + } + break; + case FORM: + FormQuestion formQA = (FormQuestion) qa; + // 将FormField转换为TempFormQuestion的JSON格式拼接到question后面 + if (formQA.getFields() != null && !formQA.getFields().isEmpty()) { + List tempQuestions = formQA.getFields().stream() + .map(field -> { + return TempFormQuestion.builder() + .id(field.getId()) + .question(field.getQuestion()) + .type(field.getType()) + .options(field.getOptions()) + .desc(field.getDesc()) + .build(); + }) + .collect(java.util.stream.Collectors.toList()); + String fieldsJson = JSONObject.toJSONString(tempQuestions); + question = question + ":" + fieldsJson; + } + // 将AnswerItem转换为JSON格式作为answer + if (formQA.getAnswer() != null && !formQA.getAnswer().isEmpty()) { + answer = JSONObject.toJSONString(formQA.getAnswer()); + } + break; + default: + break; + } + } + + return JsonNode.builder() + .nodeId(node.getId()) + .parentId(parentId) + .question(question) + .answer(answer) + .build(); + } + + /** + * 根据选项id查找对应的标签 + * @param options 选项列表 + * @param id 选项id + * @return 选项标签,如果未找到则返回null + */ + private static String findOptionLabel(List