Просмотр исходного кода

添加dsp对应url,新增获取第三方算法实例的响应接口

tags/v2.4.1
xiaoying 1 год назад
Родитель
Сommit
93d57adbf6
11 измененных файлов: 317 добавлений и 124 удалений
  1. +20
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/DspConstant.java
  2. +1
    -11
      tuoheng_oidc_admin/src/main/java/com/tuoheng/controller/TenantController.java
  3. +1
    -8
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/TenantService.java
  4. +0
    -103
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java
  5. +44
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/third/controller/ThirdController.java
  6. +21
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/third/service/ThirdService.java
  7. +167
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/third/service/impl/ThirdServiceImpl.java
  8. +29
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/third/vo/IndustryVo.java
  9. +28
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/third/vo/ServiceExampleVo.java
  10. +3
    -1
      tuoheng_oidc_admin/src/main/resources/application-dev.yml
  11. +3
    -1
      tuoheng_oidc_admin/src/main/resources/application-test.yml

+ 20
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/DspConstant.java Просмотреть файл

@@ -0,0 +1,20 @@
package com.tuoheng.constant;

import lombok.Data;

/**
* @Author xiaoying
* @Date 2023/3/8 8:49
*/
@Data
public class DspConstant {

public static final String DSP_CLIENT = "tuoheng-dsp";

public static final String DSP_NAME = "dsp服务平台";

/**
* 获取算法的调度包行业信息及对应的算法实例
*/
public static final String FIND_EXAMPLE = "/industryServiceInst/list";
}

+ 1
- 11
tuoheng_oidc_admin/src/main/java/com/tuoheng/controller/TenantController.java Просмотреть файл

@@ -75,15 +75,5 @@ public class TenantController {
return tenantService.deleteTenant(dto, loginUser);
}

/**
* 查询对应业务平台的所有角色
*
* @param clientId 平台标识
* @param loginUser
* @return
*/
@GetMapping("/getRoleList")
public JsonResult getRoleList(String clientId, @CurrentUser LoginUser loginUser) {
return tenantService.getRoleList(clientId, loginUser);
}

}

+ 1
- 8
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/TenantService.java Просмотреть файл

@@ -36,14 +36,7 @@ public interface TenantService {
* @return
*/
JsonResult findUserList(UserQuery query);
/**
* 查询对应业务平台的所有角色
*
* @param clientId 平台标识
* @param loginUser
* @return
*/
JsonResult getRoleList(String clientId, LoginUser loginUser);


JsonResult createClientTenant(CreateClientTenantDto createClientTenantDto, LoginUser loginUser);


+ 0
- 103
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java Просмотреть файл

@@ -248,109 +248,6 @@ public class TenantServiceImpl implements TenantService {

return JsonResult.success();
}

/**
* 查询对应业务平台的所有角色
*
* @param clientId 平台标识
* @param loginUser
* @return
*/
@Override
public JsonResult getRoleList(String clientId, LoginUser loginUser) {

if (ObjectUtil.isEmpty(clientId)) {
return JsonResult.error("clientId不能为空");
}
List<ClientRoleListDto> clientRoleListDtos = new ArrayList<>();

if (clientId.contains(CommonConstant.COMMA)) {
String[] clientIds = clientId.split(CommonConstant.COMMA);
for (String id : clientIds) {
ClientRoleListDto dto = getRoleListByClinetId(id, loginUser);
clientRoleListDtos.add(dto);
}
} else {
ClientRoleListDto dto = getRoleListByClinetId(clientId, loginUser);
clientRoleListDtos.add(dto);
}
return JsonResult.success(clientRoleListDtos);
}

/**
* 访问对应系统获取对应业务平台可关联的角色
*
* @param clientId
* @param loginUser
* @return
*/
private ClientRoleListDto getRoleListByClinetId(String clientId, LoginUser loginUser) {


Platform platform = platformMapper.selectOne(Wrappers.<Platform>lambdaQuery()
.eq(Platform::getPlatformCode, clientId)
.eq(Platform::getMark, 1));
if (ObjectUtil.isNull(platform)) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "该业务平台不存在");
}
ClientRoleListDto clientRoleListDto = new ClientRoleListDto();
clientRoleListDto.setPlatformName(platform.getPlatformName());
clientRoleListDto.setClientId(platform.getPlatformCode());

