Browse Source

更新租户编辑时更新对应权限相关

tags/v2.4.1
xiaoying 1 year ago
parent
commit
7fb5ffb895
3 changed files with 38 additions and 10 deletions
  1. +34
    -6
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java
  2. +3
    -3
      tuoheng_oidc_admin/target/classes/application-test.yml
  3. +1
    -1
      tuoheng_oidc_admin/target/classes/application.yml

+ 34
- 6
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java View File

@@ -426,7 +426,9 @@ public class TenantServiceImpl implements TenantService {
TenantEmploy tenantEmploy = tenantEmployMapper.selectOne(Wrappers.<TenantEmploy>lambdaQuery()
.eq(TenantEmploy::getTenantId, tenantId)
.eq(TenantEmploy::getPlatformCode, clientRoleDto.getClientId()));
clientRoleDto.setServiceId(tenantEmploy.getServiceId());
if (ObjectUtil.isNotNull(tenantEmploy)) {
clientRoleDto.setServiceId(tenantEmploy.getServiceId());
}
list.add(clientRoleDto);
}
dto.setClientRoleDtoList(list.stream().distinct().collect(Collectors.toList()));
@@ -595,18 +597,15 @@ public class TenantServiceImpl implements TenantService {
vo.setPlatformName(PlatformName.substring(CommonConstant.ZERO, PlatformName.lastIndexOf(CommonConstant.SIGN)));
log.info("租户更新的业务服务实例表更新完毕");
//更新租户原有数据基本
TenantPo tenantPo = new TenantPo();
BeanUtils.copyProperties(dto, tenantPo);
tenantPo.setName(dto.getTenantName())
tenant.setName(dto.getTenantName())
.setCode(dto.getTenantCode())
.setId(dto.getId());
tenantMapper.updateById(tenantPo);
tenantMapper.updateById(tenant);
log.info("租户基本信息更新完毕");
TenantItem tenantItem = dto.getTenantItem();
tenantItemMapper.updateById(tenantItem);
vo.setEffectiveDate(DateUtil.formatDate(tenantItem.getBeginTime()) + CommonConstant.TILDE + DateUtil.formatDate(tenantItem.getEndTime()));
log.info("租户项目相关信息更新完毕");

//todo:调用业务系统完成租户创建
for (ClientRoleDto clientRoleDto : list) {
try {
@@ -622,6 +621,35 @@ public class TenantServiceImpl implements TenantService {
log.info("异常信息:{}", e.getMessage());
}
}
log.info("业务系统新增租户成功");
//原有集合
List<ClientRoleDto> finalClientRoleDtoList = clientRoleDtoList;
list= list.stream().filter(t -> !finalClientRoleDtoList.contains(t)).collect(Collectors.toList());

List<AuthoritiesPo> authoritiesPos = new ArrayList<>();
List<ClientUserRolePo> clientUserRolePoArrayList = new ArrayList<>();

for (ClientRoleDto clientRoleDto : list) {
//添加角色权限相关
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);
}


+ 3
- 3
tuoheng_oidc_admin/target/classes/application-test.yml View File

@@ -2,11 +2,11 @@ spring:
# 注册中心consul地址
cloud:
consul:
host: 106.15.64.139 # consul 所在服务地址
host: 172.15.1.11 # consul 所在服务地址
port: 8500 # consul 服务端口
discovery:
## consul ip地址
hostname: 106.15.64.139
hostname: 172.15.1.11
# 注册到consul的服务名称
service-name: ${spring.application.name} # 服务提供者名称
instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${server.port} #实例ID
@@ -21,7 +21,7 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# 填写你数据库的url、登录名、密码和数据库名
url: jdbc:mysql://rm-uf6z740323e8053pj4o.mysql.rds.aliyuncs.com:3306/tuoheng_oidc?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false
url: jdbc:mysql://rm-uf6z740323e8053pj.mysql.rds.aliyuncs.com:3306/tuoheng_oidc?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false
username: root
password: TH22#2022
druid:

+ 1
- 1
tuoheng_oidc_admin/target/classes/application.yml View File

@@ -3,7 +3,7 @@ server:

spring:
profiles:
active: test
active: dev
application:
name: tuoheng-oidc-admin
main:

Loading…
Cancel
Save