郑永安
2023-06-19 7a6abd05683528032687c75e80e0bd2030a3e46c
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
122
123
124
125
126
127
128
129
package com.gkhy.safePlatform.account.rpc.test;
 
import com.gkhy.safePlatform.account.entity.schedule.GroupInfoDO;
import com.gkhy.safePlatform.account.enums.schedule.GroupStatusEnum;
import com.gkhy.safePlatform.account.model.dto.resp.GroupInfoRespDTO;
import com.gkhy.safePlatform.account.rpc.apimodel.AccountGroupService;
import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.GroupRPCRespDTO;
import com.gkhy.safePlatform.account.service.GroupService;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.exception.AusinessException;
import com.gkhy.safePlatform.commons.exception.BusinessException;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
 
import java.util.*;
 
@DubboService
public class AccountGroupServiceProvider implements AccountGroupService {
 
 
    @Autowired
    private GroupService groupService;
 
 
    @Override
    public ResultVO<GroupRPCRespDTO> getGroupInfoByGroupId(Long groupId) {
        try {
            GroupInfoRespDTO groupInfo = groupService.getGroupInfoByGroupId(groupId);
            GroupRPCRespDTO result = null;
            if (groupInfo != null) {
                result = new GroupRPCRespDTO();
                result.setGroupId(groupInfo.getGroupId());
                result.setGroupName(groupInfo.getGroupName());
                result.setGroupInfo(groupInfo.getGroupInfo());
                result.setGroupStrategyId(groupInfo.getGroupStrategyId());
                result.setStatus(groupInfo.getStatus());
                result.setStatusDesc(groupInfo.getStatusDesc());
            }
            return new ResultVO<>(ResultCodes.OK,result);
        } catch (AusinessException e) {
            return new ResultVO<>(e.getCode(),e.getMessage());
        } catch (BusinessException e) {
            return new ResultVO<>(e.getCode(),e.getMessage());
        } catch (Exception e) {
//            return new ResultVO<>(ResultCodes.SERVER_ERROR);
            ResultVO resultVO = new ResultVO<>();
            resultVO.setCode(ResultCodes.SERVER_ERROR.getCode());
            return resultVO;
        }
 
 
    }
 
    @Override
    public ResultVO<List<GroupRPCRespDTO>> listGroupInfoByUid(Long uid) {
        try {
            List<GroupRPCRespDTO> result = Collections.emptyList();
            List<GroupInfoRespDTO> groupInfoRespDTOS = groupService.listGroupInfoByUid(uid);
            if (groupInfoRespDTOS != null && !groupInfoRespDTOS.isEmpty()) {
                GroupRPCRespDTO rpcRespDTO;
                result = new ArrayList<>(groupInfoRespDTOS.size());
                for (GroupInfoRespDTO respDTO : groupInfoRespDTOS) {
                    rpcRespDTO = new GroupRPCRespDTO();
                    rpcRespDTO.setGroupId(respDTO.getGroupId());
                    rpcRespDTO.setGroupName(respDTO.getGroupName());
                    rpcRespDTO.setGroupInfo(respDTO.getGroupInfo());
                    rpcRespDTO.setGroupStrategyId(respDTO.getGroupStrategyId());
                    rpcRespDTO.setStatus(respDTO.getStatus());
                    rpcRespDTO.setStatusDesc(respDTO.getStatusDesc());
                    result.add(rpcRespDTO);
                }
            }
        return new ResultVO<>(ResultCodes.OK,result);
        } catch (AusinessException e) {
            return new ResultVO<>(e.getCode(),e.getMessage());
        } catch (BusinessException e) {
            return new ResultVO<>(e.getCode(),e.getMessage());
        } catch (Exception e) {
//            return new ResultVO<>(ResultCodes.SERVER_ERROR);
            ResultVO resultVO = new ResultVO<>();
            resultVO.setCode(ResultCodes.SERVER_ERROR.getCode());
            return resultVO;
        }
    }
 
    @Override
    public ResultVO<GroupRPCRespDTO> getGroupInfoByUid(Long uid) {
        return null;
    }
 
    @Override
    public ResultVO<Map<Long, GroupRPCRespDTO>> listGroupMapByGroupIds(Collection<Long> groupIds) {
        try {
            Map<Long, GroupRPCRespDTO> resultMap = null;
            if (groupIds != null && groupIds.size() != 0) {
                List<GroupInfoRespDTO> groupInfoRespDTOS = groupService.listGroupInfoByGroupIds(groupIds);
                if (groupInfoRespDTOS.size() > 0) {
                    resultMap = new HashMap<>(groupInfoRespDTOS.size());
                    GroupRPCRespDTO mapItem;
                    for (GroupInfoRespDTO groupInfo : groupInfoRespDTOS) {
                        mapItem = new GroupRPCRespDTO();
                        mapItem.setGroupId(groupInfo.getGroupId());
                        mapItem.setGroupName(groupInfo.getGroupName());
                        mapItem.setGroupInfo(groupInfo.getGroupInfo());
                        mapItem.setStatus(groupInfo.getStatus());
                        mapItem.setStatusDesc(groupInfo.getStatusDesc());
                        mapItem.setGroupStrategyId(groupInfo.getGroupStrategyId());
                        resultMap.put(groupInfo.getGroupId(), mapItem);
                    }
                }
            }
            return new ResultVO<>(ResultCodes.OK, resultMap);
        } catch (AusinessException e) {
            return new ResultVO<>(e.getCode(),e.getMessage());
        } catch (BusinessException e) {
            return new ResultVO<>(e.getCode(),e.getMessage());
        } catch (Exception e) {
//            return new ResultVO<>(ResultCodes.SERVER_ERROR);
            ResultVO resultVO = new ResultVO<>();
            resultVO.setCode(ResultCodes.SERVER_ERROR.getCode());
            return resultVO;
        }
 
    }
 
 
}