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 a88edc1..d638fe0 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 @@ -211,4 +211,8 @@ public interface IApiConsts { */ String LIST_LAYIM_DEPARTMENT_USER = "%s/resource/user/im/listdepartmentuser"; + /** + * 部门列表 + */ + String LIST_DEPARTMENT_SORT = "%s/resource/department/list-sort"; } diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/department/IDepartmentService.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/department/IDepartmentService.java index 594240f..9325f60 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/department/IDepartmentService.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/department/IDepartmentService.java @@ -3,7 +3,10 @@ package com.cm.common.plugin.oauth.service.department; import com.alibaba.fastjson.JSONArray; import com.cm.common.exception.AccessTokenException; import com.cm.common.exception.SearchException; +import com.cm.common.plugin.pojo.bos.department.DepartmentResourceBO; +import com.cm.common.pojo.dtos.department.DepartmentSortDTO; +import java.util.List; import java.util.Map; /** @@ -58,4 +61,12 @@ public interface IDepartmentService { * @throws SearchException */ JSONArray listZTreeDepartment(Map params) throws AccessTokenException, SearchException; + + /** + * 部门列表 + * + * @param type 部门类型 + * @return + */ + List listSortByType(String type); } diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/department/impl/DepartmentServiceImpl.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/department/impl/DepartmentServiceImpl.java index 27da846..cc5ef68 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/department/impl/DepartmentServiceImpl.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/department/impl/DepartmentServiceImpl.java @@ -9,11 +9,12 @@ import com.cm.common.plugin.IApiConsts; import com.cm.common.plugin.oauth.service.department.IDepartmentService; import com.cm.common.plugin.oauth.token.ClientTokenManager; import com.cm.common.plugin.utils.RestTemplateUtil; -import org.apache.commons.lang3.StringUtils; +import com.cm.common.pojo.dtos.department.DepartmentSortDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -78,4 +79,14 @@ public class DepartmentServiceImpl extends AbstractService implements IDepartmen searchResourceResult(result, "获取部门人员列表失败"); return JSONArray.parseArray(result); } + + @Override + public List listSortByType(String type) { + Map params = new HashMap<>(2); + params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken()); + params.put("departmentType", type); + String result = restTemplateUtil.doGetFormNormal(String.format(IApiConsts.LIST_DEPARTMENT_SORT, apiPathProperties.getUserCenter()), params); + searchResourceResult(result, "获取部门列表失败"); + return JSONArray.parseArray(result, DepartmentSortDTO.class); + } } diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/utils/RestTemplateUtil.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/utils/RestTemplateUtil.java index cac0ee8..2f091e7 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/utils/RestTemplateUtil.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/utils/RestTemplateUtil.java @@ -173,7 +173,7 @@ public class RestTemplateUtil { HttpEntity> httpEntity = new HttpEntity<>(queryParams, httpHeaders); RestTemplate restTemplate = getRestTemplate(); try { - LOG.debug("Rest post:\nurl: {},\nparams: {},\nhttpHeaders: {},\nqueryParams: {}", url, params, httpHeaders, queryParams); + LOG.debug("Rest post:\nurl: {},\nhttpHeaders: {},\nqueryParams: {}", url, params, httpHeaders, queryParams); return getResponse(restTemplate.postForEntity(url, httpEntity, String.class)); } catch (HttpClientErrorException e) { if (e.getRawStatusCode() == HttpStatus.BAD_REQUEST.value()) { @@ -230,7 +230,7 @@ public class RestTemplateUtil { LOG.debug(">>>> 请求结果状态: {}, ", responseEntity.getStatusCodeValue()); String response = responseEntity.getBody(); if (HttpStatus.OK.value() == responseEntity.getStatusCodeValue()) { - LOG.debug(">>>> 返回结果: {}", response); + System.out.println(response); if (response == null) { return new JSONObject().toJSONString(); } diff --git a/cloud-common/src/main/java/com/cm/common/pojo/dtos/department/DepartmentSortDTO.java b/cloud-common/src/main/java/com/cm/common/pojo/dtos/department/DepartmentSortDTO.java new file mode 100644 index 0000000..3c84c7d --- /dev/null +++ b/cloud-common/src/main/java/com/cm/common/pojo/dtos/department/DepartmentSortDTO.java @@ -0,0 +1,78 @@ +package com.cm.common.pojo.dtos.department; + +import java.io.Serializable; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: DepartmentSortDTO + * @Description: 部门 + * @Author: WangGeng + * @Date: 2021/6/24 21:21 + * @Version: 1.0 + **/ +public class DepartmentSortDTO implements Serializable { + + private static final long serialVersionUID = -5063411302090290214L; + private String departmentId; + private String departmentParentId; + private String departmentName; + private String departmentCode; + private String departmentType; + + public String getDepartmentId() { + return departmentId == null ? "" : departmentId.trim(); + } + + public void setDepartmentId(String departmentId) { + this.departmentId = departmentId; + } + + public String getDepartmentParentId() { + return departmentParentId == null ? "" : departmentParentId.trim(); + } + + public void setDepartmentParentId(String departmentParentId) { + this.departmentParentId = departmentParentId; + } + + public String getDepartmentName() { + return departmentName == null ? "" : departmentName.trim(); + } + + public void setDepartmentName(String departmentName) { + this.departmentName = departmentName; + } + + public String getDepartmentCode() { + return departmentCode == null ? "" : departmentCode.trim(); + } + + public void setDepartmentCode(String departmentCode) { + this.departmentCode = departmentCode; + } + + public String getDepartmentType() { + return departmentType == null ? "" : departmentType.trim(); + } + + public void setDepartmentType(String departmentType) { + this.departmentType = departmentType; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"departmentId\":\"") + .append(departmentId).append('\"'); + sb.append(",\"departmentName\":\"") + .append(departmentName).append('\"'); + sb.append(",\"departmentCode\":\"") + .append(departmentCode).append('\"'); + sb.append(",\"departmentType\":\"") + .append(departmentType).append('\"'); + sb.append('}'); + return sb.toString(); + } +}