|
|
|
|
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.entity.dto.NewProductSurveyStepOneCheckRequest;
|
|
|
|
|
import com.sztzjy.linkCommerce.entity.dto.NewProductSurveyStepOneCheckResult;
|
|
|
|
|
import com.sztzjy.linkCommerce.entity.dto.NewProductSurveyStepTwoValidationRequest;
|
|
|
|
|
import com.sztzjy.linkCommerce.entity.dto.NewProductSurveyStepTwoValidationResult;
|
|
|
|
|
import com.sztzjy.linkCommerce.service.NewProductSurveyStepOneService;
|
|
|
|
|
import com.sztzjy.linkCommerce.service.NewProductSurveyStepTwoService;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private NewProductSurveyStepOneService newProductSurveyStepOneService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private NewProductSurveyStepTwoService newProductSurveyStepTwoService;
|
|
|
|
|
|
|
|
|
|
@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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/new-product-survey/step-1/check")
|
|
|
|
|
@ApiOperation("新产品调查与分析第一步判题")
|
|
|
|
|
public ResultEntity<NewProductSurveyStepOneCheckResult> checkNewProductSurveyStepOne(
|
|
|
|
|
@RequestBody NewProductSurveyStepOneCheckRequest answer, HttpServletRequest request) {
|
|
|
|
|
try {
|
|
|
|
|
JwtUser user = TokenProvider.getJWTUser(request);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "判题完成", newProductSurveyStepOneService.check(answer, user));
|
|
|
|
|
} catch (ServiceException e) {
|
|
|
|
|
return new ResultEntity<>(e.getCode(), e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/new-product-survey/step-2/validate")
|
|
|
|
|
@ApiOperation("新产品调查与分析第二步校验")
|
|
|
|
|
public ResultEntity<NewProductSurveyStepTwoValidationResult> validateNewProductSurveyStepTwo(
|
|
|
|
|
@RequestBody NewProductSurveyStepTwoValidationRequest answer, HttpServletRequest request) {
|
|
|
|
|
try {
|
|
|
|
|
JwtUser user = TokenProvider.getJWTUser(request);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "校验通过", newProductSurveyStepTwoService.validate(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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|