String url = platform.getPlatformUrl();
//根据不同业务平台进行动态匹配 ->并修改对应标识权限
switch (platform.getPlatformCode()) {
//河湖长
case HhzUrlConstant.HHZ_CLIENT:
url = url + HhzUrlConstant.FIND_ROLE;
break;
////机场
//case AirportConstant.AIRPORT_CLIENT:
// url = url + AirportConstant.CREATE_TENANT;
// break;
////高速
//case FreeWayConstant.FREEWAY_CLIENT:
// url = url + FreeWayConstant.CREATE_TENANT;
// dto.getClientRoleDto().setClientId(FreeWayConstant.FREEWAY_CLIENT_ADMIN + CommonConstant.COMMA + FreeWayConstant.FREEWAY_CLIENT_MP);
// break;
////航道
//case WaterWayConstant.WATERWAY_CLIENT:
// url = url + WaterWayConstant.CREATE_TENANT;
// dto.getClientRoleDto().setClientId(WaterWayConstant.WATERWAY_CLIENT_ADMIN + CommonConstant.COMMA + WaterWayConstant.WATERWAY_CLIENT_MP);
// break;
////飞手
//case PilotConstant.PILOT_CLIENT:
// url = url + PilotConstant.CREATE_TENANT;
// dto.getClientRoleDto().setClientId(PilotConstant.PILOT_CLIENT + CommonConstant.COMMA + PilotConstant.PILOT_CLIENT_MP);
// break;
default:
break;
}
ParameterizedTypeReference<JsonResult<List<RoleDto>>> parameterizedTypeReference =
new ParameterizedTypeReference<JsonResult<List<RoleDto>>>() {
};
ResponseEntity<JsonResult<List<RoleDto>>> response;
org.springframework.http.HttpHeaders resultRequestHeader = new HttpHeaders();
resultRequestHeader.add("Authorization", "Bearer " + loginUser.getThToken());
HttpEntity httpEntity = new HttpEntity(resultRequestHeader);
try {
log.info("url:{}", url);
response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, parameterizedTypeReference);
} catch (Exception e) {
log.error("对应平台标识:{}", platform.getPlatformName());
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取角色列表失败!");
}
if (response == null || !response.hasBody() || response.getBody().getCode() != JsonResult.SUCCESS) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取角色列表响应失败!");
}
List<RoleDto> roleDtos = response.getBody().getData();

clientRoleListDto.setRoleDtoList(roleDtos);

return clientRoleListDto;

}

/**
* 查询租户以及该租户对应绑定的系统等
*

+ 44
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/third/controller/ThirdController.java Просмотреть файл

@@ -0,0 +1,44 @@
package com.tuoheng.third.controller;

import com.tuoheng.model.dto.LoginUser;
import com.tuoheng.service.CurrentUser;
import com.tuoheng.third.service.ThirdService;
import com.tuoheng.until.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* 第三方请求响应 前端控制器
* @Author xiaoying
* @Date 2023/3/8 9:01
*/
@RestController
@RequestMapping("/third")
public class ThirdController {

@Autowired
private ThirdService thirdService;


/**
* dsp -获取算法实例
* @return
*/
@GetMapping("/findExample")
public JsonResult findExample(){
return thirdService.findExample();
}
/**
* 查询对应业务平台的所有角色
*
* @param clientId 平台标识
* @param loginUser
* @return
*/
@GetMapping("/getRoleList")
public JsonResult getRoleList(String clientId, @CurrentUser LoginUser loginUser) {
return thirdService.getRoleList(clientId, loginUser);
}
}

+ 21
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/third/service/ThirdService.java Просмотреть файл

@@ -0,0 +1,21 @@
package com.tuoheng.third.service;

import com.tuoheng.model.dto.LoginUser;
import com.tuoheng.until.JsonResult;

