diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysUserService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysUserService.java index cafeca6..09f30e8 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysUserService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysUserService.java @@ -238,15 +238,18 @@ public interface ISysUserService * 检查密码是否正确 * @param userId * @param password + * @param needName * @return */ - Boolean checkPassword(Long userId,String password); + Boolean checkPassword(Long userId,String password,Boolean needName); /** * 检查密码是否正确 * @param user * @param password + * @param needName * @return */ - Boolean checkPassword(SysUser user,String password); + Boolean checkPassword(SysUser user,String password,Boolean needName); + } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java index 4f61e8a..fb06e81 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java @@ -581,13 +581,20 @@ public class SysUserServiceImpl implements ISysUserService } @Override - public Boolean checkPassword(Long userId, String password) { - SysUser user = selectUserById(userId); - return checkPassword(user,password); + public Boolean checkPassword(Long userId, String password, Boolean needName) { + SysUser sysUser = selectUserById(userId); + if(sysUser==null){ + throw new ServiceException("用户不存在"); + } + return checkPassword(sysUser,password,needName); } @Override - public Boolean checkPassword(SysUser user, String password) { - return SecurityUtils.matchesPassword(password,user.getPassword()); + public Boolean checkPassword(SysUser user, String password, Boolean needName) { + if(SecurityUtils.matchesPassword(password,user.getPassword())){ + return true; + } + throw new ServiceException((needName?user.getNickName():"")+"密码错误"); } + }