SettlementDiffController.java
2.16 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
package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.lang.Opt;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import vion.dto.SettlementDiffDTO;
import vion.model.FileInfo;
import vion.service.IFileService;
import vion.service.ISettlementDiffService;
import vion.vo.SettlementDiffVO;
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class SettlementDiffController {
private final ISettlementDiffService settlementDiffService;
private final IFileService fileService;
@GetMapping("/settlementDiff/{no}")
@SaCheckPermission(value = "settlementDiff:list", orRole = "admin")
public Page<SettlementDiffVO> list(@PathVariable String no, SettlementDiffDTO dto) {
return settlementDiffService.list(no, dto);
}
@GetMapping("/settlementDiff/{id}")
public SettlementDiffVO getVOById(@PathVariable Long id) {
return settlementDiffService.getVOById(id);
}
@PostMapping("/settlementDiff")
@SaCheckPermission(value = "settlementDiff:save", orRole = "admin")
public String save(@RequestBody SettlementDiffDTO dto) {
return settlementDiffService.save(dto);
}
@PostMapping("/settlementDiff/{id}")
@SaCheckPermission(value = "settlementDiff:edit", orRole = "admin")
public String update(@PathVariable Long id, @RequestBody SettlementDiffDTO dto) {
dto.setId(id);
return settlementDiffService.update(id, dto);
}
@DeleteMapping("/settlementDiff/{id}")
@SaCheckPermission(value = "settlementDiff:remove", orRole = "admin")
@Transactional(rollbackFor = Exception.class)
public String delById(@PathVariable Long id) {
Opt.ofEmptyAble(fileService.lambdaQuery()
.eq(FileInfo::getSourceId, id)
.eq(FileInfo::getType, 15)
.list())
.ifPresent(fileService::removeBatchByIds);
return settlementDiffService.removeById(id) ? "删除成功" : "删除失败";
}
}