Ver código fonte

新增根据角色id查询第三方对应所有菜单列表展示

tags/v2.4.1
xiaoying 1 ano atrás
pai
commit
bbcad162b6
12 arquivos alterados com 176 adições e 3 exclusões
  1. +5
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/HhzUrlConstant.java
  2. +14
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/third/controller/ThirdController.java
  3. +19
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/third/request/ThirdRequest.java
  4. +9
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/third/service/ThirdService.java
  5. +73
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/third/service/impl/ThirdServiceImpl.java
  6. +26
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/third/vo/MenuVo.java
  7. +21
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/third/vo/RoleMenuVo.java
  8. +3
    -1
      tuoheng_oidc_admin/target/classes/WEB-INF/classes/application-dev.yml
  9. +3
    -1
      tuoheng_oidc_admin/target/classes/application-dev.yml
  10. +3
    -1
      tuoheng_oidc_admin/target/classes/application-test.yml
  11. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/constant/HhzUrlConstant.class
  12. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/controller/TenantController.class

+ 5
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/HhzUrlConstant.java Ver arquivo

@@ -35,6 +35,11 @@ public class HhzUrlConstant {
*/
public static final String FIND_ROLE = "/oidcTenant/getRoleList";

/**
* 查询可用角色
*/
public static final String FIND_MENU = "/oidcTenant/getMenuList/{roleId}";





+ 14
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/third/controller/ThirdController.java Ver arquivo

@@ -2,6 +2,7 @@ package com.tuoheng.third.controller;

import com.tuoheng.model.dto.LoginUser;
import com.tuoheng.service.CurrentUser;
import com.tuoheng.third.request.ThirdRequest;
import com.tuoheng.third.service.ThirdService;
import com.tuoheng.until.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
@@ -41,4 +42,17 @@ public class ThirdController {
public JsonResult getRoleList(String clientId, @CurrentUser LoginUser loginUser) {
return thirdService.getRoleList(clientId, loginUser);
}

/**
* 查询对应业务平台角色对应的菜单
*
* @param request 请求参数
* @param loginUser
* @return
*/
@GetMapping("/getMenuList")
public JsonResult getMenuList(ThirdRequest request, @CurrentUser LoginUser loginUser) {
return thirdService.getMenuList(request, loginUser);
}

}

+ 19
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/third/request/ThirdRequest.java Ver arquivo

@@ -0,0 +1,19 @@
package com.tuoheng.third.request;

import lombok.Data;

/**
* @Author xiaoying
* @Date 2023/3/8 10:34
*/
@Data
public class ThirdRequest {
/**
* 角色id
*/
private Integer roleId;
/**
* 平台标识
*/
private String clientId;
}

+ 9
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/third/service/ThirdService.java Ver arquivo

@@ -1,6 +1,7 @@
package com.tuoheng.third.service;

import com.tuoheng.model.dto.LoginUser;
import com.tuoheng.third.request.ThirdRequest;
import com.tuoheng.until.JsonResult;

public interface ThirdService {
@@ -18,4 +19,12 @@ public interface ThirdService {
* @return
*/
JsonResult getRoleList(String clientId, LoginUser loginUser);
/**
* 查询对应业务平台角色对应的菜单
*
* @param request 角色id
* @param loginUser
* @return
*/
JsonResult getMenuList(ThirdRequest request, LoginUser loginUser);
}

+ 73
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/third/service/impl/ThirdServiceImpl.java Ver arquivo

@@ -12,18 +12,23 @@ 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.request.ThirdRequest;
import com.tuoheng.third.service.ThirdService;
import com.tuoheng.third.vo.IndustryVo;
import com.tuoheng.third.vo.RoleMenuVo;
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.util.LinkedMultiValueMap;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;

/**
* @Author xiaoying
@@ -92,6 +97,74 @@ public class ThirdServiceImpl implements ThirdService {
return JsonResult.success(clientRoleListDtos);
}

/**
* 查询对应业务平台角色对应的菜单
*
* @param request 请求参数
* @param loginUser
* @return
*/
@Override
public JsonResult getMenuList(ThirdRequest request, LoginUser loginUser) {

if (ObjectUtil.isEmpty(request.getClientId()) || ObjectUtil.isNull(request.getRoleId())) {
return JsonResult.error("请求参数有误!");

}
RoleMenuVo vo = getRoleMenuVoByThirdRequest(request, loginUser);

return JsonResult.success(vo);
}

/**
* 获取对应业务平台的角色对应的菜单列表
*
* @param request
* @param loginUser
* @return
*/
private RoleMenuVo getRoleMenuVoByThirdRequest(ThirdRequest request, LoginUser loginUser) {

Platform platform = platformMapper.selectOne(Wrappers.<Platform>lambdaQuery()
.eq(Platform::getPlatformCode, request.getClientId())
.eq(Platform::getMark, 1));
if (ObjectUtil.isNull(platform)) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "该业务平台不存在");
}
RoleMenuVo vo = new RoleMenuVo();
vo.setRoleId(request.getRoleId());

String url = "";

switch (platform.getPlatformCode()) {
//河湖长
case HhzUrlConstant.HHZ_CLIENT:
url = String.format(Locale.ENGLISH, "%s%s", platform.getPlatformUrl(), HhzUrlConstant.FIND_MENU);
break;
default:
break;
}
ParameterizedTypeReference<JsonResult<RoleMenuVo>> parameterizedTypeReference =
new ParameterizedTypeReference<JsonResult<RoleMenuVo>>() {
};
ResponseEntity<JsonResult<RoleMenuVo>> 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, request.getRoleId());
} 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(), "获取菜单表响应失败!");
}

return response.getBody().getData();
}

/**
* 访问对应系统获取对应业务平台可关联的角色
*

+ 26
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/third/vo/MenuVo.java Ver arquivo

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

import lombok.Data;

/**
* @Author xiaoying
* @Date 2023/3/8 10:31
*/
@Data
public class MenuVo {
/**
* 菜单id
*/
private Integer id;

/**
* 菜单名称
*/
private String name;
/**
* 父级ID
*/
private Integer parentId;


}

+ 21
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/third/vo/RoleMenuVo.java Ver arquivo

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

import lombok.Data;

import java.util.List;

/**
* @Author xiaoying
* @Date 2023/3/8 10:30
*/
@Data
public class RoleMenuVo {
/**
* 角色id
*/
private Integer roleId;
/**
*对应的菜单集合->及子菜单(按钮)
*/
private List<MenuVo> opMenusList;
}

+ 3
- 1
tuoheng_oidc_admin/target/classes/WEB-INF/classes/application-dev.yml Ver arquivo

@@ -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/target/classes/application-dev.yml Ver arquivo

@@ -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/target/classes/application-test.yml Ver arquivo

@@ -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

BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/constant/HhzUrlConstant.class Ver arquivo


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/controller/TenantController.class Ver arquivo


Carregando…
Cancelar
Salvar