|
|
@@ -257,7 +257,7 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
} |
|
|
|
//开启分页 |
|
|
|
IPage<TenantVo> page = new Page<>(query.getPage(), query.getLimit()); |
|
|
|
IPage<TenantPo> pageData = tenantMapper.findList(page,query); |
|
|
|
IPage<TenantPo> pageData = tenantMapper.findList(page, query); |
|
|
|
pageData.convert(x -> { |
|
|
|
TenantVo vo = Convert.convert(TenantVo.class, x); |
|
|
|
Long userId = x.getUserId(); |
|
|
@@ -289,14 +289,49 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public JsonResult editTenant(OidcTenantDto dto, LoginUser loginUser) { |
|
|
|
|
|
|
|
|
|
|
|
//TODO |
|
|
|
return null; |
|
|
|
if (ObjectUtil.isEmpty(dto.getCode())) { |
|
|
|
return JsonResult.error("租户code不能为空"); |
|
|
|
} |
|
|
|
if (dto.getClientId().contains(",")) { |
|
|
|
String[] codes = dto.getClientId().split(","); |
|
|
|
for (String code : codes) { |
|
|
|
JsonResult jsonResult = editResult(dto, code, loginUser); |
|
|
|
if (!"操作成功".equals(jsonResult.getMsg())) { |
|
|
|
return jsonResult; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
JsonResult jsonResult = editResult(dto, dto.getClientId(), loginUser); |
|
|
|
if (!"操作成功".equals(jsonResult.getMsg())) { |
|
|
|
return jsonResult; |
|
|
|
} |
|
|
|
} |
|
|
|
TTenant tTenant = tenantMapper.getByCode(dto.getCode()); |
|
|
|
dto.setId(tTenant.getId()); |
|
|
|
//更新密码 |
|
|
|
dto.setPassword("{bcrypt}" + new BCryptPasswordEncoder().encode(dto.getPassword())); |
|
|
|
TenantPo tenantPo = new TenantPo(); |
|
|
|
tenantPo.setName(dto.getName()) |
|
|
|
.setId(dto.getId()); |
|
|
|
tenantMapper.updateById(tenantPo); |
|
|
|
UserPo userPo = new UserPo(); |
|
|
|
userPo.setUsername(dto.getUsername()) |
|
|
|
.setPassword(dto.getPassword()); |
|
|
|
clientUserMapper.updatePass(userPo); |
|
|
|
return JsonResult.success(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 新增请求 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @param code |
|
|
|
* @param loginUser |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private JsonResult getResult(OidcTenantDto dto, String code, LoginUser loginUser) { |
|
|
|
Platform platform = platformMapper.selectOne(Wrappers.<Platform>lambdaQuery() |
|
|
|
.eq(Platform::getPlatformCode, code) |
|
|
@@ -330,4 +365,51 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
} |
|
|
|
return JsonResult.success(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 更新请求 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @param code |
|
|
|
* @param loginUser |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private JsonResult editResult(OidcTenantDto dto, String code, LoginUser loginUser) { |
|
|
|
Platform platform = platformMapper.selectOne(Wrappers.<Platform>lambdaQuery() |
|
|
|
.eq(Platform::getPlatformCode, code) |
|
|
|
.eq(Platform::getMark, 1)); |
|
|
|
if (ObjectUtil.isNull(platform)) { |
|
|
|
return JsonResult.error("该业务平台不存在"); |
|
|
|
} |
|
|
|
//设置请求头 |
|
|
|
HttpHeaders resultRequestHeader = new HttpHeaders(); |
|
|
|
resultRequestHeader.add("Authorization", "Bearer " + loginUser.getThToken()); |
|
|
|
HttpEntity httpEntity = new HttpEntity(dto, resultRequestHeader); |
|
|
|
//设置地址(hhz平台) |
|
|
|
String url = platform.getPlatformUrl(); |
|
|
|
//根据不同业务平台进行动态匹配 |
|
|
|
if (url.contains("hhz")) { |
|
|
|
url = url + HhzUrlConstant.UPDATE_TENANT; |
|
|
|
} |
|
|
|
//else if (url.contains("lc")) { |
|
|
|
// url = url + HhzUrlConstant.UPDATE_TENANT; |
|
|
|
//} else if (url.contains("gs")) { |
|
|
|
// url = url + HhzUrlConstant.UPDATE_TENANT; |
|
|
|
//} |
|
|
|
ResponseEntity<JsonResult> response; |
|
|
|
try { |
|
|
|
response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "业务平台更新租户失败"); |
|
|
|
} |
|
|
|
if (null == response || !response.hasBody()) { |
|
|
|
log.error("业务平台更新租户响应失败"); |
|
|
|
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "业务平台更新租户失败"); |
|
|
|
} |
|
|
|
if (response.getBody().getCode() != JsonResult.SUCCESS) { |
|
|
|
log.error("业务平台更新租户响应失败" + response.getBody()); |
|
|
|
return JsonResult.error(response.getBody().getMsg()); |
|
|
|
} |
|
|
|
return JsonResult.success(); |
|
|
|
} |
|
|
|
} |