|
|
@@ -0,0 +1,83 @@
|
|
|
+package com.zswl.dataservice.controller.user;
|
|
|
+
|
|
|
+import com.zswl.dataservice.model.user.UpdateUserPassWordParam;
|
|
|
+import com.zswl.dataservice.model.user.UserInfoModel;
|
|
|
+import com.zswl.dataservice.model.user.UserUpdateParam;
|
|
|
+import com.zswl.dataservice.service.mqtt.DeviceInfoService;
|
|
|
+import com.zswl.dataservice.service.user.impl.UserManagerServiceImpl;
|
|
|
+import com.zswl.dataservice.service.user.impl.UserServiceImpl;
|
|
|
+import com.zswl.dataservice.utils.result.ResultContent;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.util.Assert;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 用户管理 服务
|
|
|
+ *
|
|
|
+ * @author TRX
|
|
|
+ * @date 2024/3/21
|
|
|
+ */
|
|
|
+@RequestMapping("/user/userManager")
|
|
|
+@RestController
|
|
|
+@Validated
|
|
|
+@Tag(name = "用户管理")
|
|
|
+public class UserManagerController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ DeviceInfoService deviceInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ UserServiceImpl userService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ UserManagerServiceImpl userManagerService;
|
|
|
+
|
|
|
+ @Parameter(in = ParameterIn.HEADER, name = "accessToken", required = false, description = "accessToken")
|
|
|
+ @Operation(summary = "修改当前用户密码", description = "")
|
|
|
+ @RequestMapping(value = "updateUserPassWord", method = {RequestMethod.POST})
|
|
|
+ public ResultContent updateUserPassWord(@RequestBody UpdateUserPassWordParam param) {
|
|
|
+ Assert.hasText(param.getOldPass(), "原密码不能为空");
|
|
|
+ Assert.hasText(param.getPassWord(), "密码不能为空");
|
|
|
+ Assert.hasText(param.getConfirmPass(), "验证密码不能为空");
|
|
|
+ return userService.updateUserPassWord(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Parameter(in = ParameterIn.HEADER, name = "accessToken", required = false, description = "accessToken")
|
|
|
+ @Operation(summary = "得到当前用户信息", description = "")
|
|
|
+ @RequestMapping(value = "getCurrentUserInfo", method = {RequestMethod.GET})
|
|
|
+ public ResultContent<UserInfoModel> getCurrentUserInfo() {
|
|
|
+ return userService.getCurrentUserInfo();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Parameter(in = ParameterIn.HEADER, name = "accessToken", required = false, description = "accessToken")
|
|
|
+ @Operation(summary = "重置用户密码", description = "")
|
|
|
+ @RequestMapping(value = "resetUserPassWord", method = {RequestMethod.GET})
|
|
|
+ public ResultContent<UserInfoModel> resetUserPassWord(
|
|
|
+ @Parameter(name = "id", description = "用户id", example = "")
|
|
|
+ @RequestParam("id") String id) {
|
|
|
+ return userManagerService.resetUserPassWord(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Parameter(in = ParameterIn.HEADER, name = "accessToken", required = false, description = "accessToken")
|
|
|
+ @Operation(summary = "修改当前用户基本信息", description = "")
|
|
|
+ @RequestMapping(value = "updateUserInfo", method = {RequestMethod.POST})
|
|
|
+ public ResultContent<UserInfoModel> updateUserInfo(@RequestBody UserUpdateParam param) {
|
|
|
+ Assert.hasText(param.getUserName(), "userName不能为空");
|
|
|
+ return userService.updateUserInfo(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Parameter(in = ParameterIn.HEADER, name = "accessToken", required = false, description = "accessToken")
|
|
|
+ @Operation(summary = "修改当前用户头像", description = "")
|
|
|
+ @RequestMapping(value = "updateUserHead", method = {RequestMethod.GET})
|
|
|
+ public ResultContent<UserInfoModel> updateUserHead(
|
|
|
+ @Parameter(name = "url", description = "头像地址", example = "")
|
|
|
+ @RequestParam("url") String url) {
|
|
|
+ return userService.updateUserHead(url);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|