SafetyController.java
3.26 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
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.core.domain.entity.SysDept;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.Inventory;
import com.ruoyi.service.domain.Safety;
import com.ruoyi.service.domain.SafetyDetail;
import com.ruoyi.service.domain.Tree;
import com.ruoyi.service.service.InventoryService;
import com.ruoyi.service.service.SafetyService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 安全检查
*
* @author ym
*/
@RestController
@RequestMapping("/service/safety")
public class SafetyController extends BaseController
{
@Resource
private SafetyService safetyService;
@GetMapping("/treeselect")
public AjaxResult treeselect(SysDept dept)
{
List<Tree> tree=safetyService.treeSelect();
return AjaxResult.success(tree);
}
@PreAuthorize("@ss.hasPermi('service:safety:add')")
@Log(title = "安全检查", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody Safety safety)
{
return toAjax(safetyService.insert(safety));
}
@PreAuthorize("@ss.hasPermi('service:safety:edit')")
@Log(title = "安全检查", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody Safety safety)
{
if (safetyService.update(safety) > 0)
{
return AjaxResult.success();
}
return AjaxResult.error("编辑失败,请联系管理员");
}
@PreAuthorize("@ss.hasPermi('service:safety:remove')")
@Log(title = "安全检查", businessType = BusinessType.DELETE)
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id)
{
safetyService.delete(id);
return success();
}
@PreAuthorize("@ss.hasPermi('service:safety:list')")
@GetMapping("/list")
public TableDataInfo list(Safety safety)
{
startPage();
List<Safety> list = safetyService.selectList(safety);
return getDataTable(list);
}
@PreAuthorize("@ss.hasPermi('service:safetyDetail:add')")
@Log(title = "安全检查详情", businessType = BusinessType.INSERT)
@PostMapping("/addDetail")
public AjaxResult addDetail(@Validated @RequestBody SafetyDetail safetyDetail)
{
return toAjax(safetyService.insertDetail(safetyDetail));
}
@PreAuthorize("@ss.hasPermi('service:safetyDetail:list')")
@GetMapping("/detailList")
public TableDataInfo detailList(SafetyDetail safetyDetail)
{
List<SafetyDetail> list = safetyService.selectDetailList(safetyDetail);
return getDataTable(list);
}
@PostMapping("/selectCount")
public AjaxResult selectCount(@Validated @RequestBody SafetyDetail safetyDetail)
{
AjaxResult ajaxResult=new AjaxResult();
ajaxResult.put("count",safetyService.selectCountByCheckType(safetyDetail));
return ajaxResult;
}
}