|
@@ -20,6 +20,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import sun.misc.BASE64Encoder;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -101,7 +102,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
throw ExceptionResultEnum.ERROR.exception("用户名已存在");
|
|
throw ExceptionResultEnum.ERROR.exception("用户名已存在");
|
|
}
|
|
}
|
|
SysConfig sysConfig = sysConfigService.getByKey("sys.user.initPassword");
|
|
SysConfig sysConfig = sysConfigService.getByKey("sys.user.initPassword");
|
|
- user.setPassword(Md5Utils.toMd5Hex(StringUtils.isNoneBlank(sysConfig.getConfigValue()) ? sysConfig.getConfigValue() : "123456"));
|
|
|
|
|
|
+ BASE64Encoder encoder = new BASE64Encoder();
|
|
|
|
+ user.setPassword(encoder.encode(StringUtils.isNoneBlank(sysConfig.getConfigValue()) ? sysConfig.getConfigValue().getBytes() : "123456".getBytes()));
|
|
user.setId(SystemConstant.getDbUuid());
|
|
user.setId(SystemConstant.getDbUuid());
|
|
user.setCreateId(sysUser1.getId());
|
|
user.setCreateId(sysUser1.getId());
|
|
user.setCreateTime(System.currentTimeMillis());
|
|
user.setCreateTime(System.currentTimeMillis());
|
|
@@ -170,7 +172,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
@Override
|
|
@Override
|
|
public boolean resetPassword(Long id) {
|
|
public boolean resetPassword(Long id) {
|
|
SysConfig sysConfig = sysConfigService.getByKey("sys.user.initPassword");
|
|
SysConfig sysConfig = sysConfigService.getByKey("sys.user.initPassword");
|
|
- String md5Password = Md5Utils.toMd5Hex(StringUtils.isNoneBlank(sysConfig.getConfigValue()) ? sysConfig.getConfigValue() : "123456");
|
|
|
|
|
|
+ BASE64Encoder encoder = new BASE64Encoder();
|
|
|
|
+ String md5Password = encoder.encode(StringUtils.isNoneBlank(sysConfig.getConfigValue()) ? sysConfig.getConfigValue().getBytes() : "123456".getBytes());
|
|
|
|
|
|
SysUser user = this.getById(id);
|
|
SysUser user = this.getById(id);
|
|
user.setPassword(md5Password);
|
|
user.setPassword(md5Password);
|
|
@@ -266,6 +269,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
return this.list(queryWrapper);
|
|
return this.list(queryWrapper);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Transactional
|
|
@Override
|
|
@Override
|
|
public boolean saveCustomer(SysUser user) {
|
|
public boolean saveCustomer(SysUser user) {
|
|
SysUser sysUser1 = (SysUser) ServletUtil.getRequestUser();
|
|
SysUser sysUser1 = (SysUser) ServletUtil.getRequestUser();
|
|
@@ -280,7 +284,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
throw ExceptionResultEnum.ERROR.exception("用户名已存在");
|
|
throw ExceptionResultEnum.ERROR.exception("用户名已存在");
|
|
}
|
|
}
|
|
SysConfig sysConfig = sysConfigService.getByKey("sys.user.initPassword");
|
|
SysConfig sysConfig = sysConfigService.getByKey("sys.user.initPassword");
|
|
- user.setPassword(Md5Utils.toMd5Hex(StringUtils.isNoneBlank(sysConfig.getConfigValue()) ? sysConfig.getConfigValue() : "123456"));
|
|
|
|
|
|
+ BASE64Encoder encoder = new BASE64Encoder();
|
|
|
|
+ user.setPassword(encoder.encode(StringUtils.isNoneBlank(sysConfig.getConfigValue()) ? sysConfig.getConfigValue().getBytes() : "123456".getBytes()));
|
|
user.setId(SystemConstant.getDbUuid());
|
|
user.setId(SystemConstant.getDbUuid());
|
|
user.setCreateId(sysUser1.getId());
|
|
user.setCreateId(sysUser1.getId());
|
|
user.setCreateTime(System.currentTimeMillis());
|
|
user.setCreateTime(System.currentTimeMillis());
|
|
@@ -312,7 +317,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
List<SysRolePrivilege> rolePrivileges = sysRolePrivilegeService.listByRoleId(roleId);
|
|
List<SysRolePrivilege> rolePrivileges = sysRolePrivilegeService.listByRoleId(roleId);
|
|
for (SysRolePrivilege rolePrivilege : rolePrivileges) {
|
|
for (SysRolePrivilege rolePrivilege : rolePrivileges) {
|
|
SysUserRole userRole = new SysUserRole();
|
|
SysUserRole userRole = new SysUserRole();
|
|
- userRole.setUserId(sysUser.getId());
|
|
|
|
|
|
+ userRole.setUserId(user.getId());
|
|
userRole.setRoleId(roleId);
|
|
userRole.setRoleId(roleId);
|
|
userRole.setPrivilegeId(rolePrivilege.getPrivilegeId());
|
|
userRole.setPrivilegeId(rolePrivilege.getPrivilegeId());
|
|
sysUserRoleService.save(userRole);
|
|
sysUserRoleService.save(userRole);
|