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 createCommand(@Valid @RequestBody CrmContractCommandSaveReqVO createReqVO) { return success(commandService.createCommand(createReqVO)); } @PutMapping("/update") @Operation(summary = "更新合同指令") @PreAuthorize("@ss.hasPermission('crm:contract-command:update')") public CommonResult 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 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 getCommand(@RequestParam("id") Long id) { return success(commandService.getCommand(id)); } @GetMapping("/page") @Operation(summary = "获得合同指令分页") @PreAuthorize("@ss.hasPermission('crm:contract-command:query')") public CommonResult> 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 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 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 countByContract(@RequestParam("contractId") Long contractId) { return success(commandService.countByContractId(contractId)); } }