Browse Source

租户完成创建后返回基本信息

tags/v2.4.1
xiaoying 1 year ago
parent
commit
3b9a8e2c1f
3 changed files with 67 additions and 3 deletions
  1. +11
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/CommonConstant.java
  2. +36
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/model/vo/CreateTenantVo.java
  3. +20
    -3
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java

+ 11
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/CommonConstant.java View File

@@ -32,5 +32,16 @@ public final class CommonConstant {
*/
public static final String SLASH = "/";

/**
* 顿号
*/
public static final String SIGN = "、";
/**
* 波浪号
*/
public static final String TILDE = "~";




}

+ 36
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/model/vo/CreateTenantVo.java View File

@@ -0,0 +1,36 @@
package com.tuoheng.model.vo;

import lombok.Data;

/**
* 创建租户完成返回实体类
*
* @Author xiaoying
* @Date 2023/3/8 15:44
*/
@Data
public class CreateTenantVo {

/**
* 租户名称
*/
private String tenantName;

/**
* 租户账号
*/
private String username;
/**
* 密码
*/
private String password;

/**
* 平台名称(多个逗号分隔)
*/
private String platformName;
/**
* 系统有效期
*/
private String effectiveDate;
}

+ 20
- 3
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java View File

@@ -22,6 +22,7 @@ import com.tuoheng.model.po.UserPo;
import com.tuoheng.model.query.TenantQuery;
import com.tuoheng.model.query.UserQuery;
import com.tuoheng.model.vo.BusinessSystemVo;
import com.tuoheng.model.vo.CreateTenantVo;
import com.tuoheng.model.vo.TenantVo;
import com.tuoheng.model.vo.UserVo;
import com.tuoheng.service.TenantEmployService;
@@ -84,6 +85,11 @@ public class TenantServiceImpl implements TenantService {
if (clientUserMapper.judgeCreateByUserName(createClientTenantDto.getUsername()) > 0) {
return JsonResult.error("该用户名称已存在!");
}
//创建租户创建成功后的返回实体类
CreateTenantVo vo = new CreateTenantVo();
vo.setPassword(createClientTenantDto.getPassword());
vo.setTenantName(createClientTenantDto.getTenantName());
vo.setUsername(createClientTenantDto.getUsername());
//code复用username
createClientTenantDto.setTenantCode(createClientTenantDto.getTenantName());
//用户表
@@ -111,9 +117,20 @@ public class TenantServiceImpl implements TenantService {
TenantItem tenantItem = createClientTenantDto.getTenantItem();
tenantItem.setTenantId(tenantPo.getId());
tenantItemMapper.insert(tenantItem);
//设置系统有效期
vo.setEffectiveDate(DateUtil.formatDate(tenantItem.getBeginTime()) + CommonConstant.TILDE + DateUtil.formatDate(tenantItem.getEndTime()));
log.info("租户项目表添加完毕");

for (ClientRoleDto clientRoleDto : createClientTenantDto.getClientRoleDtoList()) {
//获取clientId查询对应平台获取平台名称
Platform platform = platformMapper.selectOne(Wrappers.<Platform>lambdaQuery()
.eq(Platform::getPlatformCode, clientRoleDto.getClientId())
.eq(Platform::getMark, 1));
if (ObjectUtil.isNull(platform)) {
return JsonResult.error("该业务平台不存在");
}
//添加相关对应
vo.setPlatformName(platform.getPlatformName() + CommonConstant.SIGN);
//添加租户对应服务的相关表数据
TenantEmploy tenantEmploy = new TenantEmploy();
tenantEmploy.setTenantId(tenantPo.getId());
@@ -121,8 +138,9 @@ public class TenantServiceImpl implements TenantService {
tenantEmploy.setDescription(clientRoleDto.getDescription());
tenantEmployMapper.insert(tenantEmploy);
}
//拼接
vo.setPlatformName(vo.getPlatformName().substring(CommonConstant.ZERO, vo.getPlatformName().lastIndexOf(CommonConstant.SIGN)));
log.info("租户客户表添加完毕");

//1.开始判断租户对应需要的平台并进行匹对
List<ClientRoleDto> clientRoleDtoList = getClientRoleDtos(createClientTenantDto);
List<AuthoritiesPo> authoritiesPos = new ArrayList<>();
@@ -164,8 +182,7 @@ public class TenantServiceImpl implements TenantService {
}

}

return JsonResult.success(userPo.getId());
return JsonResult.success(vo);
}

/**

Loading…
Cancel
Save