diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/group/IGroupService.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/group/IGroupService.java new file mode 100644 index 0000000..d7b2112 --- /dev/null +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/group/IGroupService.java @@ -0,0 +1,33 @@ +package com.cm.common.plugin.oauth.service.group; + +import com.cm.common.plugin.pojo.bos.UserResourceBO; +import com.cm.common.pojo.bos.GroupBO; + +import java.util.List; + +/** + * @ClassName: IGroupService + * @Description: 用户组 + * @Author: wanggeng + * @Date: 2021/8/11 2:55 下午 + * @Version: 1.0 + */ +public interface IGroupService { + + /** + * 组列表 + * + * @param parentGroupId 上级ID + * @return + */ + List list(String parentGroupId); + + /** + * 组用户列表 + * + * @param groupId + * @return + */ + List listUser(String groupId); + +} diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/group/impl/GroupServiceImpl.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/group/impl/GroupServiceImpl.java new file mode 100644 index 0000000..9888c50 --- /dev/null +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/group/impl/GroupServiceImpl.java @@ -0,0 +1,52 @@ +package com.cm.common.plugin.oauth.service.group.impl; + +import com.alibaba.fastjson.JSONArray; +import com.cm.common.base.AbstractService; +import com.cm.common.config.properties.ApiPathProperties; +import com.cm.common.plugin.IApiConsts; +import com.cm.common.plugin.oauth.service.group.IGroupService; +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.pojo.bos.GroupBO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @ClassName: GroupServiceImpl + * @Description: 用户组 + * @Author: wanggeng + * @Date: 2021/8/11 2:55 下午 + * @Version: 1.0 + */ +@Service +public class GroupServiceImpl extends AbstractService implements IGroupService { + + @Autowired + private RestTemplateUtil restTemplateUtil; + @Autowired + private ApiPathProperties apiPathProperties; + + + @Override + public List list(String parentGroupId) { + Map params = new HashMap<>(2); + params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken()); + String result = restTemplateUtil.doGetFormNormal(String.format("%s/resource/group/list/%s", apiPathProperties.getUserCenter(), parentGroupId), params); + searchResourceResult(result, "获取组列表失败"); + return JSONArray.parseArray(result, GroupBO.class); + } + + @Override + public List listUser(String groupId) { + Map params = new HashMap<>(2); + params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken()); + String result = restTemplateUtil.doGetFormNormal(String.format("%s/resource/group/list-user/%s", apiPathProperties.getUserCenter(), groupId), params); + searchResourceResult(result, "获取组列表失败"); + return JSONArray.parseArray(result, UserResourceBO.class); + } +}