Skip to content

Commit ef1a08d

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 2e19764 + eaa8507 commit ef1a08d

File tree

13 files changed

+235
-0
lines changed

13 files changed

+235
-0
lines changed

.github/workflows/release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,15 @@ jobs:
8383

8484
- name: Build with Maven
8585
if: ${{ env.SKIP != 'image'}}
86+
env:
87+
JASYPT_ALGO: ${{ secrets.JASYPT_ALGO }}
88+
JASYPT_PWD: ${{ secrets.JASYPT_PWD }}
8689
run: |
8790
cd prompto-lab-app
91+
echo "jasypt:" > src/main/resources/you-cant-see-that.yml
92+
echo " encryptor:" >> src/main/resources/you-cant-see-that.yml
93+
echo " algorithm: $JASYPT_ALGO" >> src/main/resources/you-cant-see-that.yml
94+
echo " password: $JASYPT_PWD" >> src/main/resources/you-cant-see-that.yml
8895
mvn package -Dmaven.test.skip=true
8996
9097
- name: Build and Push Docker Images

prompto-lab-app/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,18 @@
123123
<artifactId>fastjson</artifactId>
124124
<version>2.0.57</version>
125125
</dependency>
126+
<dependency>
127+
<groupId>org.projectlombok</groupId>
128+
<artifactId>lombok</artifactId>
129+
<version>1.18.30</version>
130+
<scope>provided</scope>
131+
</dependency>
126132

133+
<dependency>
134+
<groupId>com.github.ulisesbocchio</groupId>
135+
<artifactId>jasypt-spring-boot-starter</artifactId>
136+
<version>3.0.3</version>
137+
</dependency>
127138
</dependencies>
128139
<build>
129140
<plugins>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package io.github.timemachinelab.core.qatree;
2+
3+
import lombok.Data;
4+
5+
@Data
6+
public class CommonQA extends QA {
7+
8+
public CommonQA() {
9+
super(QAType.QA);
10+
}
11+
12+
private String question;
13+
14+
private String answer;
15+
16+
17+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package io.github.timemachinelab.core.qatree;
2+
3+
import lombok.Data;
4+
5+
import java.util.HashMap;
6+
import java.util.Map;
7+
8+
@Data
9+
public class FormQA extends QA {
10+
11+
private String question;
12+
13+
private Map<String, String> answerMap;
14+
15+
public FormQA() {
16+
super(QAType.FORM);
17+
answerMap = new HashMap<>();
18+
}
19+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package io.github.timemachinelab.core.qatree;
2+
3+
import lombok.Data;
4+
5+
@Data
6+
public abstract class QA {
7+
8+
protected final QAType type;
9+
10+
protected long createTime;
11+
12+
protected long updateTime;
13+
14+
public QA(QAType type) {
15+
this.type = type;
16+
this.createTime = System.currentTimeMillis();
17+
this.updateTime = this.createTime;
18+
}
19+
20+
/**
21+
* 更新updateTime为当前时间戳
22+
*/
23+
public void updateTimestamp() {
24+
this.updateTime = System.currentTimeMillis();
25+
}
26+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package io.github.timemachinelab.core.qatree;
2+
3+
public enum QAType {
4+
5+
QA("QA"),
6+
SELECTION("Selection"),
7+
FORM("Form");
8+
9+
private String name;
10+
11+
QAType(String name) {
12+
this.name = name;
13+
}
14+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package io.github.timemachinelab.core.qatree;
2+
3+
import lombok.Data;
4+
import lombok.Getter;
5+
6+
import java.util.HashMap;
7+
import java.util.Map;
8+
9+
public class QaTree {
10+
11+
@Getter
12+
private QaTreeNode root;
13+
14+
private Map<String, QaTreeNode> nodeMap = new HashMap<>();
15+
16+
public QaTree(QaTreeNode root) {
17+
this.root = root;
18+
nodeMap.put(root.getId(), root);
19+
}
20+
21+
public void addNode(String parentId, QaTreeNode node) {
22+
QaTreeNode parent = nodeMap.get(parentId);
23+
if (parent == null) {
24+
return;
25+
}
26+
parent.append(node);
27+
nodeMap.put(node.getId(), node);
28+
}
29+
30+
public QaTreeNode getNodeById(String id) {
31+
return nodeMap.get(id);
32+
}
33+
34+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package io.github.timemachinelab.core.qatree;
2+
3+
import org.springframework.stereotype.Component;
4+
5+
@Component
6+
public class QaTreeDomain {
7+
8+
public QaTree createTree(String userStartQuestion) {
9+
CommonQA startQA = new CommonQA();
10+
startQA.setQuestion(userStartQuestion);
11+
QaTreeNode startNode = new QaTreeNode(startQA);
12+
13+
return new QaTree(startNode);
14+
}
15+
16+
public QaTree appendNode(QaTree tree, String parentId, QA qa) {
17+
tree.addNode(parentId, new QaTreeNode(qa));
18+
return tree;
19+
}
20+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package io.github.timemachinelab.core.qatree;
2+
3+
import lombok.Data;
4+
import java.util.HashMap;
5+
import java.util.Map;
6+
import java.util.UUID;
7+
8+
@Data
9+
public class QaTreeNode {
10+
11+
private final String id;
12+
13+
private Map<String, QaTreeNode> children;
14+
15+
private QA qa;
16+
17+
public QaTreeNode(QA qa) {
18+
this.id = UUID.randomUUID().toString();
19+
this.children = new HashMap<>();
20+
this.qa = qa;
21+
}
22+
23+
public void append(QA qa) {
24+
QaTreeNode node = new QaTreeNode(qa);
25+
this.append(node);
26+
}
27+
28+
public void append(QaTreeNode node) {
29+
children.put(node.getId(), node);
30+
}
31+
32+
public QaTreeNode getChild(String id) {
33+
return children.get(id);
34+
}
35+
36+
public boolean hasChild(String id) {
37+
return children.containsKey(id);
38+
}
39+
40+
public void removeChild(String id) {
41+
children.remove(id);
42+
}
43+
44+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package io.github.timemachinelab.core.qatree;
2+
3+
public class SelectionQA extends QA {
4+
5+
public SelectionQA() {
6+
super(QAType.SELECTION);
7+
}
8+
9+
private String question;
10+
11+
private String[] options;
12+
13+
private Integer selectedOption;
14+
}

0 commit comments

Comments
 (0)