yaoh.wu
7 years ago
7 changed files with 92 additions and 47 deletions
@ -1,49 +1,38 @@
|
||||
package com.fr.design.remote; |
||||
|
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.base.FRContext; |
||||
import com.fr.decision.webservice.bean.user.UserAdditionBean; |
||||
import com.fr.decision.webservice.v10.user.UserService; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Collection; |
||||
import java.util.List; |
||||
import java.util.Random; |
||||
import java.util.Map; |
||||
|
||||
public class Utils { |
||||
|
||||
private static final String SOURCES = |
||||
"._-~`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"; |
||||
|
||||
private Utils() { |
||||
|
||||
} |
||||
|
||||
public static Collection<? extends RemoteMember> getRemoteMember(String keyword) { |
||||
// todo 使用决策平台api获取决策平台用户
|
||||
List<RemoteMember> res = new ArrayList<>(); |
||||
for (int i = 0; i < 30; i++) { |
||||
RemoteMember remoteMember = new RemoteMember(generate()); |
||||
if (StringUtils.isEmpty(keyword)) { |
||||
res.add(remoteMember); |
||||
continue; |
||||
} |
||||
if (remoteMember.getName().contains(keyword)) { |
||||
res.add(remoteMember); |
||||
} |
||||
} |
||||
return res; |
||||
|
||||
List<UserAdditionBean> userBeans = new ArrayList<>(); |
||||
try { |
||||
Map<String, Object> result = UserService.getInstance().getAllUsers(FRContext.getCurrentEnv().getUser(), 1, 10, keyword, "", true); |
||||
userBeans = (List<UserAdditionBean>) result.get("items"); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
List<RemoteMember> res = new ArrayList<>(); |
||||
|
||||
/** |
||||
* Generate a random string. |
||||
* |
||||
* @return String string |
||||
*/ |
||||
private static String generate() { |
||||
Random random = new Random(); |
||||
char[] text = new char[6]; |
||||
for (int i = 0; i < 6; i++) { |
||||
text[i] = Utils.SOURCES.charAt(random.nextInt(Utils.SOURCES.length())); |
||||
for (UserAdditionBean userBean : userBeans) { |
||||
res.add(new RemoteMember(userBean.getUsername()) |
||||
.realName(userBean.getRealName()) |
||||
.userId(userBean.getId()) |
||||
); |
||||
} |
||||
return new String(text); |
||||
return res; |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue