ContractController.java
1.98 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
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 org.springframework.web.bind.annotation.*;
import vion.cron.ContractRunner;
import vion.dto.ContractDTO;
import vion.model.RContractStore;
import vion.service.IContractService;
import vion.service.IRContractStoreService;
import vion.vo.ContractVO;
import java.util.List;
/**
* 合同管理
*/
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class ContractController {
private final IContractService contractService;
private final ContractRunner contractRunner;
private final IRContractStoreService contractStoreService;
private final Converter converter;
@GetMapping("/contract")
@SaCheckPermission(value = "contract:list", orRole="admin")
public Page<ContractVO> list(ContractDTO dto) {
return contractService.list(dto);
}
@GetMapping("/contract/{id}")
@SaCheckPermission(value = "contract:query", orRole="admin")
public ContractVO getById(@PathVariable Long id) {
return converter.convert(contractService.getById(id), new ContractVO());
}
@PostMapping("/contract/{id}")
@SaCheckPermission(value = "contract:edit", orRole="admin")
public String updateById(@PathVariable Long id, ContractDTO dto) {
return contractService.updateById(id, dto);
}
@PostMapping("/contract/store")
@SaCheckPermission(value = "contract:store:edit", orRole = "admin")
public String saveOrUpdateRContractStore(@RequestBody List<RContractStore> contractStoreList) {
return contractStoreService.saveBatch(contractStoreList) ? "更新成功" : "更新失败";
}
@PostMapping("/contractSync")
@SaCheckPermission(value = "contract:sync", orRole="admin")
public String manualSyncContract() {
return contractRunner.contractSync() ? "成功" : "失败";
}
}