ArchivesDeptController.java
4.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package com.ruoyi.controller;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.ArchivesDept;
import com.ruoyi.service.IArchivesDeptService;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
/**
* 部门Controller
*
* @author li
* @date 2022-08-01
*/
@RestController
@RequestMapping("/archives/dept")
public class ArchivesDeptController extends BaseController
{
@Autowired
private IArchivesDeptService archivesDeptService;
/**
* 查询部门列表
*/
@PreAuthorize("@ss.hasPermi('archives:dept:list')")
@GetMapping("/list")
public AjaxResult list(ArchivesDept archivesDept)
{
startPage();
List<ArchivesDept> list = archivesDeptService.selectArchivesDeptList(archivesDept);
return AjaxResult.success(list);
}
/**
* 导出部门列表
*/
@PreAuthorize("@ss.hasPermi('archives:dept:export')")
@Log(title = "部门", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ArchivesDept archivesDept)
{
List<ArchivesDept> list = archivesDeptService.selectArchivesDeptList(archivesDept);
ExcelUtil<ArchivesDept> util = new ExcelUtil<ArchivesDept>(ArchivesDept.class);
util.exportExcel(response, list, "部门数据");
}
/**
* 获取部门详细信息
*/
@PreAuthorize("@ss.hasPermi('archives:dept:query')")
@GetMapping(value = "/{deptId}")
public AjaxResult getInfo(@PathVariable("deptId") Long deptId)
{
return AjaxResult.success(archivesDeptService.selectArchivesDeptByDeptId(deptId));
}
/**
* 新增部门
*/
@PreAuthorize("@ss.hasPermi('archives:dept:add')")
@Log(title = "部门", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ArchivesDept archivesDept)
{
return toAjax(archivesDeptService.insertArchivesDept(archivesDept));
}
/**
* 修改部门
*/
@PreAuthorize("@ss.hasPermi('archives:dept:edit')")
@Log(title = "部门", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ArchivesDept archivesDept)
{
return toAjax(archivesDeptService.updateArchivesDept(archivesDept));
}
/**
* 删除部门
*/
@PreAuthorize("@ss.hasPermi('archives:dept:remove')")
@Log(title = "部门", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptIds}")
public AjaxResult remove(@PathVariable Long[] deptIds)
{
return toAjax(archivesDeptService.deleteArchivesDeptByDeptIds(deptIds));
}
@GetMapping("/treeselect")
public AjaxResult treeselect(ArchivesDept archivesDept)
{
List<ArchivesDept> depts = archivesDeptService.selectArchivesDeptList(archivesDept);
return AjaxResult.success(archivesDeptService.buildDeptTreeSelect(depts));
}
/**
* 查询部门列表(排除节点)
*/
@PreAuthorize("@ss.hasPermi('system:dept:list')")
@GetMapping("/list/exclude/{deptId}")
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
{
List<ArchivesDept> depts = archivesDeptService.selectArchivesDeptList(new ArchivesDept());
Iterator<ArchivesDept> it = depts.iterator();
while (it.hasNext())
{
ArchivesDept d = (ArchivesDept) it.next();
if (d.getDeptId().intValue() == deptId
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""))
{
it.remove();
}
}
return AjaxResult.success(depts);
}
}