CodeWorkController.java 966 B

123456789101112131415161718192021222324252627
  1. package nju.seec.SEECdemo.web.controller;
  2. import nju.seec.SEECdemo.logic.service.assignmentWork.CodeWorkService;
  3. import nju.seec.SEECdemo.web.dto.CodeWorkDTO;
  4. import nju.seec.SEECdemo.web.response.ResourceResponse;
  5. import nju.seec.SEECdemo.web.response.Response;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.validation.annotation.Validated;
  8. import org.springframework.web.bind.annotation.*;
  9. @RestController
  10. @RequestMapping("/api/assignment")
  11. public class CodeWorkController {
  12. @Autowired
  13. private final CodeWorkService codeService;
  14. public CodeWorkController(CodeWorkService codeService){
  15. this.codeService = codeService;
  16. }
  17. @PostMapping("/course/{courseId:\\d+}/code")
  18. public Response create(@PathVariable int courseId, @RequestBody @Validated(PostMapping.class) CodeWorkDTO codeWorkDTO){
  19. return new ResourceResponse(codeService.createAssignment(courseId, codeWorkDTO));
  20. }
  21. }