Commit b535a7fc authored by 陈立彬's avatar 陈立彬

增加新接口

parent d6442497
......@@ -275,6 +275,45 @@ public class ExamController {
return ApiResponse.ok("ok");
}
@PostMapping(value = "/run4score_v2")
public ApiResponse<String> run4ScoreV2(@RequestBody Run4ScoreRequestDto requestDto) {
String scene = requestDto.getScene();
Integer tenant = requestDto.getTenant();
String answer = requestDto.getAnswer();
String userAnswer = requestDto.getUserAnswer();
String question = requestDto.getQuestion();
String userId = requestDto.getUserId();
String sessionId = requestDto.getSessionId();
Long questionId = requestDto.getQuestionId();
String redisKey = String.format(EXAM_REDIS_SESSION_KEY, tenant, userId);
SingleQaResult qa = new SingleQaResult();
qa.setUserId(userId);
qa.setSessionId(sessionId);
qa.setUserAnswer(userAnswer);
qa.setQuestion(question);
qa.setAnswer(answer);
qa.setScene(scene);
qa.setQuestionId(questionId);
// 更新之前考试过的题目
ElehSessionQaRecordDo recordDo = qaRecordMapper.selectQaRecord(tenant, sessionId, userId, questionId);
if(Objects.nonNull(recordDo)) {
qaRecordMapper.clearById(recordDo.getId());
}
log.info("PUT V2 REDIS KEY = {}, REDIS VALUE = {}", redisKey, JSONObject.toJSONString(qa));
redisTemplate.opsForValue().set(redisKey, JSONObject.toJSONString(qa), 30, TimeUnit.MINUTES);
examAppFacade.run4Score(scene, sessionId, userId, question, answer, userAnswer);
return ApiResponse.ok("ok");
}
@GetMapping(value = "/get_run4score_info")
public ApiResponse<SingleQaResult> getRun4ScoreInfo(@RequestParam(value = "tenant") Integer tenant,
@RequestParam(value = "user_id") String userId) {
......
package cn.aibreeze.exam.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class Run4ScoreRequestDto implements Serializable {
@JsonProperty("tenant")
private Integer tenant;
@JsonProperty("scene")
private String scene;
@JsonProperty("session_id")
private String sessionId;
@JsonProperty("user_id")
private String userId;
@JsonProperty("question")
private String question;
@JsonProperty("answer")
private String answer;
@JsonProperty("question_id")
private Long questionId;
@JsonProperty("user_answer")
private String userAnswer;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment