InspectController.java
2.17 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
package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import vion.dto.InspectDTO;
import vion.model.Inspect;
import vion.service.IInspectService;
import vion.vo.InspectVO;
import java.util.Date;
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
@Slf4j
public class InspectController {
private final IInspectService inspectService;
private final Converter converter;
@GetMapping("/inspects")
@SaCheckPermission(value = "inspect:list", orRole = "admin")
public Page<InspectVO> getInspectList(InspectDTO data) {
return inspectService.getInspectList(data);
}
@GetMapping("/inspect")
@SaCheckPermission(value = "inspect:query", orRole = "admin")
public InspectVO getById(@RequestParam(name = "id") Long id) {
return inspectService.getById(id);
}
@PostMapping("/inspects")
@SaCheckPermission(value = "inspect:editAndSave", orRole = "admin")
public String saveOrUpdate(@RequestBody InspectDTO data) {
Inspect inspect = converter.convert(data, new Inspect());
return inspectService.saveOrUpdate(inspect) ? "成功" : "失败";
}
@PostMapping("/updateInspectStatus")
@SaCheckPermission(value = "inspect:editStatus", orRole = "admin")
public String UpdateStatus(@RequestBody InspectDTO data) {
boolean result = inspectService.lambdaUpdate()
.eq(Inspect::getId, data.getId())
.set(Inspect::getStatus, data.getStatus())
.set(Inspect::getAuditDate, new Date())
.set(Inspect::getReviewer, data.getReviewer())
//审核状态为已完成的时候更新完成时间(0进行中、1待审核、2已完成、3、驳回)
.set(data.getStatus() == 2, Inspect::getFinishDate, new Date())
.update();
if (result) {
return "更新巡检状态成功";
} else {
return "更新巡检状态失败";
}
}
}