|
@@ -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);
|
|
|
}
|
|
|
}
|