UserController.java 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package com.seecoder.BlueWhale.controller;
  2. import com.seecoder.BlueWhale.service.UserService;
  3. import com.seecoder.BlueWhale.vo.ResultVO;
  4. import com.seecoder.BlueWhale.vo.UserVO;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.web.bind.annotation.*;
  7. @RestController
  8. @RequestMapping("/api/users")
  9. public class UserController {
  10. @Autowired
  11. UserService userService;
  12. @PostMapping("/register")
  13. public ResultVO<Boolean> register(@RequestBody UserVO userVO){
  14. return ResultVO.buildSuccess(userService.register(userVO));
  15. }
  16. @PostMapping("/login")
  17. public ResultVO<String> login(@RequestParam("phone") String phone, @RequestParam("password") String password){
  18. return ResultVO.buildSuccess(userService.login(phone, password));
  19. }
  20. @GetMapping
  21. public ResultVO<UserVO> getInformation(){
  22. return ResultVO.buildSuccess(userService.getInformation());
  23. }
  24. @PostMapping
  25. public ResultVO<Boolean> updateInformation(@RequestBody UserVO userVO){
  26. return ResultVO.buildSuccess(userService.updateInformation(userVO));
  27. }
  28. }