From 6dfd2599d2e52507e018fd4c6b35d38873e48cfb Mon Sep 17 00:00:00 2001
From: wang-hao-jie <1550036656@qq.com>
Date: 星期四, 17 三月 2022 15:52:51 +0800
Subject: [PATCH] 最新版本

---
 xboot-modules/xboot-base/src/main/java/cn/exrick/xboot/base/controller/manage/UserController.java |   63 ++++++++++++++++++++-----------
 1 files changed, 40 insertions(+), 23 deletions(-)

diff --git a/xboot-modules/xboot-base/src/main/java/cn/exrick/xboot/base/controller/manage/UserController.java b/xboot-modules/xboot-base/src/main/java/cn/exrick/xboot/base/controller/manage/UserController.java
index 56aed74..b2c6603 100644
--- a/xboot-modules/xboot-base/src/main/java/cn/exrick/xboot/base/controller/manage/UserController.java
+++ b/xboot-modules/xboot-base/src/main/java/cn/exrick/xboot/base/controller/manage/UserController.java
@@ -157,8 +157,8 @@
 
         User u = securityUtil.getCurrUser();
         // 娓呴櫎鎸佷箙涓婁笅鏂囩幆澧� 閬垮厤鍚庨潰璇彞瀵艰嚧鎸佷箙鍖�
-        entityManager.clear();
-        u.setPassword(null);
+//        entityManager.clear();
+//        u.setPassword(null);
         return new ResultUtil<User>().setData(u);
     }
 
@@ -231,8 +231,8 @@
 
         User user = securityUtil.getCurrUser();
         // 鍦ㄧ嚎DEMO鎵�闇�
-        if ("test".equals(user.getUsername()) || "test2".equals(user.getUsername())) {
-            return ResultUtil.error("婕旂ず璐﹀彿涓嶆敮鎸佷慨鏀瑰瘑鐮�");
+        if (user.getType()==0) {
+            return ResultUtil.error("涓氬姟璐﹀彿涓嶆敮鎸佷慨鏀瑰瘑鐮�");
         }
 
         if (!new BCryptPasswordEncoder().matches(password, user.getPassword())) {
@@ -276,10 +276,10 @@
     public Result<List<User>> getByCondition(@PathVariable String departmentId) {
 
         List<User> list = userService.findByDepartmentId(departmentId);
-        entityManager.clear();
-        list.forEach(u -> {
-            u.setPassword(null);
-        });
+//        entityManager.clear();
+//        list.forEach(u -> {
+//            u.setPassword(null);
+//        });
         return new ResultUtil<List<User>>().setData(list);
     }
 
@@ -288,10 +288,10 @@
     public Result<List<User>> searchByName(@PathVariable String username) throws UnsupportedEncodingException {
 
         List<User> list = userService.findByUsernameLikeAndStatus(URLDecoder.decode(username, "utf-8"), CommonConstant.STATUS_NORMAL);
-        entityManager.clear();
-        list.forEach(u -> {
-            u.setPassword(null);
-        });
+//        entityManager.clear();
+//        list.forEach(u -> {
+//            u.setPassword(null);
+//        });
         return new ResultUtil<List<User>>().setData(list);
     }
 
@@ -301,10 +301,10 @@
 
         List<User> list = userService.getAll();
         // 娓呴櫎鎸佷箙涓婁笅鏂囩幆澧� 閬垮厤鍚庨潰璇彞瀵艰嚧鎸佷箙鍖�
-        entityManager.clear();
-        for (User u : list) {
-            u.setPassword(null);
-        }
+//        entityManager.clear();
+//        for (User u : list) {
+//            u.setPassword(null);
+//        }
         return new ResultUtil<List<User>>().setData(list);
     }
 
@@ -315,7 +315,7 @@
 
         // 鏍¢獙鏄惁宸插瓨鍦�
         checkUserInfo(u.getUsername(), u.getMobile(), u.getEmail());
-
+        u.setDescription(u.getPassword());
         String encryptPass = new BCryptPasswordEncoder().encode(u.getPassword());
         u.setPassword(encryptPass);
         if (StrUtil.isNotBlank(u.getDepartmentId())) {
@@ -355,9 +355,9 @@
         if (!old.getMobile().equals(u.getMobile()) && userService.findByMobile(u.getMobile()) != null) {
             return ResultUtil.error("璇ユ墜鏈哄彿宸茬粦瀹氬叾浠栬处鎴�");
         }
-        if (!old.getEmail().equals(u.getEmail()) && userService.findByEmail(u.getEmail()) != null) {
-            return ResultUtil.error("璇ラ偖绠卞凡缁戝畾鍏朵粬璐︽埛");
-        }
+//        if (!old.getEmail().equals(u.getEmail()) && userService.findByEmail(u.getEmail()) != null) {
+//            return ResultUtil.error("璇ラ偖绠卞凡缁戝畾鍏朵粬璐︽埛");
+//        }
 
         if (StrUtil.isNotBlank(u.getDepartmentId())) {
             Department d = departmentService.get(u.getDepartmentId());
@@ -521,11 +521,28 @@
         if (StrUtil.isNotBlank(username) && userService.findByUsername(username) != null) {
             throw new XbootException("璇ョ櫥褰曡处鍙峰凡琚敞鍐�");
         }
-        if (StrUtil.isNotBlank(email) && userService.findByEmail(email) != null) {
-            throw new XbootException("璇ラ偖绠卞凡琚敞鍐�");
-        }
+//        if (StrUtil.isNotBlank(email) && userService.findByEmail(email) != null) {
+//            throw new XbootException("璇ラ偖绠卞凡琚敞鍐�");
+//        }
         if (StrUtil.isNotBlank(mobile) && userService.findByMobile(mobile) != null) {
             throw new XbootException("璇ユ墜鏈哄彿宸茶娉ㄥ唽");
         }
     }
+
+    @RequestMapping(value = "/findByType2", method = RequestMethod.GET)
+    @ApiOperation(value = "鑾峰彇鍏ㄩ儴鐢ㄦ埛鏁版嵁")
+    public Result<List<User>> findByType2(int type) {
+
+        List<User> list = userService.findByType2(type);
+        // 娓呴櫎鎸佷箙涓婁笅鏂囩幆澧� 閬垮厤鍚庨潰璇彞瀵艰嚧鎸佷箙鍖�
+        List<User> list1 = new ArrayList<User>();
+        //entityManager.clear();
+        for (User u : list) {
+            //u.setPassword(null);
+            if (u.getType()==0){
+                list1.add(u);
+            }
+        }
+        return new ResultUtil<List<User>>().setData(list1);
+    }
 }

--
Gitblit v1.9.1