新增部门接口
This commit is contained in:
parent
1a3155f8d5
commit
bf4edb4827
@ -211,4 +211,8 @@ public interface IApiConsts {
|
|||||||
*/
|
*/
|
||||||
String LIST_LAYIM_DEPARTMENT_USER = "%s/resource/user/im/listdepartmentuser";
|
String LIST_LAYIM_DEPARTMENT_USER = "%s/resource/user/im/listdepartmentuser";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门列表
|
||||||
|
*/
|
||||||
|
String LIST_DEPARTMENT_SORT = "%s/resource/department/list-sort";
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,10 @@ package com.cm.common.plugin.oauth.service.department;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.cm.common.exception.AccessTokenException;
|
import com.cm.common.exception.AccessTokenException;
|
||||||
import com.cm.common.exception.SearchException;
|
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;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,4 +61,12 @@ public interface IDepartmentService {
|
|||||||
* @throws SearchException
|
* @throws SearchException
|
||||||
*/
|
*/
|
||||||
JSONArray listZTreeDepartment(Map<String, Object> params) throws AccessTokenException, SearchException;
|
JSONArray listZTreeDepartment(Map<String, Object> params) throws AccessTokenException, SearchException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门列表
|
||||||
|
*
|
||||||
|
* @param type 部门类型
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DepartmentSortDTO> listSortByType(String type);
|
||||||
}
|
}
|
||||||
|
@ -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.service.department.IDepartmentService;
|
||||||
import com.cm.common.plugin.oauth.token.ClientTokenManager;
|
import com.cm.common.plugin.oauth.token.ClientTokenManager;
|
||||||
import com.cm.common.plugin.utils.RestTemplateUtil;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,4 +79,14 @@ public class DepartmentServiceImpl extends AbstractService implements IDepartmen
|
|||||||
searchResourceResult(result, "获取部门人员列表失败");
|
searchResourceResult(result, "获取部门人员列表失败");
|
||||||
return JSONArray.parseArray(result);
|
return JSONArray.parseArray(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DepartmentSortDTO> listSortByType(String type) {
|
||||||
|
Map<String, Object> 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ public class RestTemplateUtil {
|
|||||||
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(queryParams, httpHeaders);
|
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(queryParams, httpHeaders);
|
||||||
RestTemplate restTemplate = getRestTemplate();
|
RestTemplate restTemplate = getRestTemplate();
|
||||||
try {
|
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));
|
return getResponse(restTemplate.postForEntity(url, httpEntity, String.class));
|
||||||
} catch (HttpClientErrorException e) {
|
} catch (HttpClientErrorException e) {
|
||||||
if (e.getRawStatusCode() == HttpStatus.BAD_REQUEST.value()) {
|
if (e.getRawStatusCode() == HttpStatus.BAD_REQUEST.value()) {
|
||||||
@ -230,7 +230,7 @@ public class RestTemplateUtil {
|
|||||||
LOG.debug(">>>> 请求结果状态: {}, ", responseEntity.getStatusCodeValue());
|
LOG.debug(">>>> 请求结果状态: {}, ", responseEntity.getStatusCodeValue());
|
||||||
String response = responseEntity.getBody();
|
String response = responseEntity.getBody();
|
||||||
if (HttpStatus.OK.value() == responseEntity.getStatusCodeValue()) {
|
if (HttpStatus.OK.value() == responseEntity.getStatusCodeValue()) {
|
||||||
LOG.debug(">>>> 返回结果: {}", response);
|
System.out.println(response);
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
return new JSONObject().toJSONString();
|
return new JSONObject().toJSONString();
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user