|
@@ -1,11 +1,15 @@
|
|
|
package com.mooctest.crowd.site.controller;
|
|
|
|
|
|
+import com.mooctest.crowd.domain.domainobject.CrowdTestReport;
|
|
|
+import com.mooctest.crowd.domain.exception.BaseException;
|
|
|
import com.mooctest.crowd.site.command.CrowdTestReportCommand;
|
|
|
import com.mooctest.crowd.site.data.dto.ReportDetailsDTO;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import com.mooctest.crowd.site.service.CrowdReportService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.validation.BindingResult;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
@@ -14,24 +18,60 @@ import java.util.List;
|
|
|
* @Email: 171256175@qq.com
|
|
|
* @date 2019-07-24 23:50
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
|
+@RequestMapping("/api")
|
|
|
public class CrowdReportController {
|
|
|
|
|
|
- @RequestMapping(value = "/api/report", method = RequestMethod.POST)
|
|
|
- public ReportDetailsDTO createReport(CrowdTestReportCommand command){
|
|
|
- return null;
|
|
|
+ @Autowired
|
|
|
+ private CrowdReportService reportService;
|
|
|
+
|
|
|
+ @RequestMapping(value = "/project/{projectCode}/task/{taskCode}/report/{reportCode}", method = RequestMethod.GET)
|
|
|
+ public ReportDetailsDTO getTaskReport(@PathVariable("projectCode") String projectCode,
|
|
|
+ @PathVariable("taskCode") String taskCode,
|
|
|
+ @PathVariable("reportCode") String reportCode){
|
|
|
+ return reportService.getTaskReport(projectCode, taskCode, reportCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/project/{projectCode}/task/{taskCode}/report", method = RequestMethod.POST)
|
|
|
+ public ReportDetailsDTO createTaskReport(@PathVariable("projectCode") String projectCode,
|
|
|
+ @PathVariable("taskCode") String taskCode,
|
|
|
+ @Validated @RequestBody CrowdTestReportCommand command, BindingResult result){
|
|
|
+ log.info("projectCode: " + projectCode + ", taskCode: "+taskCode);
|
|
|
+ if (result.hasErrors())
|
|
|
+ throw new BaseException(result.getFieldError().getDefaultMessage());
|
|
|
+ return reportService.createTaskReport(projectCode, taskCode, command);
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/api/report/{reportId}", method = RequestMethod.DELETE)
|
|
|
- public boolean deleteReport(@PathVariable("reportId")Long reportId){
|
|
|
+ @RequestMapping(value = "/project/{projectCode}/task/{taskCode}/report/{reportCode}", method = RequestMethod.PUT)
|
|
|
+ public ReportDetailsDTO updateTaskReport(@PathVariable("projectCode") String projectCode,
|
|
|
+ @PathVariable("taskCode") String taskCode,
|
|
|
+ @PathVariable("reportCode") String reportCode,
|
|
|
+ @Validated @RequestBody CrowdTestReportCommand command, BindingResult result){
|
|
|
+ return reportService.updateTaskReport(projectCode, taskCode, reportCode, command);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/project/{projectCode}/task/{taskCode}/report/{reportCode}", method = RequestMethod.DELETE)
|
|
|
+ public boolean deleteTaskReport(@PathVariable("reportCode")String reportCode){
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/api/report/{reportId}", method = RequestMethod.GET)
|
|
|
- public ReportDetailsDTO getReport(@PathVariable("reportId") Long reportId){
|
|
|
+
|
|
|
+ @RequestMapping(value = "/project/{projectCode}/report", method = RequestMethod.POST)
|
|
|
+ public ReportDetailsDTO createProjectReport(CrowdTestReportCommand command){
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping(value = "/project/{projectCode}/report/{reportCode}", method = RequestMethod.GET)
|
|
|
+ public ReportDetailsDTO getProjectReport(@PathVariable("projectCode") String projectCode, @PathVariable("reportCode") String reportCode){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/project/{projectCode}/report/{reportCode}", method = RequestMethod.DELETE)
|
|
|
+ public boolean deleteProjectReport(@PathVariable("reportCode")String reportCode){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
@RequestMapping(value = "/api/report", method = RequestMethod.GET)
|
|
|
public List<ReportDetailsDTO> getReports(){
|
|
|
return null;
|