RemoteCUserService.java
3.51 KB
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
package cn.com.glsx.admin.modules.remote;
import cn.com.glsx.usercenter.api.dto.response.CUser;
import cn.com.glsx.usercenter.api.feign.CUserService;
import com.glsx.plat.core.web.R;
import com.google.common.collect.Lists;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@Slf4j
@Service
public class RemoteCUserService {
@Autowired
private CUserService cUserService;
/**
* 根据C端用户id获取本地C端账号用户信息
*
* @param cuserIds
* @return
*/
public List<CUser> getLocalUsers(Collection<Long> cuserIds) {
if (CollectionUtils.isEmpty(cuserIds)) {
return Lists.newArrayList();
}
R<List<CUser>> listR = cUserService.getLocalCUsers(cuserIds);
if (listR == null || !listR.isSuccess()) {
return Lists.newArrayList();
}
List<CUser> cuserList = listR.getDataList(new TypeToken<List<CUser>>() {
}.getType());
return cuserList;
}
/**
* 根据C端用户id获取本地C端账号用户信息
*
* @param cuserIds
* @return
*/
public Map<Long, CUser> getLocalUserMap(Collection<Long> cuserIds) {
List<CUser> userModelList = this.getLocalUsers(cuserIds);
return userModelList.stream().collect(Collectors.toMap(CUser::getUserId, Function.identity(), (o, n) -> n));
}
/**
* 根据后台账号用户id获取对应C端用户信息(实际同后台账号信息)
*
* @param relUserIds
* @return
*/
public List<CUser> getLocalRelUsers(Collection<Long> relUserIds) {
if (CollectionUtils.isEmpty(relUserIds)) {
return Lists.newArrayList();
}
R<List<CUser>> listR = cUserService.getLocalRelCUsers(relUserIds);
if (listR == null || !listR.isSuccess()) {
return Lists.newArrayList();
}
List<CUser> cuserList = listR.getDataList(new TypeToken<List<CUser>>() {
}.getType());
return cuserList;
}
public Map<Long, CUser> getLocalRelUserMap(Collection<Long> relUserIds) {
List<CUser> userModelList = this.getLocalRelUsers(relUserIds);
return userModelList.stream().filter(um -> um.getRelUserId() != null).collect(Collectors.toMap(CUser::getRelUserId, Function.identity(), (o, n) -> n));
}
/**
* 根据C端用户id获取微信账号用户信息
*
* @param cuserIds
* @return
*/
public List<CUser> getWechatUsers(Collection<Long> cuserIds) {
if (CollectionUtils.isEmpty(cuserIds)) {
return Lists.newArrayList();
}
R<List<CUser>> listR = cUserService.getWechatUsers(cuserIds);
if (listR == null || !listR.isSuccess()) {
return Lists.newArrayList();
}
return listR.getDataList(new TypeToken<List<CUser>>() {
}.getType());
}
/**
* 根据C端用户id获取微信账号用户信息
*
* @param cuserIds
* @return
*/
public Map<Long, CUser> getWechatUserMap(Collection<Long> cuserIds) {
List<CUser> userModelList = this.getWechatUsers(cuserIds);
return userModelList.stream().collect(Collectors.toMap(CUser::getUserId, Function.identity(), (o, n) -> n));
}
}