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.
64 lines
2.9 KiB
Java
64 lines
2.9 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.StudentTrainingAnswer;
|
||
|
|
import com.sztzjy.linkCommerce.service.StudentTrainingAnswerService;
|
||
|
|
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.*;
|
||
|
|
|
||
|
|
import javax.servlet.http.HttpServletRequest;
|
||
|
|
|
||
|
|
@Api(tags = "学生实训答案")
|
||
|
|
@RequestMapping("api/student-training-answers")
|
||
|
|
@RestController
|
||
|
|
public class StudentTrainingAnswerController {
|
||
|
|
@Autowired
|
||
|
|
private StudentTrainingAnswerService studentTrainingAnswerService;
|
||
|
|
|
||
|
|
@GetMapping("/{taskKey}")
|
||
|
|
@ApiOperation("查询当前学生指定实训任务答案")
|
||
|
|
public ResultEntity<StudentTrainingAnswer> detail(@PathVariable String taskKey,
|
||
|
|
@RequestParam(required = false) String teachingClassId,
|
||
|
|
HttpServletRequest request) {
|
||
|
|
try {
|
||
|
|
JwtUser user = TokenProvider.getJWTUser(request);
|
||
|
|
return new ResultEntity<>(HttpStatus.OK, "查询成功", studentTrainingAnswerService.get(taskKey, teachingClassId, user));
|
||
|
|
} catch (ServiceException e) {
|
||
|
|
return new ResultEntity<>(e.getCode(), e.getMessage());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@PostMapping("/{taskKey}")
|
||
|
|
@ApiOperation("保存当前学生指定实训任务答案")
|
||
|
|
public ResultEntity<StudentTrainingAnswer> save(@PathVariable String taskKey,
|
||
|
|
@RequestBody StudentTrainingAnswer answer,
|
||
|
|
HttpServletRequest request) {
|
||
|
|
try {
|
||
|
|
JwtUser user = TokenProvider.getJWTUser(request);
|
||
|
|
return new ResultEntity<>(HttpStatus.OK, "保存成功", studentTrainingAnswerService.save(taskKey, answer, user));
|
||
|
|
} catch (ServiceException e) {
|
||
|
|
return new ResultEntity<>(e.getCode(), e.getMessage());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@DeleteMapping("/{taskKey}")
|
||
|
|
@ApiOperation("删除当前学生指定实训任务答案")
|
||
|
|
public ResultEntity delete(@PathVariable String taskKey,
|
||
|
|
@RequestParam(required = false) String teachingClassId,
|
||
|
|
HttpServletRequest request) {
|
||
|
|
try {
|
||
|
|
JwtUser user = TokenProvider.getJWTUser(request);
|
||
|
|
studentTrainingAnswerService.delete(taskKey, teachingClassId, user);
|
||
|
|
return new ResultEntity<>(HttpStatus.OK, "删除成功");
|
||
|
|
} catch (ServiceException e) {
|
||
|
|
return new ResultEntity<>(e.getCode(), e.getMessage());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|