Bläddra i källkod

调整controller接口

Diors.Po 6 år sedan
förälder
incheckning
3a513cfc3f

+ 9 - 0
site/src/main/java/com/mooctest/crowd/site/command/UserUpdateCommand.java

@@ -0,0 +1,9 @@
+package com.mooctest.crowd.site.command;
+
+/**
+ * @author: Diors.Po
+ * @Email: 171256175@qq.com
+ * @date 2019-07-27 11:02
+ */
+public class UserUpdateCommand {
+}

+ 1 - 1
site/src/main/java/com/mooctest/crowd/site/controller/CommonController.java

@@ -1 +1 @@
-package com.mooctest.crowd.site.controller;


import com.mooctest.crowd.site.constants.ResponseConstant;
import com.mooctest.crowd.site.data.ResponseMessage;
import com.mooctest.crowd.site.data.dto.IndexDTO;
import com.mooctest.crowd.site.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: xuexb
 * @Date: 2019.7.22 16:51
 */
@RestController
public class CommonController {

    @Autowired
    private CommonService commonService;

    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public ResponseMessage<IndexDTO> index(){
        return new ResponseMessage<>(ResponseConstant.OK,
                ResponseConstant.REQUEST_SUCCESS,
                commonService.getIndexInfo());
    }

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String hello() {
//        RegisterDService registerDService = new RegisterDService();
//        try {
//            User register = registerDService.register("13657094936", "123456");
//            System.out.println("sdfdsf");
//        } catch (UserNotExistException e) {
//            System.out.println("exist");
//            e.printStackTrace();
//        }
        return "Hello, Spring Boot!";
    }
}
+package com.mooctest.crowd.site.controller;

import com.mooctest.crowd.site.data.dto.IndexDTO;
import com.mooctest.crowd.site.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: xuexb
 * @Date: 2019.7.22 16:51
 */
@RestController
public class CommonController {

    @Autowired
    private CommonService commonService;

    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public IndexDTO index(){
        return commonService.getIndexInfo();
    }

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String hello() {
        return "Hello, Spring Boot!";
    }
}

+ 24 - 4
site/src/main/java/com/mooctest/crowd/site/controller/CrowdProjectController.java

@@ -5,23 +5,43 @@ import com.mooctest.crowd.site.command.ProjectDetailsCommand;
 import com.mooctest.crowd.site.constants.ResponseConstant;
 import com.mooctest.crowd.site.data.ResponseMessage;
 import com.mooctest.crowd.site.data.dto.ProjectDetailsDTO;
+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 java.util.List;
 
 /**
  * @author: Diors.Po
  * @Email: 171256175@qq.com
  * @date 2019-07-24 23:50
  */
