开缓存、增加异步请求
This commit is contained in:
parent
0ea9db59bf
commit
ceac706e09
@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When you feel like quitting. Think about why you started
|
* When you feel like quitting. Think about why you started
|
||||||
@ -44,10 +45,12 @@ public class DepartmentResourceController extends BaseController {
|
|||||||
})
|
})
|
||||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
@PostMapping("listdepartments/{departmentParentId}")
|
@PostMapping("listdepartments/{departmentParentId}")
|
||||||
public List<ZTreeDTO> listDepartments(@PathVariable("departmentParentId") String departmentParentId) throws SearchException {
|
public Callable<List<ZTreeDTO>> listDepartments(@PathVariable("departmentParentId") String departmentParentId) throws SearchException {
|
||||||
Map<String, Object> params = new HashMap<>(0);
|
return () -> {
|
||||||
params.put("departmentParentId", departmentParentId);
|
Map<String, Object> params = new HashMap<>(0);
|
||||||
return departmentService.listZTreeDepartment(params);
|
params.put("departmentParentId", departmentParentId);
|
||||||
|
return departmentService.listZTreeDepartment(params);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "组织部门全部列表", notes = "组织部门全部列表接口")
|
@ApiOperation(value = "组织部门全部列表", notes = "组织部门全部列表接口")
|
||||||
@ -57,10 +60,12 @@ public class DepartmentResourceController extends BaseController {
|
|||||||
})
|
})
|
||||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
@PostMapping("listalldepartments/{departmentParentId}")
|
@PostMapping("listalldepartments/{departmentParentId}")
|
||||||
public List<DepartmentDTO> listAllDepartments(@PathVariable("departmentParentId") String departmentParentId) throws SearchException {
|
public Callable<List<DepartmentDTO>> listAllDepartments(@PathVariable("departmentParentId") String departmentParentId) throws SearchException {
|
||||||
Map<String, Object> params = new HashMap<>(0);
|
return () -> {
|
||||||
params.put("departmentParentId", departmentParentId);
|
Map<String, Object> params = new HashMap<>(0);
|
||||||
return departmentService.listDepartmentsAll(params);
|
params.put("departmentParentId", departmentParentId);
|
||||||
|
return departmentService.listDepartmentsAll(params);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "zTree列表(包括人员)", notes = "zTree列表(包括人员)接口")
|
@ApiOperation(value = "zTree列表(包括人员)", notes = "zTree列表(包括人员)接口")
|
||||||
@ -69,12 +74,14 @@ public class DepartmentResourceController extends BaseController {
|
|||||||
})
|
})
|
||||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
@GetMapping("listztreedepartmentwithuser")
|
@GetMapping("listztreedepartmentwithuser")
|
||||||
public List<ZTreeDTO> listZTreeDepartmentWithUser(@RequestParam(required = false) String id) throws SearchException {
|
public Callable<List<ZTreeDTO>> listZTreeDepartmentWithUser(@RequestParam(required = false) String id) throws SearchException {
|
||||||
String departmentParentId = "0";
|
return () -> {
|
||||||
if (!StringUtils.isBlank(id)) {
|
String departmentParentId = "0";
|
||||||
departmentParentId = id;
|
if (!StringUtils.isBlank(id)) {
|
||||||
}
|
departmentParentId = id;
|
||||||
return departmentService.listZTreeDepartmentWithUser(departmentParentId);
|
}
|
||||||
|
return departmentService.listZTreeDepartmentWithUser(departmentParentId);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "zTree列表", notes = "zTree列表接口")
|
@ApiOperation(value = "zTree列表", notes = "zTree列表接口")
|
||||||
@ -101,8 +108,8 @@ public class DepartmentResourceController extends BaseController {
|
|||||||
})
|
})
|
||||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
@GetMapping("listdepartmentsimplebyparentid/{departmentParentId}")
|
@GetMapping("listdepartmentsimplebyparentid/{departmentParentId}")
|
||||||
public List<DepartmentSimpleDTO> listDepartmentSimpleByParentId(@PathVariable("departmentParentId") String departmentParentId) throws SearchException {
|
public Callable<List<DepartmentSimpleDTO>> listDepartmentSimpleByParentId(@PathVariable("departmentParentId") String departmentParentId) throws SearchException {
|
||||||
return departmentService.listDepartmentSimpleByParentId(departmentParentId);
|
return () -> departmentService.listDepartmentSimpleByParentId(departmentParentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "通过上级ID和添加获取组织部门全部增量列表(简单格式)", notes = "通过上级ID和添加获取组织部门全部增量列表(简单格式)接口")
|
@ApiOperation(value = "通过上级ID和添加获取组织部门全部增量列表(简单格式)", notes = "通过上级ID和添加获取组织部门全部增量列表(简单格式)接口")
|
||||||
@ -113,11 +120,11 @@ public class DepartmentResourceController extends BaseController {
|
|||||||
})
|
})
|
||||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
@GetMapping("listdepartmentsimplebyparentidandadddate/{departmentParentId}/{addDate}")
|
@GetMapping("listdepartmentsimplebyparentidandadddate/{departmentParentId}/{addDate}")
|
||||||
public List<DepartmentSimpleDTO> listDepartmentSimpleByParentIdAndAddDate(@PathVariable("departmentParentId") String departmentParentId, @PathVariable("addDate") String addDate) throws SearchException {
|
public Callable<List<DepartmentSimpleDTO>> listDepartmentSimpleByParentIdAndAddDate(@PathVariable("departmentParentId") String departmentParentId, @PathVariable("addDate") String addDate) throws SearchException {
|
||||||
if (!RegexUtil.isDate(addDate)) {
|
if (!RegexUtil.isDate(addDate)) {
|
||||||
throw new ParamsException("日期格式错误");
|
throw new ParamsException("日期格式错误");
|
||||||
}
|
}
|
||||||
return departmentService.listDepartmentSimpleByParentIdAndAddDate(departmentParentId, addDate);
|
return () -> departmentService.listDepartmentSimpleByParentIdAndAddDate(departmentParentId, addDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "通过上级ID和更新获取组织部门全部新增和修改的列表(简单格式)", notes = "通过上级ID和更新获取组织部门全部新增和修改的列表(简单格式)接口")
|
@ApiOperation(value = "通过上级ID和更新获取组织部门全部新增和修改的列表(简单格式)", notes = "通过上级ID和更新获取组织部门全部新增和修改的列表(简单格式)接口")
|
||||||
@ -128,11 +135,11 @@ public class DepartmentResourceController extends BaseController {
|
|||||||
})
|
})
|
||||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
@GetMapping("listdepartmentsimplebyparentidandupdatedate/{departmentParentId}/{updateDate}")
|
@GetMapping("listdepartmentsimplebyparentidandupdatedate/{departmentParentId}/{updateDate}")
|
||||||
public List<DepartmentSimpleDTO> listDepartmentSimpleByParentIdAndUpdateDate(@PathVariable("departmentParentId") String departmentParentId, @PathVariable("updateDate") String updateDate) throws SearchException {
|
public Callable<List<DepartmentSimpleDTO>> listDepartmentSimpleByParentIdAndUpdateDate(@PathVariable("departmentParentId") String departmentParentId, @PathVariable("updateDate") String updateDate) throws SearchException {
|
||||||
if (!RegexUtil.isDate(updateDate)) {
|
if (!RegexUtil.isDate(updateDate)) {
|
||||||
throw new ParamsException("日期格式错误");
|
throw new ParamsException("日期格式错误");
|
||||||
}
|
}
|
||||||
return departmentService.listDepartmentSimpleByParentIdAndUpdateDate(departmentParentId, updateDate);
|
return () -> departmentService.listDepartmentSimpleByParentIdAndUpdateDate(departmentParentId, updateDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "通过部门ID获取组织部门详情(简单格式)", notes = "通过部门ID获取组织部门详情(简单格式)接口")
|
@ApiOperation(value = "通过部门ID获取组织部门详情(简单格式)", notes = "通过部门ID获取组织部门详情(简单格式)接口")
|
||||||
@ -153,8 +160,8 @@ public class DepartmentResourceController extends BaseController {
|
|||||||
})
|
})
|
||||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
@GetMapping("listdepartmentsimplebyparentid/{departmentParentIntId}")
|
@GetMapping("listdepartmentsimplebyparentid/{departmentParentIntId}")
|
||||||
public List<DepartmentSimpleDTO> listDepartmentSimpleByParentId(@PathVariable("departmentParentIntId") Long departmentParentIntId) throws SearchException {
|
public Callable<List<DepartmentSimpleDTO>> listDepartmentSimpleByParentId(@PathVariable("departmentParentIntId") Long departmentParentIntId) throws SearchException {
|
||||||
return departmentService.listDepartmentSimpleByParentIntId(departmentParentIntId);
|
return () -> departmentService.listDepartmentSimpleByParentIntId(departmentParentIntId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "通过上级ID和添加获取组织部门全部增量列表(简单格式)", notes = "通过上级ID和添加获取组织部门全部增量列表(简单格式)接口")
|
@ApiOperation(value = "通过上级ID和添加获取组织部门全部增量列表(简单格式)", notes = "通过上级ID和添加获取组织部门全部增量列表(简单格式)接口")
|
||||||
@ -165,11 +172,11 @@ public class DepartmentResourceController extends BaseController {
|
|||||||
})
|
})
|
||||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
@GetMapping("listdepartmentsimplebyparentidandadddate/{departmentParentIntId}/{addDate}")
|
@GetMapping("listdepartmentsimplebyparentidandadddate/{departmentParentIntId}/{addDate}")
|
||||||
public List<DepartmentSimpleDTO> listDepartmentSimpleByParentIdAndAddDate(@PathVariable("departmentParentIntId") Long departmentParentIntId, @PathVariable("addDate") String addDate) throws SearchException {
|
public Callable<List<DepartmentSimpleDTO>> listDepartmentSimpleByParentIdAndAddDate(@PathVariable("departmentParentIntId") Long departmentParentIntId, @PathVariable("addDate") String addDate) throws SearchException {
|
||||||
if (!RegexUtil.isDate(addDate)) {
|
if (!RegexUtil.isDate(addDate)) {
|
||||||
throw new ParamsException("日期格式错误");
|
throw new ParamsException("日期格式错误");
|
||||||
}
|
}
|
||||||
return departmentService.listDepartmentSimpleByParentIntIdAndAddDate(departmentParentIntId, addDate);
|
return () -> departmentService.listDepartmentSimpleByParentIntIdAndAddDate(departmentParentIntId, addDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "通过上级ID和更新获取组织部门全部新增和修改的列表(简单格式)", notes = "通过上级ID和更新获取组织部门全部新增和修改的列表(简单格式)接口")
|
@ApiOperation(value = "通过上级ID和更新获取组织部门全部新增和修改的列表(简单格式)", notes = "通过上级ID和更新获取组织部门全部新增和修改的列表(简单格式)接口")
|
||||||
@ -180,11 +187,11 @@ public class DepartmentResourceController extends BaseController {
|
|||||||
})
|
})
|
||||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
@GetMapping("listdepartmentsimplebyparentidandupdatedate/{departmentParentIntId}/{updateDate}")
|
@GetMapping("listdepartmentsimplebyparentidandupdatedate/{departmentParentIntId}/{updateDate}")
|
||||||
public List<DepartmentSimpleDTO> listDepartmentSimpleByParentIdAndUpdateDate(@PathVariable("departmentParentIntId") Long departmentParentIntId, @PathVariable("updateDate") String updateDate) throws SearchException {
|
public Callable<List<DepartmentSimpleDTO>> listDepartmentSimpleByParentIdAndUpdateDate(@PathVariable("departmentParentIntId") Long departmentParentIntId, @PathVariable("updateDate") String updateDate) throws SearchException {
|
||||||
if (!RegexUtil.isDate(updateDate)) {
|
if (!RegexUtil.isDate(updateDate)) {
|
||||||
throw new ParamsException("日期格式错误");
|
throw new ParamsException("日期格式错误");
|
||||||
}
|
}
|
||||||
return departmentService.listDepartmentSimpleByParentIntIdAndUpdateDate(departmentParentIntId, updateDate);
|
return () -> departmentService.listDepartmentSimpleByParentIntIdAndUpdateDate(departmentParentIntId, updateDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "通过部门ID获取组织部门详情(简单格式)", notes = "通过部门ID获取组织部门详情(简单格式)接口")
|
@ApiOperation(value = "通过部门ID获取组织部门详情(简单格式)", notes = "通过部门ID获取组织部门详情(简单格式)接口")
|
||||||
|
@ -228,7 +228,7 @@ public class DepartmentServiceImpl extends BaseService implements IDepartmentSer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DepartmentDTO> listDepartmentsAll(Map<String, Object> params) throws SearchException {
|
public List<DepartmentDTO> listDepartmentsAll(Map<String, Object> params) throws SearchException {
|
||||||
List<DepartmentDTO> departmentDTOs = departmentDao.listDepartments(params);
|
List<DepartmentDTO> departmentDTOs = listDepartments(params);
|
||||||
listSubDepartments(departmentDTOs, params);
|
listSubDepartments(departmentDTOs, params);
|
||||||
return departmentDTOs;
|
return departmentDTOs;
|
||||||
}
|
}
|
||||||
@ -267,7 +267,7 @@ public class DepartmentServiceImpl extends BaseService implements IDepartmentSer
|
|||||||
@Override
|
@Override
|
||||||
public SuccessResultList<List<DepartmentDTO>> listPageDepartment(ListPage page) throws SearchException {
|
public SuccessResultList<List<DepartmentDTO>> listPageDepartment(ListPage page) throws SearchException {
|
||||||
PageHelper.startPage(page.getPage(), page.getRows());
|
PageHelper.startPage(page.getPage(), page.getRows());
|
||||||
List<DepartmentDTO> departmentDTOs = departmentDao.listDepartments(page.getParams());
|
List<DepartmentDTO> departmentDTOs = listDepartments(page.getParams());
|
||||||
PageInfo<DepartmentDTO> pageInfo = new PageInfo<>(departmentDTOs);
|
PageInfo<DepartmentDTO> pageInfo = new PageInfo<>(departmentDTOs);
|
||||||
return new SuccessResultList<>(departmentDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
return new SuccessResultList<>(departmentDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||||
}
|
}
|
||||||
@ -294,7 +294,8 @@ public class DepartmentServiceImpl extends BaseService implements IDepartmentSer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DepartmentDTO> listDepartments(Map<String, Object> params) throws SearchException {
|
public List<DepartmentDTO> listDepartments(Map<String, Object> params) throws SearchException {
|
||||||
return departmentDao.listDepartments(params);
|
List<DepartmentDTO> departmentDTOs = departmentDao.listDepartments(params);
|
||||||
|
return ArrayListUtil.deepClone(departmentDTOs, DepartmentDTO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -338,7 +339,7 @@ public class DepartmentServiceImpl extends BaseService implements IDepartmentSer
|
|||||||
@Override
|
@Override
|
||||||
public List<String> listDepartmentId(Map<String, Object> params) throws SearchException {
|
public List<String> listDepartmentId(Map<String, Object> params) throws SearchException {
|
||||||
List<String> departmentIds = new ArrayList<>();
|
List<String> departmentIds = new ArrayList<>();
|
||||||
List<DepartmentDTO> departmentDTOs = departmentDao.listDepartments(params);
|
List<DepartmentDTO> departmentDTOs = listDepartments(params);
|
||||||
for (DepartmentDTO departmentDTO : departmentDTOs) {
|
for (DepartmentDTO departmentDTO : departmentDTOs) {
|
||||||
departmentIds.add(departmentDTO.getDepartmentId());
|
departmentIds.add(departmentDTO.getDepartmentId());
|
||||||
}
|
}
|
||||||
@ -779,7 +780,7 @@ public class DepartmentServiceImpl extends BaseService implements IDepartmentSer
|
|||||||
private void listSubDepartments(List<DepartmentDTO> departmentDTOs, Map<String, Object> params) throws SearchException {
|
private void listSubDepartments(List<DepartmentDTO> departmentDTOs, Map<String, Object> params) throws SearchException {
|
||||||
for (DepartmentDTO departmentDTO : departmentDTOs) {
|
for (DepartmentDTO departmentDTO : departmentDTOs) {
|
||||||
params.put("departmentParentId", departmentDTO.getDepartmentId());
|
params.put("departmentParentId", departmentDTO.getDepartmentId());
|
||||||
List<DepartmentDTO> subDepartmentDTOs = departmentDao.listDepartments(params);
|
List<DepartmentDTO> subDepartmentDTOs = listDepartments(params);
|
||||||
departmentDTO.setSubDepartments(subDepartmentDTOs);
|
departmentDTO.setSubDepartments(subDepartmentDTOs);
|
||||||
listSubDepartments(subDepartmentDTOs, params);
|
listSubDepartments(subDepartmentDTOs, params);
|
||||||
}
|
}
|
||||||
|
@ -424,7 +424,7 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 组织部门列表 -->
|
<!-- 组织部门列表 -->
|
||||||
<select id="listDepartments" parameterType="map" resultMap="departmentDTO" useCache="false">
|
<select id="listDepartments" parameterType="map" resultMap="departmentDTO" useCache="true">
|
||||||
SELECT
|
SELECT
|
||||||
department_id,
|
department_id,
|
||||||
department_parent_id,
|
department_parent_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user