用户导入初始密码

master
RuoYi 6 years ago committed by Limy
parent 90f2573568
commit db507b1624

@ -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<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
List<SysUser> 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);
}

@ -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}个字符之间

@ -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);

@ -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);
}
}

@ -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);
}
}

@ -144,7 +144,9 @@ public interface ISysUserService
*
* @param userList
* @param isUpdateSupport
* @param operName
* @param password
* @return
*/
public String importUser(List<SysUser> userList, Boolean isUpdateSupport);
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName, String password);
}

@ -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<SysUser> userList, Boolean isUpdateSupport)
public String importUser(List<SysUser> 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("<br/>" + successNum + "、账号 " + user.getLoginName() + " 导入成功");
}
else if (isUpdateSupport)
{
user.setUpdateBy(operName);
this.updateUser(user);
successNum++;
successMsg.append("<br/>" + successNum + "、账号 " + user.getLoginName() + " 更新成功");

Loading…
Cancel
Save