forked from gzzfw/backEnd/gz-dyh

xusd
2024-10-14 d651a004647ed5ce63c79e56616d9ba961f10b00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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;
 
 
/**
 * @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();
        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;
    }
 
}