|
@@ -22,39 +22,40 @@ import java.util.List;
|
|
|
* @date 2019-07-24 23:50
|
|
* @date 2019-07-24 23:50
|
|
|
*/
|
|
*/
|
|
|
@RestController
|
|
@RestController
|
|
|
|
|
+@RequestMapping("/api")
|
|
|
public class UserController {
|
|
public class UserController {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private UserService userService;
|
|
private UserService userService;
|
|
|
|
|
|
|
|
- @RequestMapping(value = "/api/user", method = RequestMethod.POST)
|
|
|
|
|
|
|
+ @RequestMapping(value = "/user", method = RequestMethod.POST)
|
|
|
public UserDTO register(@Validated RegisterCommand registerCommand, BindingResult result) {
|
|
public UserDTO register(@Validated RegisterCommand registerCommand, BindingResult result) {
|
|
|
if (result.hasErrors())
|
|
if (result.hasErrors())
|
|
|
throw new BadRequestException(result.getFieldError().getDefaultMessage());
|
|
throw new BadRequestException(result.getFieldError().getDefaultMessage());
|
|
|
return userService.register(registerCommand);
|
|
return userService.register(registerCommand);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @RequestMapping(value = "/api/user", method = RequestMethod.PUT)
|
|
|
|
|
|
|
+ @RequestMapping(value = "/user", method = RequestMethod.PUT)
|
|
|
public UserDTO updateUser(@Validated UserUpdateCommand command, BindingResult result){
|
|
public UserDTO updateUser(@Validated UserUpdateCommand command, BindingResult result){
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @RequestMapping(value = "/api/user/{userId}", method = RequestMethod.DELETE)
|
|
|
|
|
|
|
+ @RequestMapping(value = "/user/{userId}", method = RequestMethod.DELETE)
|
|
|
public boolean deleteUser(@PathVariable("userId") Long userId){
|
|
public boolean deleteUser(@PathVariable("userId") Long userId){
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @RequestMapping(value = "/api/user/{userId}", method = RequestMethod.GET)
|
|
|
|
|
|
|
+ @RequestMapping(value = "/user/{userId}", method = RequestMethod.GET)
|
|
|
public UserDTO getUser(@PathVariable Long userId){
|
|
public UserDTO getUser(@PathVariable Long userId){
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @RequestMapping(value = "/api/user", method = RequestMethod.GET)
|
|
|
|
|
|
|
+ @RequestMapping(value = "/user", method = RequestMethod.GET)
|
|
|
public List<UserDTO> getUsers(){
|
|
public List<UserDTO> getUsers(){
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @RequestMapping(value = "/api/login", method = RequestMethod.GET)
|
|
|
|
|
|
|
+ @RequestMapping(value = "/login", method = RequestMethod.GET)
|
|
|
public 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())
|
|
if (result.hasErrors())
|
|
|
throw new BadRequestException(result.getFieldError().getDefaultMessage());
|
|
throw new BadRequestException(result.getFieldError().getDefaultMessage());
|