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 bf2194a..77c5010 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 @@ -122,4 +122,20 @@ public interface IApiConsts { * 角色zTree */ String LIST_ZTREE_ROLE = "%s/resource/role/listztreerole"; + /** + * 获取所有用户列表(通过上级区域ID) + */ + String LIST_USER_ALL_BY_AREA_ID = "%s/resource/user/listuserallbyareaid"; + /** + * 获取所有用户ID列表(通过上级区域ID) + */ + String LIST_USER_ID_ALL_BY_AREA_ID = "%s/resource/user/listuseridallbyareaid"; + /** + * 获取用户列表(通过上级区域ID) + */ + String LIST_USER_BY_AREA_ID = "%s/resource/user/listuserbyareaid"; + /** + * 获取用户ID列表(通过上级区域ID) + */ + String LIST_USER_ID_BY_AREA_ID = "%s/resource/user/listuseridbyareaid"; } 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 305ab2d..1f4b91a 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 @@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cm.common.exception.AccessTokenException; import com.cm.common.exception.SearchException; +import com.cm.common.plugin.pojo.bos.UserResourceBO; import com.cm.common.result.SuccessResult; +import java.util.List; import java.util.Map; /** @@ -167,4 +169,45 @@ public interface IUserService { * @throws SearchException */ JSONArray listDepartmentUserByUserDepartmentId(JSONObject params) throws AccessTokenException, SearchException; + + /** + * 获取所有用户列表(通过上级区域ID) + * + * @param params,1级区域到5级区域,area1, area2, area3, area4, area5 + * @return + * @throws AccessTokenException + * @throws SearchException + */ + List listUserAllByAreaId(Map params) throws AccessTokenException, SearchException; + + /** + * 获取所有用户ID列表(通过上级区域ID) + * + * @param params,1级区域到5级区域,area1, area2, area3, area4, area5 + * @return + * @throws AccessTokenException + * @throws SearchException + */ + List listUserIdAllByAreaId(Map params) throws AccessTokenException, SearchException; + + /** + * 获取用户列表(通过上级区域ID) + * + * @param params,1级区域到5级区域,area1, area2, area3, area4, area5 + * @return + * @throws AccessTokenException + * @throws SearchException + */ + List listUserByAreaId(Map params) throws AccessTokenException, SearchException; + + /** + * 获取用户列表(通过上级区域ID) + * + * @param params 1级区域到5级区域,area1, area2, area3, area4, area5 + * @return + * @throws AccessTokenException + * @throws SearchException + */ + List listUserIdByAreaId(Map params) throws AccessTokenException, SearchException; + } 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 4d38788..5dc26ed 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 @@ -10,12 +10,14 @@ import com.cm.common.exception.SearchException; import com.cm.common.plugin.IApiConsts; import com.cm.common.plugin.oauth.service.user.IUserService; import com.cm.common.plugin.oauth.token.ClientTokenManager; +import com.cm.common.plugin.pojo.bos.UserResourceBO; import com.cm.common.plugin.utils.RestTemplateUtil; import com.cm.common.result.SuccessResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -147,4 +149,36 @@ public class UserServiceImpl extends AbstractService implements IUserService { return JSONArray.parseArray(result); } + @Override + public List listUserAllByAreaId(Map params) throws AccessTokenException, SearchException { + params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken()); + String result = restTemplateUtil.doGetFormNormal(String.format(IApiConsts.LIST_USER_ALL_BY_AREA_ID, apiPathProperties.getUserCenter()), params); + searchResourceResult(result, "获取所有用户列表失败"); + return JSONArray.parseArray(result, UserResourceBO.class); + } + + @Override + public List listUserIdAllByAreaId(Map params) throws AccessTokenException, SearchException { + params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken()); + String result = restTemplateUtil.doGetFormNormal(String.format(IApiConsts.LIST_USER_ID_ALL_BY_AREA_ID, apiPathProperties.getUserCenter()), params); + searchResourceResult(result, "获取所有用户ID列表失败"); + return JSONArray.parseArray(result, String.class); + } + + @Override + public List listUserByAreaId(Map params) throws AccessTokenException, SearchException { + params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken()); + String result = restTemplateUtil.doGetFormNormal(String.format(IApiConsts.LIST_USER_BY_AREA_ID, apiPathProperties.getUserCenter()), params); + searchResourceResult(result, "获取用户列表失败"); + return JSONArray.parseArray(result, UserResourceBO.class); + } + + @Override + public List listUserIdByAreaId(Map params) throws AccessTokenException, SearchException { + params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken()); + String result = restTemplateUtil.doGetFormNormal(String.format(IApiConsts.LIST_USER_ID_BY_AREA_ID, apiPathProperties.getUserCenter()), params); + searchResourceResult(result, "获取用户ID列表失败"); + return JSONArray.parseArray(result, String.class); + } + } diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/pojo/bos/UserResourceBO.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/pojo/bos/UserResourceBO.java new file mode 100644 index 0000000..00da273 --- /dev/null +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/pojo/bos/UserResourceBO.java @@ -0,0 +1,76 @@ +package com.cm.common.plugin.pojo.bos; + +import java.io.Serializable; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: UserDTO + * @Description: 用户 + * @Author: WangGeng + * @Date: 2020/7/27 16:41 + * @Version: 1.0 + **/ +public class UserResourceBO implements Serializable { + + private static final long serialVersionUID = -2467274836208617520L; + private String userId; + private String userUsername; + private String userName; + private String userPhone; + private String userEmail; + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getUserUsername() { + return userUsername == null ? "" : userUsername.trim(); + } + + public void setUserUsername(String userUsername) { + this.userUsername = userUsername; + } + + public String getUserName() { + return userName == null ? "" : userName.trim(); + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserPhone() { + return userPhone == null ? "" : userPhone.trim(); + } + + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; + } + + public String getUserEmail() { + return userEmail == null ? "" : userEmail.trim(); + } + + public void setUserEmail(String userEmail) { + this.userEmail = userEmail; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"userId\":\"") + .append(userId).append('\"'); + sb.append(",\"userUsername\":\"") + .append(userUsername).append('\"'); + sb.append(",\"userName\":\"") + .append(userName).append('\"'); + sb.append(",\"userPhone\":\"") + .append(userPhone).append('\"'); + sb.append(",\"userEmail\":\"") + .append(userEmail).append('\"'); + sb.append('}'); + return sb.toString(); + } +}