sunhh преди 1 година
родител
ревизия
0966756fdb

+ 3 - 0
hazard-admin/src/main/java/com/ozs/web/controller/app/GeoHazardMineController.java

@@ -111,6 +111,8 @@ public class GeoHazardMineController extends BaseController {
 //        sysUserService.updatePassword(userId, newPwd);
 //        return AjaxResult.success();
         LoginUser loginUser = getLoginUser();
+        String password = user.getPassword();
+        String s = SecurityUtils.encryptPassword(password);
         if (!SecurityUtils.matchesPassword(user.getPassword(), loginUser.getPassword())) {
             return error("修改密码失败,旧密码错误");
         }
@@ -123,6 +125,7 @@ public class GeoHazardMineController extends BaseController {
         }
         user.setPassword(SecurityUtils.encryptPassword(user.getNewPassword()));
         user.setUpdateBy(getUsername());
+        user.setId(getId());
         if (userService.resetPwd(user) > 0) {
             // 更新缓存用户密码
             loginUser.getUser().setPassword(SecurityUtils.encryptPassword(user.getNewPassword()));

+ 24 - 24
hazard-admin/src/main/java/com/ozs/web/controller/system/SysUserController.java

@@ -178,17 +178,17 @@ public class SysUserController extends BaseController {
     @PreAuthorize("@ss.hasPermi('system:user:import')")
     @PostMapping("/importData")
     public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
-        String password=null;
+        String password = null;
         ExcelUtil<SysUsers> util = new ExcelUtil<SysUsers>(SysUsers.class);
         List<SysUsers> userList = util.importExcel(file.getInputStream());
         String userId = getUserId();
         List<SysDictData> data = dictTypeService.selectDictDataByType("default_password");
-        if(!ObjectUtils.isEmpty(data.get(0).getDictValue())){
-            password=data.get(0).getDictValue();
-        }else {
-            password=defaultPassword;
+        if (!ObjectUtils.isEmpty(data.get(0).getDictValue())) {
+            password = data.get(0).getDictValue();
+        } else {
+            password = defaultPassword;
         }
-        String message = userService.importUser(userList, updateSupport, userId,password);
+        String message = userService.importUser(userList, updateSupport, userId, password);
         return success(message);
     }
 
@@ -227,10 +227,10 @@ public class SysUserController extends BaseController {
         if (StringUtils.isNotNull(id)) {
             SysUser sysUser = userService.selectUserById(id);
             ajax.put(AjaxResult.DATA_TAG, sysUser);
-            if (SysUser.isAdmin(id)){
+            if (SysUser.isAdmin(id)) {
                 List<SysRole> roLe = roles.stream().filter(r -> r.getRoleKey().equals("admin")).collect(Collectors.toList());
-                ajax.put("roleIds", roLe.stream().map(SysRole::getRoleId).collect(Collectors.toList())); 
-            }else {
+                ajax.put("roleIds", roLe.stream().map(SysRole::getRoleId).collect(Collectors.toList()));
+            } else {
                 ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
             }
         }
@@ -244,17 +244,17 @@ public class SysUserController extends BaseController {
     @Log(title = "用户管理", businessType = BusinessType.INSERT)
     @PostMapping("/add")
     public AjaxResult add(@Validated @RequestBody SysUser user) {
-        String password=null;
+        String password = null;
         if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user))) {
             return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
         }
         user.setCreateBy(getUserId());
         user.setUpdateBy(getUserId());
         List<SysDictData> data = dictTypeService.selectDictDataByType("default_password");
-        if(!ObjectUtils.isEmpty(data.get(0).getDictValue())){
-            password=data.get(0).getDictValue();
-        }else {
-            password=defaultPassword;
+        if (!ObjectUtils.isEmpty(data.get(0).getDictValue())) {
+            password = data.get(0).getDictValue();
+        } else {
+            password = defaultPassword;
         }
         user.setPassword(SecurityUtils.encryptPassword(password));
         return toAjax(userService.saveUser(user));
@@ -270,7 +270,7 @@ public class SysUserController extends BaseController {
 //        userService.checkUserAllowed(user);
 //        userService.checkUserDataScope(user.getId());
         BaseUser baseUser = baseUserService.getUserById(user.getId());
-        if (baseUser.getUserName().equals("admin")){
+        if (baseUser.getUserName().equals("admin")) {
             return success("admin账号不能修改");
         }
         if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user))) {
@@ -325,7 +325,7 @@ public class SysUserController extends BaseController {
         }
         for (Long id : Ids) {
             BaseUser baseUser = baseUserService.getUserById(id);
-            if (baseUser.getUserName().equals("admin")){
+            if (baseUser.getUserName().equals("admin")) {
                 return success("admin账号不能修改");
             }
         }
@@ -355,14 +355,14 @@ public class SysUserController extends BaseController {
     @Log(title = "用户管理", businessType = BusinessType.UPDATE)
     @GetMapping("/resetPwd/{id}")
     public AjaxResult resetPwd(@PathVariable(value = "id") Long id) {
-        String password=null;
+        String password = null;
         SysUser user = new SysUser();
         user.setId(id);
         List<SysDictData> data = dictTypeService.selectDictDataByType("default_password");
-        if(!ObjectUtils.isEmpty(data.get(0).getDictValue())){
-            password=data.get(0).getDictValue();
-        }else {
-            password=defaultPassword;
+        if (!ObjectUtils.isEmpty(data.get(0).getDictValue())) {
+            password = data.get(0).getDictValue();
+        } else {
+            password = defaultPassword;
         }
         user.setPassword(SecurityUtils.encryptPassword(password));
         user.setUpdateBy(getUsername());
@@ -380,7 +380,7 @@ public class SysUserController extends BaseController {
         if (!SecurityUtils.matchesPassword(user.getPassword(), loginUser.getPassword())) {
             return error("修改密码失败,旧密码错误");
         }
-        boolean matches =user.getNewPassword().matches(PW_PATTERN);
+        boolean matches = user.getNewPassword().matches(PW_PATTERN);
         if (!matches) {
             return error("您的密码太简单!需要包含大小英文、数字、特殊字符、并且长度8-20");
         }
@@ -389,7 +389,7 @@ public class SysUserController extends BaseController {
         }
         user.setPassword(SecurityUtils.encryptPassword(user.getNewPassword()));
         user.setUpdateBy(getUsername());
-        if (userService.resetPwd(user)>0) {
+        if (userService.resetPwd(user) > 0) {
             // 更新缓存用户密码
             loginUser.getUser().setPassword(SecurityUtils.encryptPassword(user.getNewPassword()));
             tokenService.setLoginUser(loginUser);
@@ -456,7 +456,7 @@ public class SysUserController extends BaseController {
     @Log(title = "用户管理", businessType = BusinessType.GRANT)
     public AjaxResult dataPermission(@PathVariable("id") Long id, @PathVariable("dataPermission") Integer dataPermission) {
         BaseUser baseUser = baseUserService.getUserById(id);
-        if (baseUser.getUserName().equals("admin")){
+        if (baseUser.getUserName().equals("admin")) {
             return success("admin账号不能修改");
         }
         if (userService.dataPermission(id, dataPermission)) {