From b7f285bfa44650d77d56a631c74fb07893da7365 Mon Sep 17 00:00:00 2001 From: WenG <450292408@qq.com> Date: Mon, 14 Sep 2020 18:22:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=83=A8=E5=88=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../oauth/service/user/IUserService.java | 24 ++++++++++++++++++ .../service/user/impl/UserServiceImpl.java | 25 ++++++++++++++++--- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/IUserService.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/IUserService.java index 117d5a8..c9340e5 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/IUserService.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/IUserService.java @@ -7,6 +7,7 @@ import com.cm.common.exception.SearchException; import com.cm.common.plugin.pojo.bos.UserResourceBO; import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultList; +import org.aspectj.lang.annotation.DeclareError; import java.util.List; import java.util.Map; @@ -30,6 +31,7 @@ public interface IUserService { * @throws AccessTokenException * @throws SearchException */ + @Deprecated JSONArray listDepartmentUsers(Map params) throws AccessTokenException, SearchException; /** @@ -40,6 +42,7 @@ public interface IUserService { * @throws AccessTokenException * @throws SearchException */ + @Deprecated JSONArray listRoleUsers(Map params) throws AccessTokenException, SearchException; /** @@ -50,6 +53,7 @@ public interface IUserService { * @throws AccessTokenException * @throws SearchException */ + @Deprecated JSONArray listGroupUsers(Map params) throws AccessTokenException, SearchException; /** @@ -60,6 +64,7 @@ public interface IUserService { * @throws AccessTokenException * @throws SearchException */ + @Deprecated JSONArray listPositionUsers(Map params) throws AccessTokenException, SearchException; /** @@ -70,6 +75,7 @@ public interface IUserService { * @throws AccessTokenException * @throws SearchException */ + @Deprecated JSONArray listUserByIds(Map params) throws AccessTokenException, SearchException; /** @@ -80,6 +86,7 @@ public interface IUserService { * @throws AccessTokenException * @throws SearchException */ + @Deprecated JSONArray listAllUsers(Map params) throws AccessTokenException, SearchException; /** @@ -90,6 +97,7 @@ public interface IUserService { * @throws AccessTokenException * @throws SearchException */ + @Deprecated JSONArray listUserDepartmentUser(Map userParams) throws AccessTokenException, SearchException; /** @@ -100,6 +108,7 @@ public interface IUserService { * @throws AccessTokenException * @throws SearchException */ + @Deprecated JSONArray listUserDepartmentUserByRole(Map params) throws AccessTokenException, SearchException; /** @@ -109,6 +118,7 @@ public interface IUserService { * @param userParams * @return */ + @Deprecated JSONArray listUserDepartmentUserByRole(String token, Map userParams) throws SearchException; /** @@ -119,6 +129,7 @@ public interface IUserService { * @throws AccessTokenException * @throws SearchException */ + @Deprecated JSONArray listUserDepartmentUserByPosition(Map params) throws AccessTokenException, SearchException; /** @@ -129,6 +140,7 @@ public interface IUserService { * @throws AccessTokenException * @throws SearchException */ + @Deprecated JSONObject getUserDetail(Map params) throws AccessTokenException, SearchException; /** @@ -140,6 +152,7 @@ public interface IUserService { * @throws AccessTokenException * @throws SearchException */ + @Deprecated JSONArray listRoleUsers(String accessToken, Map params) throws AccessTokenException, SearchException; /** @@ -221,6 +234,16 @@ public interface IUserService { */ SuccessResultList> listPageUserSimple(Map params) throws AccessTokenException, SearchException; + /** + * 用户列表(通过用户Id列表) + * + * @param userIds + * @return + * @throws AccessTokenException + * @throws SearchException + */ + List listUserResourceByIds(List userIds) throws AccessTokenException, SearchException; + /** * 用户动态详情列表(通过id列表) * @@ -233,6 +256,7 @@ public interface IUserService { /** * 用户详情 + * * @param userId * @return * @throws AccessTokenException diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/impl/UserServiceImpl.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/impl/UserServiceImpl.java index 40d5bbe..f7beaa4 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/impl/UserServiceImpl.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/impl/UserServiceImpl.java @@ -19,10 +19,7 @@ import org.apache.poi.util.StringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * When you feel like quitting. Think about why you started @@ -198,6 +195,26 @@ public class UserServiceImpl extends AbstractService implements IUserService { return successResult; } + @Override + public List listUserResourceByIds(List userIds) throws AccessTokenException, SearchException { + if (userIds.isEmpty()) { + return new ArrayList<>(); + } + StringBuilder userIdsSB = new StringBuilder(); + for (String userId : userIds) { + if (userIdsSB.length() > 0) { + userIdsSB.append("_"); + } + userIdsSB.append(userId); + } + Map params = getHashMap(4); + params.put("userIds", userIdsSB.toString()); + params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken()); + String result = restTemplateUtil.doPostForm(String.format(IApiConsts.LIST_USER_BY_ID, apiPathProperties.getUserCenter()), params); + searchResourceResult(result, "获取人员列表失败"); + return JSONArray.parseArray(result, UserResourceBO.class); + } + @Override public JSONArray listDynamicUserInfoByIds(List userIds) throws AccessTokenException, SearchException { if (userIds.isEmpty()) {