|
|
|
package cn.teammodel;
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
import cn.teammodel.dao.EvaluationRepository;
|
|
|
|
import cn.teammodel.dao.StudentRepository;
|
|
|
|
import cn.teammodel.manager.DingAlertNotifier;
|
|
|
|
import cn.teammodel.model.entity.Evaluation;
|
|
|
|
import cn.teammodel.model.entity.EvaluationTreeNode;
|
|
|
|
import cn.teammodel.service.EvaluationService;
|
|
|
|
import cn.teammodel.service.impl.EvaluationServiceImpl;
|
|
|
|
import com.azure.cosmos.models.PartitionKey;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
@SpringBootTest
|
|
|
|
class TeamModelExtensionApplicationTests {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private DingAlertNotifier notifier;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
StudentRepository studentRepository;
|
|
|
|
@Autowired
|
|
|
|
private EvaluationRepository evaluationRepository;
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void contextLoads() {
|
|
|
|
notifier.send("告警: 测试消息推送封装模块");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testCrud() {
|
|
|
|
Evaluation evaluation = new Evaluation();
|
|
|
|
evaluation.setCode("evaluation");
|
|
|
|
evaluation.setPeriodId("default");
|
|
|
|
List<EvaluationTreeNode> nodes = new ArrayList<>();
|
|
|
|
|
|
|
|
// 1
|
|
|
|
String rootId = UUID.randomUUID().toString();
|
|
|
|
EvaluationTreeNode node = new EvaluationTreeNode();
|
|
|
|
node.setId(rootId);
|
|
|
|
node.setPid(null);
|
|
|
|
node.setName("root");
|
|
|
|
node.setScore(0);
|
|
|
|
// 2
|
|
|
|
EvaluationTreeNode node1 = new EvaluationTreeNode();
|
|
|
|
String subId = UUID.randomUUID().toString();
|
|
|
|
node1.setId(subId);
|
|
|
|
node1.setPid(rootId);
|
|
|
|
node1.setName("child-1");
|
|
|
|
node1.setScore(0);
|
|
|
|
// 3
|
|
|
|
EvaluationTreeNode node2 = new EvaluationTreeNode();
|
|
|
|
node2.setId(UUID.randomUUID().toString());
|
|
|
|
node2.setPid(subId);
|
|
|
|
node2.setName("child-2");
|
|
|
|
node2.setScore(0);
|
|
|
|
nodes.add(node);
|
|
|
|
nodes.add(node1);
|
|
|
|
nodes.add(node2);
|
|
|
|
evaluation.setNodes(nodes);
|
|
|
|
|
|
|
|
Evaluation saved = evaluationRepository.save(evaluation);
|
|
|
|
System.out.println(saved);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testSelect() {
|
|
|
|
Evaluation saved = evaluationRepository.findBySchoolId("hbcn", new PartitionKey("evaluation"));
|
|
|
|
EvaluationService service = new EvaluationServiceImpl();
|
|
|
|
System.out.println(JSONUtil.parse(service.buildTree(saved.getNodes())).toStringPretty());
|
|
|
|
}
|
|
|
|
@Test
|
|
|
|
public void testUpdate() {
|
|
|
|
//EvaluationTree saved = evaluationTreeRepository.findBySchoolId("hbcn", new PartitionKey("evaluation"));
|
|
|
|
Evaluation saved = evaluationRepository.findBySchoolId("hbcn", new PartitionKey("evaluation"));
|
|
|
|
EvaluationService service = new EvaluationServiceImpl();
|
|
|
|
System.out.println(JSONUtil.parse(service.buildTree(saved.getNodes())).toStringPretty());
|
|
|
|
evaluationRepository.save(saved);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|