DeptNodeController.java
4.18 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
package com.ruoyi.service.controller;
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.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.service.domain.DepotNode;
import com.ruoyi.service.service.DepotNodeService;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.Iterator;
import java.util.List;
/**
* 库房维护 控制层
*
* @author ym
* @date 2022-08-19
*/
@RestController
@RequestMapping("/service/depotNode")
public class DeptNodeController extends BaseController
{
@Autowired
private DepotNodeService depotNodeService;
/**
* 查询库房列表
*/
@PreAuthorize("@ss.hasPermi('service:depotNode:list')")
@GetMapping("/list")
public AjaxResult list(DepotNode depotNode)
{
startPage();
List<DepotNode> list = depotNodeService.selectDepotNodeList(depotNode);
return AjaxResult.success(list);
}
/**
* 导出库房列表
*/
@PreAuthorize("@ss.hasPermi('service:depotNode:export')")
@Log(title = "库房", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DepotNode serviceDept)
{
List<DepotNode> list = depotNodeService.selectDepotNodeList(serviceDept);
ExcelUtil<DepotNode> util = new ExcelUtil<DepotNode>(DepotNode.class);
util.exportExcel(response, list, "库房数据");
}
/**
* 获取库房详细信息
*/
@PreAuthorize("@ss.hasPermi('service:depotNode:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
DepotNode serviceDept=depotNodeService.selectDepotNodeById(id);
System.out.println(serviceDept);
return AjaxResult.success(depotNodeService.selectDepotNodeById(id));
}
/**
* 新增库房
*/
@PreAuthorize("@ss.hasPermi('service:depotNode:add')")
@Log(title = "库房", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DepotNode serviceDept)
{
return toAjax(depotNodeService.insertDepotNode(serviceDept));
}
/**
* 修改库房
*/
@PreAuthorize("@ss.hasPermi('service:depotNode:edit')")
@Log(title = "库房", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DepotNode serviceDept)
{
return toAjax(depotNodeService.updateDepotNode(serviceDept));
}
/**
* 删除库房
*/
@PreAuthorize("@ss.hasPermi('service:depotNode:remove')")
@Log(title = "库房", businessType = BusinessType.DELETE)
@DeleteMapping("/{depotNodeIds}")
public AjaxResult remove(@PathVariable Long[] depotNodeIds)
{
return toAjax(depotNodeService.deleteDepotNodeByIds(depotNodeIds));
}
@GetMapping("/treeselect")
public AjaxResult treeselect(DepotNode serviceDept)
{
List<DepotNode> depotNodes = depotNodeService.selectDepotNodeList(serviceDept);
return AjaxResult.success(depotNodeService.buildDepotNodeTreeSelect(depotNodes));
}
/**
* 查询库房列表(排除节点)
*/
@PreAuthorize("@ss.hasPermi('system:depotNode:list')")
@GetMapping("/list/exclude/{depotNodeId}")
public AjaxResult excludeChild(@PathVariable(value = "depotNodeId", required = false) Long depotNodeId)
{
List<DepotNode> depotNodes = depotNodeService.selectDepotNodeList(new DepotNode());
Iterator<DepotNode> it = depotNodes.iterator();
while (it.hasNext())
{
DepotNode d = (DepotNode) it.next();
if (d.getId().intValue() == depotNodeId
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), depotNodeId + ""))
{
it.remove();
}
}
return AjaxResult.success(depotNodes);
}
}