forked from gzzfw/backEnd/gz-dyh

xusd
2024-10-14 d651a004647ed5ce63c79e56616d9ba961f10b00
dyh-service/dyh-cust/src/main/java/cn/huge/module/client/api/impl/SysClientImpl.java
@@ -1,18 +1,29 @@
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.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;
/**
@@ -41,24 +52,70 @@
    /**
     * 根据用户token获取用户信息
     * @url {ctx}/api/thrid/grid/user/get-userinfo
     *
     * @param gridTokenBaseDTO
     * @return
     * @url {ctx}/api/thrid/grid/user/get-userinfo
     */
    public GridUserBaseDTO getUserInfo(GridTokenBaseDTO gridTokenBaseDTO){
    public GridUserBaseDTO getUserInfo(GridTokenBaseDTO gridTokenBaseDTO) {
        GridUserBaseDTO gridUserBaseDTO = null;
        try{
        try {
            ReturnBO returnBo = sysClient.getUserInfo(gridTokenBaseDTO);
            if (ReturnConsts.OK == returnBo.getCode()){
            if (ReturnConsts.OK == returnBo.getCode()) {
                gridUserBaseDTO = objectMapper.convertValue(returnBo.getData(), GridUserBaseDTO.class);
            }else{
            } 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);
        } catch (Exception e) {
            log.error("service方法[SysClientImpl.getUserInfo]调用异常:" + e, e);
        }
        return gridUserBaseDTO;
    }
    /**
     * @param gridUserRoleVo
     * @return 返回当前登录使用的机构角色
     */
    public GridUserRoleDTO getUserRoleList(GridUserRoleVo gridUserRoleVo) {
        GridUserRoleDTO roleDTO = 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()) {
                    BeanUtils.copyProperties(item, roleDTO);
                    break;
                }
            }
        }
        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;
    }
}