|
|
|
|
|
|
|
|
import com.tuoheng.model.dto.LoginUser; |
|
|
import com.tuoheng.model.dto.LoginUser; |
|
|
import com.tuoheng.model.dto.Platform; |
|
|
import com.tuoheng.model.dto.Platform; |
|
|
import com.tuoheng.model.dto.RoleDto; |
|
|
import com.tuoheng.model.dto.RoleDto; |
|
|
|
|
|
import com.tuoheng.third.request.ThirdRequest; |
|
|
import com.tuoheng.third.service.ThirdService; |
|
|
import com.tuoheng.third.service.ThirdService; |
|
|
import com.tuoheng.third.vo.IndustryVo; |
|
|
import com.tuoheng.third.vo.IndustryVo; |
|
|
|
|
|
import com.tuoheng.third.vo.RoleMenuVo; |
|
|
import com.tuoheng.until.JsonResult; |
|
|
import com.tuoheng.until.JsonResult; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.core.ParameterizedTypeReference; |
|
|
import org.springframework.core.ParameterizedTypeReference; |
|
|
import org.springframework.http.*; |
|
|
import org.springframework.http.*; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import org.springframework.util.LinkedMultiValueMap; |
|
|
import org.springframework.web.client.RestTemplate; |
|
|
import org.springframework.web.client.RestTemplate; |
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.LinkedHashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Locale; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Author xiaoying |
|
|
* @Author xiaoying |
|
|
|
|
|
|
|
|
return JsonResult.success(clientRoleListDtos); |
|
|
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(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 访问对应系统获取对应业务平台可关联的角色 |
|
|
* 访问对应系统获取对应业务平台可关联的角色 |
|
|
* |
|
|
* |