添加用户名查找列表

This commit is contained in:
wanggeng888 2021-02-08 20:21:59 +08:00
parent 321d29c43e
commit 2681311767
3 changed files with 35 additions and 0 deletions

View File

@ -59,6 +59,11 @@ public interface IApiConsts {
*/
String LIST_USER_BY_ID = "%s/resource/user/listuserbyids";
/**
* 用户列表通过用户名
*/
String LIST_USER_BY_USERNAME = "%s/resource/user/listuserbyusernames";
/**
* 全部用户
*/

View File

@ -237,6 +237,16 @@ public interface IUserService {
*/
List<UserResourceBO> listUserResourceByIds(List<String> userIds) throws AccessTokenException, SearchException;
/**
* 用户列表
*
* @param usernames 用户名列表
* @return
* @throws AccessTokenException
* @throws SearchException
*/
List<UserResourceBO> listUserResourceByUsernames(List<String> usernames) throws AccessTokenException, SearchException;
/**
* 用户动态详情列表通过id列表
*

View File

@ -224,6 +224,26 @@ public class UserServiceImpl extends AbstractService implements IUserService {
return JSONArray.parseArray(result, UserResourceBO.class);
}
@Override
public List<UserResourceBO> listUserResourceByUsernames(List<String> usernames) throws AccessTokenException, SearchException {
if (usernames == null || usernames.isEmpty()) {
return new ArrayList<>();
}
StringBuilder usernamesSB = new StringBuilder();
for (String username : usernames) {
if (usernamesSB.length() > 0) {
usernamesSB.append("_");
}
usernamesSB.append(username);
}
Map<String, Object> params = getHashMap(4);
params.put("usernames", usernamesSB.toString());
params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken());
String result = restTemplateUtil.doPostFormNormal(String.format(IApiConsts.LIST_USER_BY_USERNAME, apiPathProperties.getUserCenter()), params);
searchResourceResult(result, "获取人员列表失败");
return JSONArray.parseArray(result, UserResourceBO.class);
}
@Override
public JSONArray listDynamicUserInfoByIds(List<String> userIds) throws AccessTokenException, SearchException {
if (userIds == null || userIds.isEmpty()) {