|
@@ -170,13 +170,34 @@ public class SysDeptController extends BaseController {
|
|
|
return toAjax(deptService.deleteDeptById(deptId));
|
|
|
}
|
|
|
|
|
|
- @Log(title = "部门管理", businessType = BusinessType.EXPORT)
|
|
|
- @PreAuthorize("@ss.hasPermi('system:role:export')")
|
|
|
- @PostMapping("/export")
|
|
|
+ @Log(title = "部门导出", businessType = BusinessType.EXPORT)
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:dept:export')")
|
|
|
@ApiOperation("部门管理")
|
|
|
- public void export(HttpServletResponse response, SysDept dept) {
|
|
|
- List<SysDept> list = deptService.selectDeptListAll(dept);
|
|
|
+ @GetMapping("/export")
|
|
|
+ public void export(SysDept dept, HttpServletResponse response) {
|
|
|
+ List<SysDept> list = forDeptList(dept);
|
|
|
ExcelUtil<SysDept> util = new ExcelUtil<SysDept>(SysDept.class);
|
|
|
- util.exportExcel(response, list, "角色数据");
|
|
|
+ util.exportExcel(response, list, "部门数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 遍历列表,给字段赋值
|
|
|
+ */
|
|
|
+ private List<SysDept> forDeptList(SysDept dept) {
|
|
|
+ List<SysDept> list = deptService.selectDeptListAll(dept);
|
|
|
+ for (SysDept sysDept : list) {
|
|
|
+ for (SysDept dept1 : list) {
|
|
|
+ if (dept1.getDeptId().equals(sysDept.getParentId())) {
|
|
|
+ sysDept.setParentName(dept1.getDeptName());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (SysDept sysDept : list) {
|
|
|
+ if (ObjectUtils.isEmpty(sysDept.getParentName())) {
|
|
|
+ sysDept.setParentName(sysDept.getDeptName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
}
|
|
|
}
|