新增通过地区编码、上级ID、部门类型获取部门ZTree列表

This commit is contained in:
wanggeng 2021-12-28 18:44:57 +08:00
parent 393ab9a0a9
commit 0c968f3d72
8 changed files with 98 additions and 3 deletions

View File

@ -184,6 +184,16 @@ public interface IDepartmentBaseService {
*/
List<ZTreeDTO> listZTreeByAreaCodeAndParentId(String areaCode, String parentId);
/**
* 部门列表
*
* @param departmentAreaCode 地区ID
* @param departmentParentId 上级部门ID0为查询地区下部门其他为地区下所有下级部门
* @param departmentType 部门类型1机构2部门
* @return
*/
List<ZTreeDTO> listZTreeByAreaCodeAndParentIdAndType(String departmentAreaCode, String departmentParentId, Integer departmentType);
/**
* 部门ID列表
*

View File

@ -42,6 +42,9 @@ public interface IDepartmentRemoteService {
@RemoteGetMethod("/list-id")
List<String> listId(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemoteQueryParamsMap Map<String, Object> params);
@RemoteGetMethod("/list-ztree/area-code/{departmentAreaCode}/parent-id/{departmentParentId}/type/{departmentType}")
List<ZTreeDTO> listZTreeByAreaCodeAndParentIdAndType(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemotePathParams("departmentAreaCode") String departmentAreaCode, @RemotePathParams("departmentParentId") String departmentParentId, @RemotePathParams("departmentType") Integer departmentType);
@RemoteGetMethod("/count")
SuccessResultData<Integer> count(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemoteQueryParamsMap Map<String, Object> params);

View File

@ -167,6 +167,20 @@ public class DepartmentServiceImpl extends DefaultBaseService implements IDepart
return listZTree(params);
}
@Override
public List<ZTreeDTO> listZTreeByAreaCodeAndParentIdAndType(String departmentAreaCode, String departmentParentId, Integer departmentType) {
if (StringUtils.isBlank(departmentAreaCode)) {
return new ArrayList<>();
}
if (StringUtils.isBlank(departmentParentId)) {
return new ArrayList<>();
}
if (departmentType == null) {
return new ArrayList<>();
}
return departmentRemoteService.listZTreeByAreaCodeAndParentIdAndType(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), departmentAreaCode, departmentParentId, departmentType);
}
@Override
public List<String> listId(Map<String, Object> params) {
return departmentRemoteService.listId(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), params);

View File

@ -20,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.*;
@ -156,6 +155,20 @@ public class DepartmentController extends DefaultBaseController {
return departmentService.listZTree(departmentParentId, params);
}
@ApiOperation(value = "组织部门zTree列表", notes = "通过地区编码、部门上级ID和部门类型组织部门zTree列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "departmentAreaCode", value = "地区编码", paramType = "path"),
@ApiImplicitParam(name = "departmentParentId", value = "组织部门上级ID", paramType = "path"),
@ApiImplicitParam(name = "departmentType", value = "部门类型1机构2部门", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-ztree/area-code/{departmentAreaCode}/parent-id/{departmentParentId}/type/{departmentType}")
public List<ZTreeDTO> listByAreaCodeAndParentIdAndType(@PathVariable("departmentAreaCode") String departmentAreaCode,
@PathVariable("departmentParentId") String departmentParentId,
@PathVariable("departmentType") Integer departmentType) {
return departmentService.listZTreeByAreaCodeAndParentIdAndType(departmentAreaCode, departmentParentId, departmentType);
}
@ApiOperation(value = "组织部门详情", notes = "组织部门详情接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path")

View File

@ -55,7 +55,7 @@ public class DepartmentAppController extends DefaultBaseController {
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-all/{departmentParentId}")
public List<DepartmentDTO> listAll(@RequestHeader("token") String token,
@PathVariable("departmentParentId") String departmentParentId) {
@PathVariable("departmentParentId") String departmentParentId) {
Map<String, Object> params = new HashMap<>(0);
params.put("departmentParentId", departmentParentId);
return departmentService.listAll(params);
@ -77,6 +77,22 @@ public class DepartmentAppController extends DefaultBaseController {
return departmentService.listZTree(departmentParentId, params);
}
@ApiOperation(value = "组织部门zTree列表", notes = "通过地区编码、部门上级ID和部门类型组织部门zTree列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "departmentAreaCode", value = "地区编码", paramType = "path"),
@ApiImplicitParam(name = "departmentParentId", value = "组织部门上级ID", paramType = "path"),
@ApiImplicitParam(name = "departmentType", value = "部门类型1机构2部门", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-ztree/area-code/{departmentAreaCode}/parent-id/{departmentParentId}/type/{departmentType}")
public List<ZTreeDTO> listByAreaCodeAndParentIdAndType(@RequestHeader("token") String token,
@PathVariable("departmentAreaCode") String departmentAreaCode,
@PathVariable("departmentParentId") String departmentParentId,
@PathVariable("departmentType") Integer departmentType) {
return departmentService.listZTreeByAreaCodeAndParentIdAndType(departmentAreaCode, departmentParentId, departmentType);
}
@ApiOperation(value = "组织部门详情", notes = "组织部门详情接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),

View File

@ -83,6 +83,20 @@ public class DepartmentResourceController extends DefaultBaseController {
return departmentService.listZTree(departmentParentId, params);
}
@ApiOperation(value = "组织部门zTree列表", notes = "通过地区编码、部门上级ID和部门类型组织部门zTree列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "departmentAreaCode", value = "地区编码", paramType = "path"),
@ApiImplicitParam(name = "departmentParentId", value = "组织部门上级ID", paramType = "path"),
@ApiImplicitParam(name = "departmentType", value = "部门类型1机构2部门", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-ztree/area-code/{departmentAreaCode}/parent-id/{departmentParentId}/type/{departmentType}")
public List<ZTreeDTO> listByAreaCodeAndParentIdAndType(@PathVariable("departmentAreaCode") String departmentAreaCode,
@PathVariable("departmentParentId") String departmentParentId,
@PathVariable("departmentType") Integer departmentType) {
return departmentService.listZTreeByAreaCodeAndParentIdAndType(departmentAreaCode, departmentParentId, departmentType);
}
@ApiOperation(value = "组织部门详情", notes = "组织部门详情接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path")

View File

@ -335,6 +335,19 @@ public class DepartmentServiceImpl extends DefaultBaseService implements IDepart
return listZTree(params);
}
@Override
public List<ZTreeDTO> listZTreeByAreaCodeAndParentIdAndType(String departmentAreaCode, String departmentParentId, Integer departmentType) {
Map<String, Object> params = getHashMap(8);
if (StringUtils.isBlank(departmentParentId) || StringUtils.equals(departmentParentId, "0")) {
params.put("departmentAreaCode", departmentAreaCode);
} else {
params.put("departmentAreaCodeLike", WStringUtil.cutContinuityRepeatCharDesc(departmentAreaCode, '0'));
params.put("departmentParentId", departmentParentId);
}
params.put("departmentType", departmentType);
return departmentDao.listZTree(params);
}
@Override
public List<ZTreeDTO> listZTreeByAreaCodeAndParentId(String departmentAreaCode, String departmentParentId) {
Map<String, Object> params = getHashMap(4);

View File

@ -293,10 +293,18 @@
AND
department_area_code = #{departmentAreaCode}
</if>
<if test="departmentType != null and departmentType != ''">
<if test="departmentAreaCodeLike != null and departmentAreaCodeLike != ''">
AND
department_area_code LIKE CONCAT(#{departmentAreaCodeLike}, '%')
</if>
<if test="departmentType != null">
AND
department_type = #{departmentType}
</if>
<if test="excludeDepartmentAreaCode != null and excludeDepartmentAreaCode != ''">
AND
department_area_code != #{excludeDepartmentAreaCode}
</if>
ORDER BY
department_order
</select>
@ -389,6 +397,10 @@
AND
department_no LIKE CONCAT(#{departmentNo}, '%')
</if>
<if test="departmentType != null">
AND
department_type = #{departmentType}
</if>
<if test="departmentIds != null and departmentIds.size > 0">
AND
department_id IN