fix:修改changPassword接口 使用配置文件默认密码
This commit is contained in:
parent
c65e9b72a7
commit
20b6b2eaab
|
@ -41,6 +41,7 @@ import org.jeecg.modules.system.vo.lowapp.UpdateDepartInfo;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
@ -63,7 +64,7 @@ import java.util.stream.Collectors;
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
|
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysUserMapper userMapper;
|
private SysUserMapper userMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -96,7 +97,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
private SysUserTenantMapper relationMapper;
|
private SysUserTenantMapper relationMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysUserTenantMapper userTenantMapper;
|
private SysUserTenantMapper userTenantMapper;
|
||||||
|
|
||||||
|
@Value("${system.auth.defaultPassword}")
|
||||||
|
private String defaultPassword;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<IPage<SysUser>> queryPageList(HttpServletRequest req, QueryWrapper<SysUser> queryWrapper, Integer pageSize, Integer pageNo) {
|
public Result<IPage<SysUser>> queryPageList(HttpServletRequest req, QueryWrapper<SysUser> queryWrapper, Integer pageSize, Integer pageNo) {
|
||||||
Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
|
Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
|
||||||
|
@ -185,8 +189,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
public Result<?> changePassword(SysUser sysUser) {
|
public Result<?> changePassword(SysUser sysUser) {
|
||||||
String salt = oConvertUtils.randomGen(8);
|
String salt = oConvertUtils.randomGen(8);
|
||||||
sysUser.setSalt(salt);
|
sysUser.setSalt(salt);
|
||||||
String password = sysUser.getPassword();
|
String passwordEncode = PasswordUtil.encrypt(sysUser.getUsername(), defaultPassword, salt);
|
||||||
String passwordEncode = PasswordUtil.encrypt(sysUser.getUsername(), password, salt);
|
|
||||||
sysUser.setPassword(passwordEncode);
|
sysUser.setPassword(passwordEncode);
|
||||||
this.userMapper.updateById(sysUser);
|
this.userMapper.updateById(sysUser);
|
||||||
return Result.ok("密码修改成功!");
|
return Result.ok("密码修改成功!");
|
||||||
|
@ -224,8 +227,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
}
|
}
|
||||||
return sysUser;
|
return sysUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void addUserWithRole(SysUser user, String roles) {
|
public void addUserWithRole(SysUser user, String roles) {
|
||||||
|
@ -286,7 +289,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
roleIndex = list.get(0);
|
roleIndex = list.get(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//如果componentUrl为空,则返回空
|
//如果componentUrl为空,则返回空
|
||||||
if(oConvertUtils.isEmpty(roleIndex.getComponent())){
|
if(oConvertUtils.isEmpty(roleIndex.getComponent())){
|
||||||
return null;
|
return null;
|
||||||
|
@ -352,7 +355,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
info.setSysUserName(sysUser.getRealname());
|
info.setSysUserName(sysUser.getRealname());
|
||||||
info.setSysOrgCode(sysUser.getOrgCode());
|
info.setSysOrgCode(sysUser.getOrgCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
//多部门支持in查询
|
//多部门支持in查询
|
||||||
List<SysDepart> list = sysDepartMapper.queryUserDeparts(sysUser.getId());
|
List<SysDepart> list = sysDepartMapper.queryUserDeparts(sysUser.getId());
|
||||||
List<String> sysMultiOrgCode = new ArrayList<String>();
|
List<String> sysMultiOrgCode = new ArrayList<String>();
|
||||||
|
@ -368,7 +371,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info.setSysMultiOrgCode(sysMultiOrgCode);
|
info.setSysMultiOrgCode(sysMultiOrgCode);
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,7 +589,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
|
|
||||||
//6. 删除租户用户中间表的数据
|
//6. 删除租户用户中间表的数据
|
||||||
line += userTenantMapper.delete(new LambdaQueryWrapper<SysUserTenant>().in(SysUserTenant::getUserId,userIds));
|
line += userTenantMapper.delete(new LambdaQueryWrapper<SysUserTenant>().in(SysUserTenant::getUserId,userIds));
|
||||||
|
|
||||||
return line != 0;
|
return line != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,7 +791,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
queryWrapper.eq(SysTenant::getStatus, Integer.valueOf(CommonConstant.STATUS_1));
|
queryWrapper.eq(SysTenant::getStatus, Integer.valueOf(CommonConstant.STATUS_1));
|
||||||
tenantList = sysTenantMapper.selectList(queryWrapper);
|
tenantList = sysTenantMapper.selectList(queryWrapper);
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
if (tenantList.size() == 0) {
|
if (tenantList.size() == 0) {
|
||||||
return result.error500("与该用户关联的租户均已被冻结,无法登录!");
|
return result.error500("与该用户关联的租户均已被冻结,无法登录!");
|
||||||
} else {
|
} else {
|
||||||
|
@ -896,7 +899,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
//找到新的租户id与原来的租户id不同之处,进行删除
|
//找到新的租户id与原来的租户id不同之处,进行删除
|
||||||
String[] relTenantIdArray = relTenantIds.split(SymbolConstant.COMMA);
|
String[] relTenantIdArray = relTenantIds.split(SymbolConstant.COMMA);
|
||||||
List<String> relTenantIdList = Arrays.asList(relTenantIdArray);
|
List<String> relTenantIdList = Arrays.asList(relTenantIdArray);
|
||||||
|
|
||||||
List<Integer> deleteTenantIdList = oldTenantIds.stream().filter(item -> !relTenantIdList.contains(item.toString())).collect(Collectors.toList());
|
List<Integer> deleteTenantIdList = oldTenantIds.stream().filter(item -> !relTenantIdList.contains(item.toString())).collect(Collectors.toList());
|
||||||
for (Integer tenantId : deleteTenantIdList) {
|
for (Integer tenantId : deleteTenantIdList) {
|
||||||
this.deleteTenantByUserId(userId, tenantId);
|
this.deleteTenantByUserId(userId, tenantId);
|
||||||
|
@ -964,9 +967,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
.in(SysUserDepart::getUserId, idList)
|
.in(SysUserDepart::getUserId, idList)
|
||||||
.in(SysUserDepart::getDepId, departIdList);
|
.in(SysUserDepart::getDepId, departIdList);
|
||||||
sysUserDepartMapper.delete(query);
|
sysUserDepartMapper.delete(query);
|
||||||
|
|
||||||
String[] arr = selecteddeparts.split(",");
|
String[] arr = selecteddeparts.split(",");
|
||||||
|
|
||||||
//再新增
|
//再新增
|
||||||
for (String deaprtId : arr) {
|
for (String deaprtId : arr) {
|
||||||
for(String userId: idList){
|
for(String userId: idList){
|
||||||
|
@ -1104,7 +1107,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1135,7 +1138,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 变更父级部门 修改编码
|
* 变更父级部门 修改编码
|
||||||
* @param parentId
|
* @param parentId
|
||||||
|
@ -1208,7 +1211,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
getParentDepart(temp, orgName, orgId);
|
getParentDepart(temp, orgName, orgId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true)
|
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true)
|
||||||
|
@ -1221,7 +1224,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
//修改租户用户下的部门
|
//修改租户用户下的部门
|
||||||
this.updateTenantDepart(user, tenantId, departs);
|
this.updateTenantDepart(user, tenantId, departs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改租户下的部门
|
* 修改租户下的部门
|
||||||
* @param departs
|
* @param departs
|
||||||
|
|
Loading…
Reference in New Issue
Block a user