public interface ThirdService {
/**
* dsp -获取算法实例
* @return
*/
JsonResult findExample();

/**
* 查询对应业务平台的所有角色
*
* @param clientId 平台标识
* @param loginUser
* @return
*/
JsonResult getRoleList(String clientId, LoginUser loginUser);
}

+ 167
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/third/service/impl/ThirdServiceImpl.java Просмотреть файл

@@ -0,0 +1,167 @@
package com.tuoheng.third.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.common.CommonConfig;
import com.tuoheng.common.ServiceException;
import com.tuoheng.constant.CommonConstant;
import com.tuoheng.constant.DspConstant;
import com.tuoheng.constant.HhzUrlConstant;
import com.tuoheng.mapper.PlatformMapper;
import com.tuoheng.model.dto.ClientRoleListDto;
import com.tuoheng.model.dto.LoginUser;
import com.tuoheng.model.dto.Platform;
import com.tuoheng.model.dto.RoleDto;
import com.tuoheng.third.service.ThirdService;
import com.tuoheng.third.vo.IndustryVo;
import com.tuoheng.until.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.List;

/**
* @Author xiaoying
* @Date 2023/3/8 9:01
*/
@Service
@Slf4j
public class ThirdServiceImpl implements ThirdService {

@Autowired
private PlatformMapper platformMapper;
@Autowired
private RestTemplate restTemplate;

/**
* dsp -获取算法实例
*
* @return
*/
@Override
public JsonResult findExample() {

String url = CommonConfig.dspURL + DspConstant.FIND_EXAMPLE;

ParameterizedTypeReference<JsonResult<List<IndustryVo>>> parameterizedTypeReference =
new ParameterizedTypeReference<JsonResult<List<IndustryVo>>>() {
};
ResponseEntity<JsonResult<List<IndustryVo>>> response;
try {
log.info("url:{}", url);
response = restTemplate.exchange(url, HttpMethod.GET, null, parameterizedTypeReference);
} catch (Exception e) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "请求发送内部出现异常!");
}
if (response == null || !response.hasBody() || response.getBody().getCode() != JsonResult.SUCCESS) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "dsp获取服务实例异常");
}
return JsonResult.success(response.getBody().getData());
}

/**
* 查询对应业务平台的所有角色
*
* @param clientId 平台标识
* @param loginUser
* @return
*/
@Override
public JsonResult getRoleList(String clientId, LoginUser loginUser) {

if (ObjectUtil.isEmpty(clientId)) {
return JsonResult.error("clientId不能为空");
}
List<ClientRoleListDto> clientRoleListDtos = new ArrayList<>();

if (clientId.contains(CommonConstant.COMMA)) {
String[] clientIds = clientId.split(CommonConstant.COMMA);
for (String id : clientIds) {
ClientRoleListDto dto = getRoleListByClinetId(id, loginUser);
clientRoleListDtos.add(dto);
}
} else {
ClientRoleListDto dto = getRoleListByClinetId(clientId, loginUser);
clientRoleListDtos.add(dto);
}
return JsonResult.success(clientRoleListDtos);
}

/**
* 访问对应系统获取对应业务平台可关联的角色
*
* @param clientId
* @param loginUser
* @return
*/
private ClientRoleListDto getRoleListByClinetId(String clientId, LoginUser loginUser) {

Platform platform = platformMapper.selectOne(Wrappers.<Platform>lambdaQuery()
.eq(Platform::getPlatformCode, clientId)
.eq(Platform::getMark, 1));
if (ObjectUtil.isNull(platform)) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "该业务平台不存在");
}
ClientRoleListDto clientRoleListDto = new ClientRoleListDto();
clientRoleListDto.setPlatformName(platform.getPlatformName());
clientRoleListDto.setClientId(platform.getPlatformCode());

