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