From d34a44a1ffa778c0a95027f67d56544b0faa4930 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期六, 25 四月 2026 17:16:01 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_New_pro' into dev_New_pro
---
src/main/java/com/ruoyi/project/system/controller/SysProfileController.java | 69 ++++++++++++++--------------------
1 files changed, 29 insertions(+), 40 deletions(-)
diff --git a/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java b/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java
index 6ae85ab..62f6db5 100644
--- a/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java
+++ b/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java
@@ -1,15 +1,5 @@
package com.ruoyi.project.system.controller;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
-import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
@@ -23,6 +13,11 @@
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.service.ISysUserService;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Map;
/**
* 涓汉淇℃伅 涓氬姟澶勭悊
@@ -31,12 +26,10 @@
*/
@RestController
@RequestMapping("/system/user/profile")
+@AllArgsConstructor
public class SysProfileController extends BaseController
{
- @Autowired
private ISysUserService userService;
-
- @Autowired
private TokenService tokenService;
/**
@@ -61,33 +54,26 @@
public AjaxResult updateProfile(@RequestBody SysUser user)
{
LoginUser loginUser = getLoginUser();
- SysUser sysUser = loginUser.getUser();
- user.setUserName(sysUser.getUserName());
- if (StringUtils.isNotEmpty(user.getPhonenumber())
- && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
+ SysUser currentUser = loginUser.getUser();
+ currentUser.setNickName(user.getNickName());
+ currentUser.setEmail(user.getEmail());
+ currentUser.setPhonenumber(user.getPhonenumber());
+ currentUser.setSex(user.getSex());
+ if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser))
{
- return AjaxResult.error("淇敼鐢ㄦ埛'" + user.getUserName() + "'澶辫触锛屾墜鏈哄彿鐮佸凡瀛樺湪");
+ return error("淇敼鐢ㄦ埛'" + loginUser.getUsername() + "'澶辫触锛屾墜鏈哄彿鐮佸凡瀛樺湪");
}
- if (StringUtils.isNotEmpty(user.getEmail())
- && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
+ if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(currentUser))
{
- return AjaxResult.error("淇敼鐢ㄦ埛'" + user.getUserName() + "'澶辫触锛岄偖绠辫处鍙峰凡瀛樺湪");
+ return error("淇敼鐢ㄦ埛'" + loginUser.getUsername() + "'澶辫触锛岄偖绠辫处鍙峰凡瀛樺湪");
}
- user.setUserId(sysUser.getUserId());
- user.setPassword(null);
- user.setAvatar(null);
- user.setDeptId(null);
- if (userService.updateUserProfile(user) > 0)
+ if (userService.updateUserProfile(currentUser) > 0)
{
// 鏇存柊缂撳瓨鐢ㄦ埛淇℃伅
- sysUser.setNickName(user.getNickName());
- sysUser.setPhonenumber(user.getPhonenumber());
- sysUser.setEmail(user.getEmail());
- sysUser.setSex(user.getSex());
tokenService.setLoginUser(loginUser);
- return AjaxResult.success();
+ return success();
}
- return AjaxResult.error("淇敼涓汉淇℃伅寮傚父锛岃鑱旂郴绠$悊鍛�");
+ return error("淇敼涓汉淇℃伅寮傚父锛岃鑱旂郴绠$悊鍛�");
}
/**
@@ -95,27 +81,30 @@
*/
@Log(title = "涓汉淇℃伅", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
- public AjaxResult updatePwd(String oldPassword, String newPassword)
+ public AjaxResult updatePwd(@RequestBody Map<String, String> params)
{
+ String oldPassword = params.get("oldPassword");
+ String newPassword = params.get("newPassword");
LoginUser loginUser = getLoginUser();
String userName = loginUser.getUsername();
String password = loginUser.getPassword();
if (!SecurityUtils.matchesPassword(oldPassword, password))
{
- return AjaxResult.error("淇敼瀵嗙爜澶辫触锛屾棫瀵嗙爜閿欒");
+ return error("淇敼瀵嗙爜澶辫触锛屾棫瀵嗙爜閿欒");
}
if (SecurityUtils.matchesPassword(newPassword, password))
{
- return AjaxResult.error("鏂板瘑鐮佷笉鑳戒笌鏃у瘑鐮佺浉鍚�");
+ return error("鏂板瘑鐮佷笉鑳戒笌鏃у瘑鐮佺浉鍚�");
}
- if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0)
+ newPassword = SecurityUtils.encryptPassword(newPassword);
+ if (userService.resetUserPwd(userName, newPassword) > 0)
{
// 鏇存柊缂撳瓨鐢ㄦ埛瀵嗙爜
- loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
+ loginUser.getUser().setPassword(newPassword);
tokenService.setLoginUser(loginUser);
- return AjaxResult.success();
+ return success();
}
- return AjaxResult.error("淇敼瀵嗙爜寮傚父锛岃鑱旂郴绠$悊鍛�");
+ return error("淇敼瀵嗙爜寮傚父锛岃鑱旂郴绠$悊鍛�");
}
/**
@@ -139,6 +128,6 @@
return ajax;
}
}
- return AjaxResult.error("涓婁紶鍥剧墖寮傚父锛岃鑱旂郴绠$悊鍛�");
+ return error("涓婁紶鍥剧墖寮傚父锛岃鑱旂郴绠$悊鍛�");
}
}
--
Gitblit v1.9.3