+@RestController("/api")
 public class CrowdProjectController {
 
     @RequestMapping(value = "/project", method = RequestMethod.POST)
-    public ResponseMessage<Boolean> createProject(CreateProjectCommand createProjectCommand){
-        return new ResponseMessage<>(ResponseConstant.OK, ResponseConstant.REQUEST_SUCCESS);
+    public Boolean createProject(CreateProjectCommand createProjectCommand){
+        return null;
+    }
+
+    @RequestMapping(value = "/project/{projectId}", method = RequestMethod.GET)
+    public ProjectDetailsDTO getProject(@PathVariable("projectId") Long projectId){
+        return null;
     }
 
     @RequestMapping(value = "/project", method = RequestMethod.GET)
-    public ResponseMessage<ProjectDetailsDTO> getProject(ProjectDetailsCommand projectDetailsCommand){
-        return new ResponseMessage<>(ResponseConstant.OK, ResponseConstant.REQUEST_SUCCESS);
+    public List<ProjectDetailsDTO> getProjects(){
+        return null;
+    }
+
+    @RequestMapping(value = "/project}", method = RequestMethod.PUT)
+    public ProjectDetailsDTO updateProject(ProjectDetailsCommand projectDetailsCommand){
+        return null;
+    }
+
+    @RequestMapping(value = "/project/{projectId}", method = RequestMethod.DELETE)
+    public boolean deleteProject(@PathVariable("projectId") Long projectId){
+        return true;
     }
 }

+ 37 - 0
site/src/main/java/com/mooctest/crowd/site/controller/CrowdReportController.java

@@ -1,9 +1,46 @@
 package com.mooctest.crowd.site.controller;
 
+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 java.util.List;
+
 /**
  * @author: Diors.Po
  * @Email: 171256175@qq.com
  * @date 2019-07-24 23:50
  */
+@RestController("/api")
 public class CrowdReportController {
+
+    @RequestMapping(value = "/report", method = RequestMethod.POST)
+    public ReportDetailsDTO createReport(CrowdTestReportCommand command){
+        return null;
+    }
+
+    @RequestMapping(value = "/report/{reportId}", method = RequestMethod.DELETE)
+    public boolean deleteReport(@PathVariable("reportId")Long reportId){
+        return true;
+    }
+
+    @RequestMapping(value = "/report/{reportId}", method = RequestMethod.GET)
+    public ReportDetailsDTO getReport(@PathVariable("reportId") Long reportId){
+        return null;
+    }
+
+    @RequestMapping(value = "/report", method = RequestMethod.GET)
+    public List<ReportDetailsDTO> getReports(){
+        return null;
+    }
+
+    @RequestMapping(value = "/report", method = RequestMethod.PUT)
+    public ReportDetailsDTO updateReport(CrowdTestReportCommand command){
+        return null;
+    }
+
+
 }

+ 33 - 0
site/src/main/java/com/mooctest/crowd/site/controller/CrowdTaskController.java

@@ -1,9 +1,42 @@
 package com.mooctest.crowd.site.controller;
 
+import com.mooctest.crowd.site.command.CrowdTestTaskCommand;
+import com.mooctest.crowd.site.data.dto.TaskDetailsDTO;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import java.util.List;
+
 /**
  * @author: Diors.Po
  * @Email: 171256175@qq.com
  * @date 2019-07-24 23:50
  */
 public class CrowdTaskController {
+
+    @RequestMapping(value = "/task", method = RequestMethod.POST)
+    public TaskDetailsDTO createTask(CrowdTestTaskCommand command){
+        return null;
+    }
+
+    @RequestMapping(value = "/task/{taskId}", method = RequestMethod.DELETE)
+    public boolean deleteTask(@PathVariable("taskId")Long taskId){
+        return true;
+    }
+
+    @RequestMapping(value = "/task/{taskId}", method = RequestMethod.GET)
+    public TaskDetailsDTO getTask(@PathVariable("taskId") Long taskId){
+        return null;
+    }
+
+    @RequestMapping(value = "/task", method = RequestMethod.GET)
+    public List<TaskDetailsDTO> getTasks(){
+        return null;
+    }
+
+    @RequestMapping(value = "/task", method = RequestMethod.PUT)
+    public TaskDetailsDTO updateTask(CrowdTestTaskCommand command){
+        return null;
+    }
 }

+ 28 - 7
site/src/main/java/com/mooctest/crowd/site/controller/UserController.java

@@ -1,8 +1,6 @@
 package com.mooctest.crowd.site.controller;
 
 import com.mooctest.crowd.site.command.*;
-import com.mooctest.crowd.site.constants.ResponseConstant;
-import com.mooctest.crowd.site.data.ResponseMessage;
 import com.mooctest.crowd.site.data.dto.UserDTO;
 import com.mooctest.crowd.domain.exception.AccountNotExistException;
 import com.mooctest.crowd.domain.exception.BadRequestException;
@@ -11,10 +9,13 @@ import com.mooctest.crowd.site.service.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
 import org.springframework.validation.annotation.Validated;
+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 java.util.List;
+
 /**
  * @author: Diors.Po
  * @Email: 171256175@qq.com
@@ -26,17 +27,37 @@ public class UserController {
     @Autowired
     private UserService userService;
 
-    @RequestMapping(value = "/account", method = RequestMethod.POST)
-    public ResponseMessage<UserDTO> register(@Validated RegisterCommand registerCommand, BindingResult result) throws BadRequestException, AccountNotExistException {
+    @RequestMapping(value = "/api/user", method = RequestMethod.POST)
+    public UserDTO register(@Validated RegisterCommand registerCommand, BindingResult result) {
         if (result.hasErrors())
             throw new BadRequestException(result.getFieldError().getDefaultMessage());
-        return new ResponseMessage<>(ResponseConstant.OK, "注册成功", userService.register(registerCommand));
+        return userService.register(registerCommand);
+    }
+
+    @RequestMapping(value = "/api/user", method = RequestMethod.PUT)
+    public UserDTO updateUser(@Validated UserUpdateCommand command, BindingResult result){
+        return null;
+    }
+
+    @RequestMapping(value = "/api/user/{userId}", method = RequestMethod.DELETE)
+    public boolean deleteUser(@PathVariable("userId") Long userId){
+        return true;
+    }
+
+    @RequestMapping(value = "/api/user/{userId}", method = RequestMethod.GET)
+    public UserDTO getUser(@PathVariable Long userId){
+        return null;
+    }
+
+    @RequestMapping(value = "/api/user", method = RequestMethod.GET)
+    public List<UserDTO> getUsers(){
+        return null;
     }
 
     @RequestMapping(value = "/api/login", method = RequestMethod.GET)
-    public ResponseMessage<UserDTO> loginByMobileAndPwd(@Validated LoginCommand loginCommand, BindingResult result) throws PasswordErrorException, AccountNotExistException, BadRequestException {
+    public UserDTO loginByMobileAndPwd(@Validated LoginCommand loginCommand, BindingResult result) throws PasswordErrorException, AccountNotExistException, BadRequestException {
         if (result.hasErrors())
             throw new BadRequestException(result.getFieldError().getDefaultMessage());
-        return new ResponseMessage<>(ResponseConstant.OK, "登录成功", userService.loginByMobileAndPwd(loginCommand));
+        return userService.loginByMobileAndPwd(loginCommand);
     }
 }

+ 2 - 9
site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java

@@ -19,21 +19,14 @@ public class WebMediatorImpl implements Mediator {
     AccountUTRepo accountUTRepo = new AccountUTRepo();
 
     @Override
-    public UserDTO loginByMobileAndPwd(LoginCommand cmd) throws PasswordErrorException, AccountNotExistException, BadRequestException {
-//        User byMobileNum = accountUTRepo.getByMobileNum(cmd.getMobileNum());
-//        if (account.login(cmd.getMobileNum(),cmd.getPassword())) {
-//            UserVO userVO = new UserVO(account);
-//            return new UserDTO(userVO);
-//        }else
+    public UserDTO loginByMobileAndPwd(LoginCommand cmd) {
+
 //            throw new BadRequestException("登录失败");
         return null;
     }
 
     @Override
     public UserDTO register(RegisterCommand registerCommand) throws AccountNotExistException {
-//        Account account = new RegisterDService().register(registerCommand.getMobileNum(), registerCommand.getPassword());
-//        UserVO userVO = new UserVO(account);
-//        return new UserDTO(userVO);
         return null;
     }