陪练功能联调
This commit is contained in:
@@ -40,6 +40,12 @@ public class TrainingItemController {
|
||||
@Autowired
|
||||
private ITrainingItemService trainingItemService;
|
||||
|
||||
@Autowired
|
||||
private IKnowledgeBaseService knowledgeBaseService;
|
||||
@Autowired
|
||||
private ITrainingMainService trainingMainService;
|
||||
|
||||
|
||||
/**
|
||||
* 新增陪练子表记录
|
||||
*/
|
||||
@@ -210,10 +216,7 @@ public class TrainingItemController {
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
@Autowired
|
||||
private IKnowledgeBaseService knowledgeBaseService;
|
||||
@Autowired
|
||||
private ITrainingMainService trainingMainService;
|
||||
|
||||
|
||||
/**
|
||||
* 按条件不分页查询陪练子表列表
|
||||
@@ -292,6 +295,7 @@ public class TrainingItemController {
|
||||
item.setQuestion(s);
|
||||
item.setParentId(trainingMain.getId());
|
||||
item.setTenantId(trainingMain.getTenantId());
|
||||
item.setStatus("init");
|
||||
trainingItemService.save(item);
|
||||
}
|
||||
}
|
||||
@@ -315,7 +319,7 @@ public class TrainingItemController {
|
||||
/**
|
||||
* 更新陪练子表信息
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
@PostMapping("/traningNext")
|
||||
@Operation(summary = "更新陪练子表信息", description = "更新陪练子表详细信息")
|
||||
public ResponseEntity<Map<String, Object>> updateTrainingItem(
|
||||
@Parameter(description = "陪练子表信息", required = true)
|
||||
@@ -327,17 +331,30 @@ public class TrainingItemController {
|
||||
result.put("message", "陪练子表ID不能为空");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
|
||||
boolean success = trainingItemService.updateById(trainingItem);
|
||||
|
||||
TrainingItem item = new TrainingItem();
|
||||
item.setId(trainingItem.getId());
|
||||
item.setAnswer(trainingItem.getAnswer());
|
||||
item.setStatus("finished");
|
||||
item.setAnswerTime( LocalDateTime.now());
|
||||
boolean success = trainingItemService.updateById(item);
|
||||
|
||||
|
||||
LambdaQueryWrapper<TrainingItem> queryTrainingItemWrapper = new LambdaQueryWrapper<>();
|
||||
queryTrainingItemWrapper.eq(TrainingItem::getParentId, trainingItem.getParentId());
|
||||
queryTrainingItemWrapper.eq(TrainingItem::getStatus, "init");
|
||||
|
||||
// 每次只查询一条记录
|
||||
queryTrainingItemWrapper.last("LIMIT 1");
|
||||
List<TrainingItem> trainingItemList = trainingItemService.list(queryTrainingItemWrapper);
|
||||
|
||||
result.put("data", trainingItemList);
|
||||
if (success) {
|
||||
result.put("success", true);
|
||||
result.put("message", "陪练子表信息更新成功");
|
||||
result.put("data", trainingItem);
|
||||
result.put("message", "成功");
|
||||
return ResponseEntity.ok(result);
|
||||
} else {
|
||||
result.put("success", false);
|
||||
result.put("message", "陪练子表信息更新失败");
|
||||
result.put("message", "失败");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -347,6 +364,45 @@ public class TrainingItemController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新陪练子表信息
|
||||
*/
|
||||
@PostMapping("/traningFinish")
|
||||
@Operation(summary = "更新陪练zhu表信息", description = "更新陪练主表详细信息")
|
||||
public ResponseEntity<Map<String, Object>> traningFinish(
|
||||
@Parameter(description = "陪练主表信息", required = true)
|
||||
@RequestBody TrainingItem trainingItem) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
if (trainingItem.getParentId() == null || trainingItem.getParentId().trim().isEmpty()) {
|
||||
result.put("success", false);
|
||||
result.put("message", "父ID不能为空");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
TrainingMain trainingMain = new TrainingMain();
|
||||
trainingMain.setId(trainingItem.getParentId());
|
||||
trainingMain.setFinishStatus("finished");
|
||||
trainingMain.setEndTime( LocalDateTime.now());
|
||||
boolean success = trainingMainService.updateById(trainingMain);
|
||||
|
||||
if (success) {
|
||||
result.put("success", true);
|
||||
result.put("message", "成功");
|
||||
return ResponseEntity.ok(result);
|
||||
} else {
|
||||
result.put("success", false);
|
||||
result.put("message", "失败");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "更新异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据ID删除陪练子表记录
|
||||
*/
|
||||
|
||||
@@ -41,6 +41,10 @@ public class TrainingItem implements Serializable {
|
||||
@TableField("question")
|
||||
private String question;
|
||||
|
||||
@Schema(description = "状态")
|
||||
@TableField("status")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "题目答案")
|
||||
@TableField("answer")
|
||||
private String answer;
|
||||
@@ -49,9 +53,15 @@ public class TrainingItem implements Serializable {
|
||||
@TableField("ai_answer")
|
||||
private String AiAnswer;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@TableField("answer_time")
|
||||
private LocalDateTime answerTime;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
public void setAnswerTime() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,11 @@ public class TrainingMain implements Serializable {
|
||||
@TableField("end_time")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "结束状态")
|
||||
@TableField("finish_status")
|
||||
private String finishStatus;
|
||||
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
Reference in New Issue
Block a user