|
@@ -0,0 +1,57 @@
|
|
|
|
|
+package seecoder.devcloud.web.controller.user;
|
|
|
|
|
+
|
|
|
|
|
+import jnr.ffi.annotations.In;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+import seecoder.devcloud.web.service.user.UserService;
|
|
|
|
|
+import seecoder.devcloud.web.vo.Response;
|
|
|
|
|
+import seecoder.devcloud.web.vo.user.ChangePasswordVO;
|
|
|
|
|
+import seecoder.devcloud.web.vo.user.RegisterVO;
|
|
|
|
|
+import seecoder.devcloud.web.vo.user.UserVO;
|
|
|
|
|
+
|
|
|
|
|
+import javax.validation.Validation;
|
|
|
|
|
+import javax.validation.constraints.Pattern;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @author PuHong Weng
|
|
|
|
|
+ * @date 2021/3/5
|
|
|
|
|
+ * @description:
|
|
|
|
|
+ */
|
|
|
|
|
+@RestController("/user")
|
|
|
|
|
+@ResponseBody
|
|
|
|
|
+public class UserController {
|
|
|
|
|
+
|
|
|
|
|
+ private final UserService userService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ public UserController(UserService userService) {
|
|
|
|
|
+ this.userService = userService;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/register")
|
|
|
|
|
+ public Response<UserVO> register(@RequestBody RegisterVO registerVO){
|
|
|
|
|
+ return Response.ok(userService.register(registerVO)) ;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PutMapping("/password")
|
|
|
|
|
+ public Response changePassword(@RequestBody ChangePasswordVO vo){
|
|
|
|
|
+ userService.changePassword(vo);
|
|
|
|
|
+ return Response.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PutMapping("nickname")
|
|
|
|
|
+ public Response<UserVO> changeUserInfo(
|
|
|
|
|
+ @RequestParam("userId") Integer userid,
|
|
|
|
|
+ @RequestParam("nickname")
|
|
|
|
|
+ @Pattern(regexp = "^\\w+${4,23}", message = "昵称只能包含大小写字母、数字和下划线,且必须为4-23位!")
|
|
|
|
|
+ String nickName) {
|
|
|
|
|
+ return userService.changeUserInfo(userid, nickName);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/id")
|
|
|
|
|
+ public Response<UserVO> findUserById(
|
|
|
|
|
+ @RequestParam("userId") Integer userId){
|
|
|
|
|
+ return Response.ok(userService.getUserById(userId));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|