|
|
@@ -1,12 +1,15 @@ |
|
|
|
package com.tuoheng.admin.service.third.oidc; |
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.tuoheng.admin.constant.OidcUrlConstant; |
|
|
|
import com.tuoheng.admin.constant.SystemConstant; |
|
|
|
import com.tuoheng.admin.dto.ClientRoleDto; |
|
|
|
import com.tuoheng.admin.entity.Tenant; |
|
|
|
import com.tuoheng.admin.entity.User; |
|
|
|
import com.tuoheng.admin.enums.ClientEnum; |
|
|
|
import com.tuoheng.admin.enums.MarkEnum; |
|
|
|
import com.tuoheng.admin.mapper.TenantMapper; |
|
|
|
import com.tuoheng.admin.request.oidc.OidcCreateUserRequest; |
|
|
|
import com.tuoheng.common.core.config.common.CommonConfig; |
|
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
@@ -33,6 +36,9 @@ public class AddOidcUserService { |
|
|
|
@Qualifier("restTemplate") |
|
|
|
private RestTemplate restTemplate; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private TenantMapper tenantMapper; |
|
|
|
|
|
|
|
public JsonResult add(User user, String password, Tenant tenant) { |
|
|
|
OidcCreateUserRequest request = this.buildOidcCreateUserRequest(user, password, tenant); |
|
|
|
//设置请求头 |
|
|
@@ -70,8 +76,11 @@ public class AddOidcUserService { |
|
|
|
oidcCreateUserRequest.setPassword(password); |
|
|
|
if (ObjectUtil.isNull(tenant)) { |
|
|
|
// 普通用户新增 |
|
|
|
Tenant tenantTmp = tenantMapper.selectOne(new LambdaQueryWrapper<Tenant>() |
|
|
|
.eq(Tenant::getId, user.getTenantId()) |
|
|
|
.eq(Tenant::getMark, MarkEnum.VALID.getCode())); |
|
|
|
oidcCreateUserRequest.setTenantFlag(0); |
|
|
|
oidcCreateUserRequest.setTenantName(""); |
|
|
|
oidcCreateUserRequest.setTenantName(tenantTmp.getUsername()); |
|
|
|
} else { |
|
|
|
oidcCreateUserRequest.setTenantFlag(1); |
|
|
|
oidcCreateUserRequest.setCode(tenant.getCode()); |