diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 03b5a24aa..7b8fc2c15 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -22,6 +22,7 @@ import com.ruoyi.framework.shiro.service.SysPasswordService; import com.ruoyi.framework.util.ShiroUtils; import com.ruoyi.framework.web.base.BaseController; import com.ruoyi.system.domain.SysUser; +import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysPostService; import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysUserService; @@ -45,6 +46,9 @@ public class SysUserController extends BaseController @Autowired private ISysPostService postService; + + @Autowired + private ISysConfigService configService; @Autowired private SysPasswordService passwordService; @@ -85,7 +89,9 @@ public class SysUserController extends BaseController { ExcelUtil util = new ExcelUtil(SysUser.class); List userList = util.importExcel(file.getInputStream()); - String message = userService.importUser(userList, updateSupport); + String operName = getSysUser().getLoginName(); + String password = configService.selectConfigByKey("sys.user.initPassword"); + String message = userService.importUser(userList, updateSupport, operName, password); return AjaxResult.success(message); } diff --git a/ruoyi-admin/src/main/resources/i18n/messages.properties b/ruoyi-admin/src/main/resources/i18n/messages.properties index 56a74fba4..b62fc1c89 100644 --- a/ruoyi-admin/src/main/resources/i18n/messages.properties +++ b/ruoyi-admin/src/main/resources/i18n/messages.properties @@ -6,8 +6,8 @@ user.password.not.match=用户不存在/密码错误 user.password.retry.limit.count=密码输入错误{0}次 user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定10分钟 user.password.delete=对不起,您的账号已被删除 -user.blocked=用户已封禁,原因:{0} -role.blocked=角色已封禁,原因:{0} +user.blocked=用户已封禁,请联系管理员 +role.blocked=角色已封禁,请联系管理员 user.logout.success=退出成功 length.not.valid=长度必须在{min}到{max}个字符之间 diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysLoginService.java index e8f677a81..050153058 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysLoginService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysLoginService.java @@ -96,7 +96,7 @@ public class SysLoginService if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.blocked", user.getRemark()))); - throw new UserBlockedException(user.getRemark()); + throw new UserBlockedException(); } passwordService.validate(user, password); diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/user/RoleBlockedException.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/user/RoleBlockedException.java index 23f571401..ea6d2517a 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/user/RoleBlockedException.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/user/RoleBlockedException.java @@ -9,8 +9,8 @@ public class RoleBlockedException extends UserException { private static final long serialVersionUID = 1L; - public RoleBlockedException(String reason) + public RoleBlockedException() { - super("role.blocked", new Object[] { reason }); + super("role.blocked", null); } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/user/UserBlockedException.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/user/UserBlockedException.java index 855398994..10e2d85bf 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/user/UserBlockedException.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/user/UserBlockedException.java @@ -9,8 +9,8 @@ public class UserBlockedException extends UserException { private static final long serialVersionUID = 1L; - public UserBlockedException(String reason) + public UserBlockedException() { - super("user.blocked", new Object[] { reason }); + super("user.blocked", null); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java index f7742bf6f..802454706 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -144,7 +144,9 @@ public interface ISysUserService * * @param userList 用户数据列表 * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 + * @param operName 操作用户 + * @param password 初始密码 * @return 结果 */ - public String importUser(List userList, Boolean isUpdateSupport); + public String importUser(List userList, Boolean isUpdateSupport, String operName, String password); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 862e3e12a..89d4ebf82 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -10,6 +10,7 @@ import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.support.Convert; +import com.ruoyi.common.utils.Md5Utils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.domain.SysPost; import com.ruoyi.system.domain.SysRole; @@ -363,9 +364,11 @@ public class SysUserServiceImpl implements ISysUserService * * @param userList 用户数据列表 * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 + * @param operName 操作用户 + * @param password 初始密码 * @return 结果 */ - public String importUser(List userList, Boolean isUpdateSupport) + public String importUser(List userList, Boolean isUpdateSupport, String operName, String password) { if (StringUtils.isNull(userList) || userList.size() == 0) { @@ -383,12 +386,15 @@ public class SysUserServiceImpl implements ISysUserService SysUser u = userMapper.selectUserByLoginName(user.getLoginName()); if (StringUtils.isNull(u)) { + user.setPassword(Md5Utils.hash(user.getLoginName() + password)); + user.setCreateBy(operName); this.insertUser(user); successNum++; successMsg.append("
" + successNum + "、账号 " + user.getLoginName() + " 导入成功"); } else if (isUpdateSupport) { + user.setUpdateBy(operName); this.updateUser(user); successNum++; successMsg.append("
" + successNum + "、账号 " + user.getLoginName() + " 更新成功");