String url = platform.getPlatformUrl();
//根据不同业务平台进行动态匹配 ->并修改对应标识权限
switch (platform.getPlatformCode()) {
//河湖长
case HhzUrlConstant.HHZ_CLIENT:
url = url + HhzUrlConstant.FIND_ROLE;
break;
////机场
//case AirportConstant.AIRPORT_CLIENT:
// url = url + AirportConstant.CREATE_TENANT;
// break;
////高速
//case FreeWayConstant.FREEWAY_CLIENT:
// url = url + FreeWayConstant.CREATE_TENANT;
// dto.getClientRoleDto().setClientId(FreeWayConstant.FREEWAY_CLIENT_ADMIN + CommonConstant.COMMA + FreeWayConstant.FREEWAY_CLIENT_MP);
// break;
////航道
//case WaterWayConstant.WATERWAY_CLIENT:
// url = url + WaterWayConstant.CREATE_TENANT;
// dto.getClientRoleDto().setClientId(WaterWayConstant.WATERWAY_CLIENT_ADMIN + CommonConstant.COMMA + WaterWayConstant.WATERWAY_CLIENT_MP);
// break;
////飞手
//case PilotConstant.PILOT_CLIENT:
// url = url + PilotConstant.CREATE_TENANT;
// dto.getClientRoleDto().setClientId(PilotConstant.PILOT_CLIENT + CommonConstant.COMMA + PilotConstant.PILOT_CLIENT_MP);
// break;
default:
break;
}
ParameterizedTypeReference<JsonResult<List<RoleDto>>> parameterizedTypeReference =
new ParameterizedTypeReference<JsonResult<List<RoleDto>>>() {
};
ResponseEntity<JsonResult<List<RoleDto>>> response;
org.springframework.http.HttpHeaders resultRequestHeader = new HttpHeaders();
resultRequestHeader.add("Authorization", "Bearer " + loginUser.getThToken());
HttpEntity httpEntity = new HttpEntity(resultRequestHeader);
try {
log.info("url:{}", url);
response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, parameterizedTypeReference);
} catch (Exception e) {
log.error("对应平台标识:{}", platform.getPlatformName());
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取角色列表失败!");
}
if (response == null || !response.hasBody() || response.getBody().getCode() != JsonResult.SUCCESS) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取角色列表响应失败!");
}
List<RoleDto> roleDtos = response.getBody().getData();

clientRoleListDto.setRoleDtoList(roleDtos);

return clientRoleListDto;

}
}

+ 29
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/third/vo/IndustryVo.java Просмотреть файл

@@ -0,0 +1,29 @@
package com.tuoheng.third.vo;

import lombok.Data;

import java.util.List;

/**
* 行业vo 返回实体类
* @Author xiaoying
* @Date 2023/3/8 9:36
*/
@Data
public class IndustryVo {

/**
* 行业ID
*/
private String industryId;
/**
* 行业名称
*/
private String industryName;
/**
* 服务实例列表
*/
private List<ServiceExampleVo> serviceInstListVoList;


}

+ 28
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/third/vo/ServiceExampleVo.java Просмотреть файл

@@ -0,0 +1,28 @@
package com.tuoheng.third.vo;

import lombok.Data;

/**
* 服务实例返回实体类
* @Author xiaoying
* @Date 2023/3/8 9:39
*/
@Data
public class ServiceExampleVo {
/**
* 服务实例id
*/
private String id;
/**
* 服务定义ID
*/
private String serviceDefId;
/**
* 服务实例名称
*/
private String name;
/**
* 服务实例id
*/
private String description;
}

+ 3
- 1
tuoheng_oidc_admin/src/main/resources/application-dev.yml Просмотреть файл

@@ -69,4 +69,6 @@ spring:
# 自定义配置
tuoheng:
#airport配置地址
airport-url: https://airport-test.t-aaron.com
airport-url: https://airport-test.t-aaron.com
#dsp配置地址
dsp-url: http://106.15.64.139:7011/api/web/dsp

+ 3
- 1
tuoheng_oidc_admin/src/main/resources/application-test.yml Просмотреть файл

@@ -68,4 +68,6 @@ spring:
# 自定义配置
tuoheng:
#airport配置地址
airport-url: https://airport-test.t-aaron.com
airport-url: https://airport-test.t-aaron.com
#dsp配置地址
dsp-url: https://dsp-portal.t-aaron.com/api/web/dsp

Загрузка…
Отмена
Сохранить