|
|
@@ -660,47 +660,50 @@ public class TenantServiceImpl implements TenantService { |
|
|
|
tenantItemMapper.updateById(tenantItem); |
|
|
|
vo.setEffectiveDate(DateUtil.formatDate(tenantItem.getBeginTime()) + CommonConstant.TILDE + DateUtil.formatDate(tenantItem.getEndTime())); |
|
|
|
log.info("租户项目相关信息更新完毕"); |
|
|
|
//todo:调用业务系统完成租户创建 |
|
|
|
for (ClientRoleDto clientRoleDto : insertClientRoleDtoList) { |
|
|
|
try { |
|
|
|
log.info("参数:{}", clientRoleDto.toString()); |
|
|
|
JsonResult result = getResult(dto, clientRoleDto.getClientId(), loginUser); |
|
|
|
if (JsonResult.SUCCESS != result.getCode()) { |
|
|
|
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), result.getMsg()); |
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(insertClientRoleDtoList)) { |
|
|
|
//todo:调用业务系统完成租户创建 |
|
|
|
for (ClientRoleDto clientRoleDto : insertClientRoleDtoList) { |
|
|
|
try { |
|
|
|
log.info("参数:{}", clientRoleDto.toString()); |
|
|
|
JsonResult result = getResult(dto, clientRoleDto.getClientId(), loginUser); |
|
|
|
if (JsonResult.SUCCESS != result.getCode()) { |
|
|
|
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), result.getMsg()); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
//e.printStackTrace(); |
|
|
|
//事务并不会回滚 |
|
|
|
log.info("异常信息捕获,平台标识:{}", clientRoleDto.getClientId()); |
|
|
|
log.info("异常信息:{}", e.getMessage()); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
//e.printStackTrace(); |
|
|
|
//事务并不会回滚 |
|
|
|
log.info("异常信息捕获,平台标识:{}", clientRoleDto.getClientId()); |
|
|
|
log.info("异常信息:{}", e.getMessage()); |
|
|
|
} |
|
|
|
log.info("业务系统新增租户成功"); |
|
|
|
|
|
|
|
//创建新的租户对应权限相关数据 |
|
|
|
List<AuthoritiesPo> authoritiesPos = new ArrayList<>(); |
|
|
|
List<ClientUserRolePo> clientUserRolePoArrayList = new ArrayList<>(); |
|
|
|
insertClientRoleDtoList = getClientRoleDtos(insertClientRoleDtoList); |
|
|
|
for (ClientRoleDto clientRoleDto : insertClientRoleDtoList) { |
|
|
|
//添加角色权限相关 |
|
|
|
AuthoritiesPo authoritiesPo = new AuthoritiesPo() |
|
|
|
.setUserId(tenant.getUserId()) |
|
|
|
.setUsername(dto.getUsername()) |
|
|
|
.setAuthority(clientRoleDto.getClientId()); |
|
|
|
authoritiesPo.setCreateUser(loginUser.getUserId()); |
|
|
|
authoritiesPos.add(authoritiesPo); |
|
|
|
|
|
|
|
ClientUserRolePo clientUserRolePo = new ClientUserRolePo() |
|
|
|
.setUserId(tenant.getUserId()) |
|
|
|
.setClientId(clientRoleDto.getClientId()) |
|
|
|
.setRoleId(clientRoleDto.getRoleId()) |
|
|
|
.setRoleName(clientRoleDto.getRoleName()); |
|
|
|
clientUserRolePo.setCreateUser(loginUser.getUserId()); |
|
|
|
clientUserRolePoArrayList.add(clientUserRolePo); |
|
|
|
} |
|
|
|
authoritiesMapper.batchInsert(authoritiesPos); |
|
|
|
clientUserRoleMapper.batchInsert(clientUserRolePoArrayList); |
|
|
|
log.info("对应业务系统的权限相关创建成功"); |
|
|
|
} |
|
|
|
log.info("业务系统新增租户成功"); |
|
|
|
|
|
|
|
//创建新的租户对应权限相关数据 |
|
|
|
List<AuthoritiesPo> authoritiesPos = new ArrayList<>(); |
|
|
|
List<ClientUserRolePo> clientUserRolePoArrayList = new ArrayList<>(); |
|
|
|
insertClientRoleDtoList = getClientRoleDtos(insertClientRoleDtoList); |
|
|
|
for (ClientRoleDto clientRoleDto : insertClientRoleDtoList) { |
|
|
|
//添加角色权限相关 |
|
|
|
AuthoritiesPo authoritiesPo = new AuthoritiesPo() |
|
|
|
.setUserId(tenant.getUserId()) |
|
|
|
.setUsername(dto.getUsername()) |
|
|
|
.setAuthority(clientRoleDto.getClientId()); |
|
|
|
authoritiesPo.setCreateUser(loginUser.getUserId()); |
|
|
|
authoritiesPos.add(authoritiesPo); |
|
|
|
|
|
|
|
ClientUserRolePo clientUserRolePo = new ClientUserRolePo() |
|
|
|
.setUserId(tenant.getUserId()) |
|
|
|
.setClientId(clientRoleDto.getClientId()) |
|
|
|
.setRoleId(clientRoleDto.getRoleId()) |
|
|
|
.setRoleName(clientRoleDto.getRoleName()); |
|
|
|
clientUserRolePo.setCreateUser(loginUser.getUserId()); |
|
|
|
clientUserRolePoArrayList.add(clientUserRolePo); |
|
|
|
} |
|
|
|
authoritiesMapper.batchInsert(authoritiesPos); |
|
|
|
clientUserRoleMapper.batchInsert(clientUserRolePoArrayList); |
|
|
|
log.info("对应业务系统的权限相关创建成功"); |
|
|
|
|
|
|
|
return JsonResult.success(vo); |
|
|
|
} |