Parcourir la source

!90 【轻量级PR】SysUserController remove 解决把自己删除的bug
Merge pull request !90 from dazer007/secerity-fix-remove-self-ok

若依 il y a 4 ans
Parent
commit
04edd66199

+ 5 - 0
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java

@@ -5,6 +5,8 @@ import java.util.List;
5
 import java.util.Set;
5
 import java.util.Set;
6
 import java.util.stream.Collectors;
6
 import java.util.stream.Collectors;
7
 import javax.servlet.http.HttpServletResponse;
7
 import javax.servlet.http.HttpServletResponse;
8
+
9
+import org.apache.commons.lang3.ArrayUtils;
8
 import org.springframework.beans.factory.annotation.Autowired;
10
 import org.springframework.beans.factory.annotation.Autowired;
9
 import org.springframework.validation.annotation.Validated;
11
 import org.springframework.validation.annotation.Validated;
10
 import org.springframework.web.bind.annotation.DeleteMapping;
12
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -217,6 +219,9 @@ public class SysUserController extends BaseController
217
     @DeleteMapping("/{userIds}")
219
     @DeleteMapping("/{userIds}")
218
     public AjaxResult remove(@PathVariable Long[] userIds)
220
     public AjaxResult remove(@PathVariable Long[] userIds)
219
     {
221
     {
222
+        if (ArrayUtils.contains(userIds, SecurityUtils.getUserId())) {
223
+            return AjaxResult.error("当前用户不能删除");
224
+        }
220
         return toAjax(userService.deleteUserByIds(userIds));
225
         return toAjax(userService.deleteUserByIds(userIds));
221
     }
226
     }
222
 
227