|
@@ -1,13 +1,14 @@
|
|
|
package com.mooctest.crowd.site.controller;
|
|
package com.mooctest.crowd.site.controller;
|
|
|
|
|
|
|
|
|
|
+import com.mooctest.crowd.domain.exception.BaseException;
|
|
|
import com.mooctest.crowd.site.command.CrowdTestTaskCommand;
|
|
import com.mooctest.crowd.site.command.CrowdTestTaskCommand;
|
|
|
import com.mooctest.crowd.site.data.dto.TaskDetailsDTO;
|
|
import com.mooctest.crowd.site.data.dto.TaskDetailsDTO;
|
|
|
import com.mooctest.crowd.site.service.CrowdTaskService;
|
|
import com.mooctest.crowd.site.service.CrowdTaskService;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-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 org.springframework.validation.BindingResult;
|
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
@@ -16,6 +17,7 @@ import java.util.List;
|
|
|
* @Email: 171256175@qq.com
|
|
* @Email: 171256175@qq.com
|
|
|
* @date 2019-07-24 23:50
|
|
* @date 2019-07-24 23:50
|
|
|
*/
|
|
*/
|
|
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/api")
|
|
@RequestMapping("/api")
|
|
|
public class CrowdTaskController {
|
|
public class CrowdTaskController {
|
|
@@ -23,18 +25,22 @@ public class CrowdTaskController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private CrowdTaskService taskService;
|
|
private CrowdTaskService taskService;
|
|
|
|
|
|
|
|
- @RequestMapping(value = "/project/{projectId}/task/{taskCode}", method = RequestMethod.GET)
|
|
|
|
|
- public TaskDetailsDTO getTask(@PathVariable("projectId") Long projectId, @PathVariable("taskCode") String taskCode){
|
|
|
|
|
- return taskService.getTaskDetails(projectId, taskCode);
|
|
|
|
|
|
|
+ @RequestMapping(value = "/project/{projectCode}/task/{taskCode}", method = RequestMethod.GET)
|
|
|
|
|
+ public TaskDetailsDTO getTask(@PathVariable("projectCode") String projectCode, @PathVariable("taskCode") String taskCode){
|
|
|
|
|
+ return taskService.getTaskDetails(projectCode, taskCode);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @RequestMapping(value = "/task", method = RequestMethod.POST)
|
|
|
|
|
- public TaskDetailsDTO createTask(CrowdTestTaskCommand command){
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ @RequestMapping(value = "/project/{projectCode}/task", method = RequestMethod.POST)
|
|
|
|
|
+ public TaskDetailsDTO createTask(@PathVariable("projectCode") String projectCode, @Validated @RequestBody CrowdTestTaskCommand command, BindingResult result){
|
|
|
|
|
+ if (result.hasErrors())
|
|
|
|
|
+ throw new BaseException(result.getFieldError().getDefaultMessage());
|
|
|
|
|
+ else if (!command.isLegal())
|
|
|
|
|
+ throw new BaseException("信息不合法,项目可见性选择存在问题");
|
|
|
|
|
+ return taskService.createTask(projectCode, command);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @RequestMapping(value = "/task/{taskId}", method = RequestMethod.DELETE)
|
|
|
|
|
- public boolean deleteTask(@PathVariable("taskId")Long taskId){
|
|
|
|
|
|
|
+ @RequestMapping(value = "/task/{taskCode}", method = RequestMethod.DELETE)
|
|
|
|
|
+ public boolean deleteTask(@PathVariable("taskCode")String taskCode){
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -43,8 +49,16 @@ public class CrowdTaskController {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @RequestMapping(value = "/task", method = RequestMethod.PUT)
|
|
|
|
|
- public TaskDetailsDTO updateTask(CrowdTestTaskCommand command){
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ @RequestMapping(value = "/project/{projectCode}/task/{taskCode}", method = RequestMethod.PUT)
|
|
|
|
|
+ public TaskDetailsDTO updateTask(@PathVariable("projectCode") String projectCode,
|
|
|
|
|
+ @PathVariable("taskCode") String taskCode,
|
|
|
|
|
+ @Validated @RequestBody CrowdTestTaskCommand command,
|
|
|
|
|
+ BindingResult result){
|
|
|
|
|
+ log.info("修改Task信息");
|
|
|
|
|
+ if (result.hasErrors())
|
|
|
|
|
+ throw new BaseException(result.getFieldError().getDefaultMessage());
|
|
|
|
|
+ else if (!command.isLegal())
|
|
|
|
|
+ throw new BaseException("信息不合法,项目可见性选择存在问题");
|
|
|
|
|
+ return taskService.updateTask(projectCode, taskCode, command);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|