package cn.huge.module.client.api.impl;
|
|
import cn.huge.base.common.bo.ReturnBO;
|
import cn.huge.base.common.constant.ReturnConsts;
|
import cn.huge.base.common.dto.SelectTermDTO;
|
import cn.huge.base.common.exception.ClientException;
|
import cn.huge.base.common.exception.ServiceException;
|
import cn.huge.module.client.api.CustClient;
|
import cn.huge.module.cust.dto.CtUserDTO;
|
import cn.huge.module.cust.dto.PaUserDTO;
|
import com.alibaba.fastjson.JSON;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import java.util.ArrayList;
|
import java.util.LinkedHashMap;
|
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 CustClientImpl {
|
|
private CustClient custClient;
|
|
@Autowired
|
public CustClientImpl(CustClient custClient) {
|
this.custClient = custClient;
|
}
|
|
/**
|
* ObjectMapper工具类
|
*/
|
private ObjectMapper objectMapper = new ObjectMapper();
|
|
/**
|
* 内部用户-获取登录用户
|
* @param userId 用户编号
|
* @return CtUserDTO
|
*/
|
public CtUserDTO clientGetUser(String userId){
|
try{
|
ReturnBO returnBo = custClient.clientGetUser(userId);
|
if (ReturnConsts.OK == returnBo.getCode()){
|
CtUserDTO loginUser = objectMapper.convertValue(returnBo.getData(), CtUserDTO.class);
|
return loginUser;
|
}else{
|
log.error("Client外服务接口[CustClientImpl.clientGetUser]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
|
throw new ClientException("CustClientImpl.clientGetUser", returnBo.getMsg());
|
}
|
}catch (Exception e){
|
log.error("service方法[CustClientImpl.clientGetUser]调用异常:"+e, e);
|
throw new ServiceException("CustClientImpl.clientGetUser", e);
|
}
|
}
|
|
/**
|
* 内部用户-获取登录用户
|
* @param userId
|
* @return
|
*/
|
public CtUserDTO clientGetUserAll(String userId){
|
try{
|
ReturnBO returnBo = custClient.clientGetUserAll(userId);
|
if (ReturnConsts.OK == returnBo.getCode()){
|
CtUserDTO loginUser = objectMapper.convertValue(returnBo.getData(), CtUserDTO.class);
|
return loginUser;
|
}else{
|
log.error("Client外服务接口[CustClientImpl.clientGetUserAll]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
|
throw new ClientException("CustClientImpl.clientGetUserAll", returnBo.getMsg());
|
}
|
}catch (Exception e){
|
log.error("service方法[CustClientImpl.clientGetUserAll]调用异常:"+e, e);
|
throw new ServiceException("CustClientImpl.clientGetUserAll", e);
|
}
|
}
|
|
/**
|
* 当事人-获取登录用户
|
* @param userId 用户编号
|
* @return
|
*/
|
public PaUserDTO paclientGetUser(String userId){
|
try{
|
ReturnBO returnBo = custClient.paclientGetUser(userId);
|
if (ReturnConsts.OK == returnBo.getCode()){
|
PaUserDTO loginUser = objectMapper.convertValue(returnBo.getData(), PaUserDTO.class);
|
return loginUser;
|
}else{
|
log.error("Client外服务接口[CustClientImpl.paclientGetUser]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
|
throw new ClientException("CustClientImpl.paclientGetUser", returnBo.getMsg());
|
}
|
}catch (Exception e){
|
log.error("service方法[CustClientImpl.paclientGetUser]调用异常:"+e, e);
|
throw new ServiceException("CustClientImpl.paclientGetUser", e);
|
}
|
}
|
|
/**
|
* 根据组织和角色查询
|
* @return unitId 组织编号
|
* @return roleCode 角色代码
|
* @return Object
|
*/
|
public List<CtUserDTO> listUserByUnitRole(@RequestParam(value = "unitId") String unitId, @RequestParam(value = "roleCode") String roleCode) {
|
List<CtUserDTO> ctUserDTOList = new ArrayList<>();
|
try{
|
ReturnBO returnBo = custClient.listUserByUnitRole(unitId, roleCode);
|
if (ReturnConsts.OK == returnBo.getCode()){
|
List<LinkedHashMap> list = (List<LinkedHashMap>) returnBo.getData();
|
for (LinkedHashMap map : list) {
|
CtUserDTO ctUserDTO = JSON.parseObject(JSON.toJSONString(map), CtUserDTO.class);
|
ctUserDTOList.add(ctUserDTO);
|
}
|
return ctUserDTOList;
|
}else{
|
log.error("Client外服务接口[CustClientImpl.listUserByUnitRole]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
|
throw new ClientException("CustClientImpl.listUserByUnitRole", returnBo.getMsg());
|
}
|
}catch (Exception e){
|
log.error("service方法[CustClientImpl.listUserByUnitRole]调用异常:"+e, e);
|
throw new ServiceException("CustClientImpl.listUserByUnitRole", e);
|
}
|
}
|
|
/**
|
* 根据部门和角色查询
|
* @return deptId 部门编号
|
* @return roleCode 角色代码
|
* @return Object
|
*/
|
public List<CtUserDTO> listUserByDeptRole(@RequestParam(value = "deptId") String deptId, @RequestParam(value = "roleCode") String roleCode) {
|
List<CtUserDTO> ctUserDTOList = new ArrayList<>();
|
try{
|
ReturnBO returnBo = custClient.listUserByDeptRole(deptId, roleCode);
|
if (ReturnConsts.OK == returnBo.getCode()){
|
List<LinkedHashMap> list = (List<LinkedHashMap>) returnBo.getData();
|
for (LinkedHashMap map : list) {
|
CtUserDTO ctUserDTO = JSON.parseObject(JSON.toJSONString(map), CtUserDTO.class);
|
ctUserDTOList.add(ctUserDTO);
|
}
|
return ctUserDTOList;
|
}else{
|
log.error("Client外服务接口[CustClientImpl.listUserByDeptRole]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
|
throw new ClientException("CustClientImpl.listUserByDeptRole", returnBo.getMsg());
|
}
|
}catch (Exception e){
|
log.error("service方法[CustClientImpl.listUserByDeptRole]调用异常:"+e, e);
|
throw new ServiceException("CustClientImpl.listUserByDeptRole", e);
|
}
|
}
|
|
/**
|
* 查询客户下的法院
|
* @param userId
|
* @return
|
*/
|
public List<SelectTermDTO> listCourt1(String userId){
|
List<SelectTermDTO> selectTermDTOList = new ArrayList<>();
|
try{
|
ReturnBO returnBo = custClient.listCourt1(userId);
|
if (ReturnConsts.OK == returnBo.getCode()){
|
List<LinkedHashMap> list = (List<LinkedHashMap>) returnBo.getData();
|
for (LinkedHashMap map : list) {
|
SelectTermDTO selectTermDTO = JSON.parseObject(JSON.toJSONString(map), SelectTermDTO.class);
|
selectTermDTOList.add(selectTermDTO);
|
}
|
return selectTermDTOList;
|
}else{
|
log.error("Client外服务接口[CustClientImpl.listCourt1]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
|
throw new ClientException("CustClientImpl.listCourt1", returnBo.getMsg());
|
}
|
}catch (Exception e){
|
log.error("service方法[CustClientImpl.listCourt1]调用异常:"+e, e);
|
throw new ServiceException("CustClientImpl.listCourt1", e);
|
}
|
}
|
}
|