From 4a3e1b1602f7579dcd2f1269f1e3794ceb46f384 Mon Sep 17 00:00:00 2001 From: wenc000 <450292408@qq.com> Date: Thu, 12 Nov 2020 17:39:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/cm/common/plugin/IApiConsts.java | 5 +++++ .../plugin/oauth/service/user/IUserService.java | 12 ++++++++++++ .../oauth/service/user/impl/UserServiceImpl.java | 15 +++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/IApiConsts.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/IApiConsts.java index 71e4917..0675467 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/IApiConsts.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/IApiConsts.java @@ -196,4 +196,9 @@ public interface IApiConsts { */ String SEND_DINGDING_MSG_BY_PHONES = "%s/resource/dingdingmessage/sendbyphones"; + /** + * 资源用户列表 + */ + String LIST_USER_RESOURCE_BY_KEYWORDS = "%s/resource/user/listresourcebykeywords/%s"; + } 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 fb8488c..ed7a25e 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 @@ -11,6 +11,7 @@ import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultList; import org.aspectj.lang.annotation.DeclareError; +import java.io.UnsupportedEncodingException; import java.util.List; import java.util.Map; @@ -349,4 +350,15 @@ public interface IUserService { * @throws SearchException */ JSONArray listUserByIds(Map params) throws AccessTokenException, SearchException; + + /** + * 用户资源列表 + * + * @param keywords 关键字 + * @return + * @throws AccessTokenException + * @throws SearchException + */ + List listResourceByKeywords(String keywords) throws AccessTokenException, SearchException, UnsupportedEncodingException; + } 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 d201cef..b05b8f7 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 @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; import com.cm.common.base.AbstractService; import com.cm.common.component.OAuthRestTemplateComponent; import com.cm.common.config.properties.ApiPathProperties; +import com.cm.common.constants.ISystemConstant; import com.cm.common.exception.AccessTokenException; import com.cm.common.exception.SearchException; import com.cm.common.plugin.IApiConsts; @@ -22,6 +23,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.print.attribute.standard.PageRanges; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.*; /** @@ -409,4 +412,16 @@ public class UserServiceImpl extends AbstractService implements IUserService { searchResourceResult(result, "获取人员列表失败"); return JSONArray.parseArray(result); } + + @Override + public List listResourceByKeywords(String keywords) throws AccessTokenException, SearchException { + if(StringUtils.isBlank(keywords)) { + return new ArrayList<>(); + } + Map params = getHashMap(2); + params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken()); + String result = restTemplateUtil.doGetFormNormal(String.format(IApiConsts.LIST_USER_RESOURCE_BY_KEYWORDS, apiPathProperties.getUserCenter(), keywords), params); + searchResourceResult(result, "获取人员资源列表失败"); + return JSONArray.parseArray(result, UserResourceBO.class); + } }