package cn.huge.module.client.api.impl;
|
|
import cn.huge.base.common.bo.R;
|
import cn.huge.base.common.bo.ReturnBO;
|
import cn.huge.base.common.constant.ReturnConsts;
|
import cn.huge.base.common.exception.ClientException;
|
import cn.huge.base.common.exception.ServiceException;
|
import cn.huge.module.client.api.SysClient;
|
import cn.huge.module.client.api.UtilsClient;
|
import cn.huge.module.ctuser.domain.po.CtUserole;
|
import cn.huge.module.cust.dto.CtUnitDTO;
|
import cn.huge.module.sys.dto.GridRoleMenuDTO;
|
import cn.huge.module.sys.dto.GridTokenBaseDTO;
|
import cn.huge.module.sys.dto.GridUserBaseDTO;
|
import cn.huge.module.sys.dto.GridUserRoleDTO;
|
import cn.huge.module.sys.vo.GridRoleMenuVo;
|
import cn.huge.module.sys.vo.GridUserRoleVo;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import java.util.List;
|
|
|
/**
|
* @title: 系统服务微服务调用接口
|
* @description: 系统服务微服务调用接口
|
* @company: hugeinfo
|
* @author: liyj
|
* @time: 2021-11-05 16:51:48
|
* @version: 1.0.0
|
*/
|
@Slf4j
|
@Component
|
public class SysClientImpl {
|
|
private SysClient sysClient;
|
|
/**
|
* ObjectMapper工具类
|
*/
|
private ObjectMapper objectMapper = new ObjectMapper();
|
|
@Autowired
|
public SysClientImpl(SysClient sysClient) {
|
this.sysClient = sysClient;
|
}
|
|
/**
|
* 根据用户token获取用户信息
|
*
|
* @param gridTokenBaseDTO
|
* @return
|
* @url {ctx}/api/thrid/grid/user/get-userinfo
|
*/
|
public GridUserBaseDTO getUserInfo(GridTokenBaseDTO gridTokenBaseDTO) {
|
GridUserBaseDTO gridUserBaseDTO = null;
|
try {
|
ReturnBO returnBo = sysClient.getUserInfo(gridTokenBaseDTO);
|
if (ReturnConsts.OK == returnBo.getCode()) {
|
gridUserBaseDTO = objectMapper.convertValue(returnBo.getData(), GridUserBaseDTO.class);
|
} else {
|
log.error("Client外服务接口[SysClientImpl.getUserInfo]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
|
throw new ClientException("SysClientImpl.getUserInfo", returnBo.getMsg());
|
}
|
} catch (Exception e) {
|
log.error("service方法[SysClientImpl.getUserInfo]调用异常:" + e, e);
|
}
|
return gridUserBaseDTO;
|
}
|
|
/**
|
* @param gridUserRoleVo
|
* @return 返回当前登录使用的机构角色
|
*/
|
public GridUserRoleDTO getUserRoleList(GridUserRoleVo gridUserRoleVo) {
|
GridUserRoleDTO roleDTO = new GridUserRoleDTO();
|
GridUserRoleDTO nowRoleDTO = new GridUserRoleDTO();
|
R<List<GridUserRoleDTO>> userRoleList = sysClient.getUserRoleList(gridUserRoleVo);
|
if (userRoleList.getCode() == R.SUCCESS) {
|
List<GridUserRoleDTO> data = userRoleList.getData();
|
for (GridUserRoleDTO item : data) {
|
if (item.isLastOrgRole() && item.getRoleName().contains("(M)")) {
|
BeanUtils.copyProperties(item, nowRoleDTO);
|
}
|
if (item.isLastOrgRole() && item.getRoleName().contains("调度干部")) {
|
BeanUtils.copyProperties(item, nowRoleDTO);
|
}
|
if (item.getRoleName().contains("(M)")) {
|
BeanUtils.copyProperties(item, roleDTO);
|
}
|
}
|
}
|
if (StringUtils.isNotEmpty(nowRoleDTO.getRoleId()))
|
return nowRoleDTO;
|
else
|
return roleDTO;
|
}
|
|
/**
|
* @param gridRoleMenuVo
|
* @return true管理员,全部权限;false,纠纷调解员,部分权限 //如果全部菜单权限,分配管理员角色;如果部分菜单权限,分配纠纷化解员角色
|
*/
|
public CtUserole getRoleMenu(GridRoleMenuVo gridRoleMenuVo) {
|
//需要等所有菜单权限确认后再编写后续逻辑
|
CtUserole ctUserole = new CtUserole();
|
|
R<List<GridRoleMenuDTO>> roleMenu = sysClient.getRoleMenu(gridRoleMenuVo);
|
if (roleMenu.getCode() == R.SUCCESS) {
|
List<GridRoleMenuDTO> data = roleMenu.getData();
|
if (data.size() > 0) {
|
String name = data.get(0).getName();
|
if ("矛盾纠纷化解子系统".equals(name)) {
|
List<GridRoleMenuDTO> children = data.get(0).getChildren();
|
|
} else {
|
|
}
|
ctUserole.setRoleId("22_00024-4");
|
ctUserole.setRoleName("纠纷化解人员");
|
}
|
}
|
return ctUserole;
|
}
|
|
}
|