xiaoyi
3 天以前 abf1c0a35d85d38239ff5d2ed746a4e4b797c9d1
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
package cn.iocoder.yudao.module.crm.controller.admin.contract;
 
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.command.CrmContractCommandPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.command.CrmContractCommandRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.command.CrmContractCommandSaveReqVO;
import cn.iocoder.yudao.module.crm.service.contract.CrmContractCommandService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
@Tag(name = "管理后台 - CRM 合同指令")
@RestController
@RequestMapping("/crm/contract-command")
@Validated
public class CrmContractCommandController {
 
    @Resource
    private CrmContractCommandService commandService;
 
    @PostMapping("/create")
    @Operation(summary = "创建合同指令")
    @PreAuthorize("@ss.hasPermission('crm:contract-command:create')")
    public CommonResult<Long> createCommand(@Valid @RequestBody CrmContractCommandSaveReqVO createReqVO) {
        return success(commandService.createCommand(createReqVO));
    }
 
    @PutMapping("/update")
    @Operation(summary = "更新合同指令")
    @PreAuthorize("@ss.hasPermission('crm:contract-command:update')")
    public CommonResult<Boolean> updateCommand(@Valid @RequestBody CrmContractCommandSaveReqVO updateReqVO) {
        commandService.updateCommand(updateReqVO);
        return success(true);
    }
 
    @DeleteMapping("/delete")
    @Operation(summary = "删除合同指令")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('crm:contract-command:delete')")
    public CommonResult<Boolean> deleteCommand(@RequestParam("id") Long id) {
        commandService.deleteCommand(id);
        return success(true);
    }
 
    @GetMapping("/get")
    @Operation(summary = "获得合同指令")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('crm:contract-command:query')")
    public CommonResult<CrmContractCommandRespVO> getCommand(@RequestParam("id") Long id) {
        return success(commandService.getCommand(id));
    }
 
    @GetMapping("/page")
    @Operation(summary = "获得合同指令分页")
    @PreAuthorize("@ss.hasPermission('crm:contract-command:query')")
    public CommonResult<PageResult<CrmContractCommandRespVO>> getCommandPage(@Valid CrmContractCommandPageReqVO pageReqVO) {
        return success(commandService.getCommandPage(pageReqVO));
    }
 
    @PutMapping("/execute")
    @Operation(summary = "执行合同指令")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('crm:contract-command:update')")
    public CommonResult<Boolean> executeCommand(@RequestParam("id") Long id) {
        commandService.executeCommand(id);
        return success(true);
    }
 
    @PutMapping("/cancel")
    @Operation(summary = "取消合同指令")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('crm:contract-command:update')")
    public CommonResult<Boolean> cancelCommand(@RequestParam("id") Long id) {
        commandService.cancelCommand(id);
        return success(true);
    }
 
    @GetMapping("/count-by-contract")
    @Operation(summary = "统计某合同指令数量")
    @Parameter(name = "contractId", description = "合同ID", required = true)
    @PreAuthorize("@ss.hasPermission('crm:contract-command:query')")
    public CommonResult<Long> countByContract(@RequestParam("contractId") Long contractId) {
        return success(commandService.countByContractId(contractId));
    }
 
}