Преглед изворни кода

新增平台管理端重置用户密码接口及按钮权限SQL

qmj пре 3 дана
родитељ
комит
d51a6d08d3

+ 27 - 0
ruoyi-admin/src/main/java/com/ruoyi/app/user/InfoUserController.java

@@ -39,6 +39,7 @@ import com.ruoyi.system.utils.Auth;
 import com.ruoyi.system.utils.AuthContext;
 import com.ruoyi.system.utils.JwtUtil;
 import com.ruoyi.system.utils.MobileSMS;
+import com.ruoyi.app.user.dto.InfoUserResetPwdDto;
 import com.ruoyi.app.user.dto.OAuthBindDto;
 import com.ruoyi.app.user.dto.OAuthDeviceConfirmDto;
 import com.ruoyi.app.user.dto.OAuthLoginDto;
@@ -1658,6 +1659,32 @@ public class InfoUserController extends BaseController {
         return toAjax(infoUserService.updateInfoUser(infoUser));
     }
 
+    /**
+     * 重置用户登录密码(独立于通用编辑,密文入库,与 App 端 RSA 公钥体系一致)
+     */
+    @PreAuthorize("@ss.hasPermi('infouser:user:resetPwd')")
+    @Log(title = "用户信息", businessType = BusinessType.UPDATE)
+    @PutMapping("/resetPwd")
+    public AjaxResult resetPwd(@RequestBody InfoUserResetPwdDto resetPwdDto) {
+        if (resetPwdDto.getUserId() == null) {
+            return error(MessageUtils.message("no.user.not.exist"));
+        }
+        if (resetPwdDto.getPassword() == null || resetPwdDto.getPassword().isEmpty()) {
+            return error(MessageUtils.message("no.user.password.not.null"));
+        }
+        InfoUser user = infoUserService.selectInfoUserByUserId(resetPwdDto.getUserId());
+        if (user == null) {
+            return error(MessageUtils.message("no.user.not.exist"));
+        }
+        if (MerchantAccountConstants.SUBACCOUNT_USER_TYPE.equals(user.getUserType())) {
+            return error(MessageUtils.message("merchant.subaccount.platform.managed"));
+        }
+        boolean updated = infoUserService.update(new LambdaUpdateWrapper<InfoUser>()
+                .eq(InfoUser::getUserId, user.getUserId())
+                .set(InfoUser::getPassword, resetPwdDto.getPassword()));
+        return updated ? success() : error(MessageUtils.message("no.system.error"));
+    }
+
     private boolean normalizeAuditRejectReason(InfoUser infoUser) {
         if (!"2".equals(infoUser.getAuditStatus())) {
             infoUser.setAuditRejectReason(null);

+ 12 - 0
ruoyi-admin/src/main/java/com/ruoyi/app/user/dto/InfoUserResetPwdDto.java

@@ -0,0 +1,12 @@
+package com.ruoyi.app.user.dto;
+
+import lombok.Data;
+
+/**
+ * 平台管理端重置用户登录密码请求;password 为前端 RSA 公钥加密后的密文,原样入库
+ */
+@Data
+public class InfoUserResetPwdDto {
+    private Long userId;
+    private String password;
+}

+ 12 - 0
updatesql/sql.md

@@ -2157,3 +2157,15 @@ ALTER TABLE stall_qualification_application
   ADD COLUMN director_screenshot_image_urls TEXT NULL COMMENT '选填董监事资料截图JSON数组' AFTER business_registration_image_urls,
   ADD COLUMN ubo_declaration_image_urls TEXT NULL COMMENT '选填实质受益人声明图片JSON数组' AFTER director_screenshot_image_urls;
 ```
+
+
+## 2026-10-16 平台管理端独立重置用户登录密码
+
+> 仅登记,未执行。为骑手/商家/夜市管理页新增"重置密码"按钮权限;执行后需在角色管理中为相应角色勾选该按钮,按钮才会显示。
+
+```sql
+-- 用户信息管理菜单下新增重置密码按钮(与 infouser:user:edit 按钮同级)
+SET @infouserMenuId = (SELECT parent_id FROM sys_menu WHERE perms = 'infouser:user:edit' LIMIT 1);
+INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, menu_type, visible, status, perms, icon, create_by, create_time)
+VALUES ('用户重置密码', @infouserMenuId, 9, '#', '', 'F', '0', '0', 'infouser:user:resetPwd', '#', 'admin', NOW());
+```