You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.8 KiB
Java
65 lines
2.8 KiB
Java
|
2 months ago
|
package com.sztzjy.linkCommerce.controller.stu;
|
||
|
|
|
||
|
|
import com.sztzjy.linkCommerce.config.exception.handler.ServiceException;
|
||
|
|
import com.sztzjy.linkCommerce.config.security.JwtUser;
|
||
|
|
import com.sztzjy.linkCommerce.config.security.TokenProvider;
|
||
|
|
import com.sztzjy.linkCommerce.entity.dto.AiTrainingEvaluationView;
|
||
|
|
import com.sztzjy.linkCommerce.service.AiTrainingEvaluationService;
|
||
|
|
import com.sztzjy.linkCommerce.util.ResultEntity;
|
||
|
|
import io.swagger.annotations.Api;
|
||
|
|
import io.swagger.annotations.ApiOperation;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.http.HttpStatus;
|
||
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
||
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
||
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
|
||
|
|
import javax.servlet.http.HttpServletRequest;
|
||
|
|
|
||
|
|
@Api(tags = "Student AI training evaluation")
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("api/student/training-tasks/{taskKey}/ai-evaluation")
|
||
|
|
public class AiTrainingEvaluationController {
|
||
|
|
@Autowired
|
||
|
|
protected AiTrainingEvaluationService aiTrainingEvaluationService;
|
||
|
|
|
||
|
|
@GetMapping
|
||
|
|
@ApiOperation("Get the current student's AI training evaluation")
|
||
|
|
public ResultEntity<AiTrainingEvaluationView> get(@PathVariable String taskKey, HttpServletRequest request) {
|
||
|
|
try {
|
||
|
|
return new ResultEntity<>(HttpStatus.OK, "Query succeeded",
|
||
|
|
aiTrainingEvaluationService.get(taskKey, currentUser(request)));
|
||
|
|
} catch (ServiceException e) {
|
||
|
|
return new ResultEntity<>(e.getCode(), e.getMessage());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@PostMapping("/help")
|
||
|
|
@ApiOperation("Generate AI learning help")
|
||
|
|
public ResultEntity<AiTrainingEvaluationView> help(@PathVariable String taskKey, HttpServletRequest request) {
|
||
|
|
try {
|
||
|
|
return new ResultEntity<>(HttpStatus.OK, "AI help generated",
|
||
|
|
aiTrainingEvaluationService.generateHelp(taskKey, currentUser(request)));
|
||
|
|
} catch (ServiceException e) {
|
||
|
|
return new ResultEntity<>(e.getCode(), e.getMessage());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@PostMapping("/assessment")
|
||
|
|
@ApiOperation("Generate AI assessment")
|
||
|
|
public ResultEntity<AiTrainingEvaluationView> assessment(@PathVariable String taskKey, HttpServletRequest request) {
|
||
|
|
try {
|
||
|
|
return new ResultEntity<>(HttpStatus.OK, "AI assessment generated",
|
||
|
|
aiTrainingEvaluationService.generateAssessment(taskKey, currentUser(request)));
|
||
|
|
} catch (ServiceException e) {
|
||
|
|
return new ResultEntity<>(e.getCode(), e.getMessage());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
protected JwtUser currentUser(HttpServletRequest request) {
|
||
|
|
return TokenProvider.getJWTUser(request);
|
||
|
|
}
|
||
|
|
}
|