package nju.seec.SEECdemo.web.controller; import nju.seec.SEECdemo.logic.service.assignmentWork.CodeWorkService; import nju.seec.SEECdemo.web.dto.CodeWorkDTO; import nju.seec.SEECdemo.web.response.ResourceResponse; import nju.seec.SEECdemo.web.response.Response; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/api/assignment") public class CodeWorkController { @Autowired private final CodeWorkService codeService; public CodeWorkController(CodeWorkService codeService){ this.codeService = codeService; } @PostMapping("/course/{courseId:\\d+}/code") public Response create(@PathVariable int courseId, @RequestBody @Validated(PostMapping.class) CodeWorkDTO codeWorkDTO){ return new ResourceResponse(codeService.createAssignment(courseId, codeWorkDTO)); } }