| | |
| | | package com.by4cloud.platformx.business.controller; |
| | | |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.by4cloud.platformx.business.entity.Contract; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.log.annotation.SysLog; |
| | | import com.by4cloud.platformx.business.service.ContractService; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import com.by4cloud.platformx.common.excel.annotation.ResponseExcel; |
| | | import io.swagger.v3.oas.annotations.security.SecurityRequirement; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springdoc.core.annotations.ParameterObject; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * @author cd |
| | | * @description |
| | | * @date 2026/4/29 14:05 |
| | | **/ |
| | | * 合同管理 |
| | | * |
| | | * @author platformx |
| | | * @date 2026-04-29 16:46:26 |
| | | */ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping("/contract" ) |
| | | @Tag(description = "contract" , name = "合同表管理" ) |
| | | @Tag(description = "contract" , name = "合同管理管理" ) |
| | | @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) |
| | | public class ContractController { |
| | | |
| | | private final ContractService contractService; |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param page 分页对象 |
| | | * @param contract 合同管理 |
| | | * @return |
| | | */ |
| | | @Operation(summary = "分页查询" , description = "分页查询" ) |
| | | @GetMapping("/page" ) |
| | | @PreAuthorize("@pms.hasPermission('business_contract_view')" ) |
| | | public R getContractPage(@ParameterObject Page page, @ParameterObject Contract contract) { |
| | | LambdaQueryWrapper<Contract> wrapper = Wrappers.lambdaQuery(); |
| | | return R.ok(contractService.page(page, wrapper)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通过id查询合同管理 |
| | | * @param id id |
| | | * @return R |
| | | */ |
| | | @Operation(summary = "通过id查询" , description = "通过id查询" ) |
| | | @GetMapping("/{id}" ) |
| | | @PreAuthorize("@pms.hasPermission('business_contract_view')" ) |
| | | public R getById(@PathVariable("id" ) Long id) { |
| | | return R.ok(contractService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 新增合同管理 |
| | | * @param contract 合同管理 |
| | | * @return R |
| | | */ |
| | | @Operation(summary = "新增合同管理" , description = "新增合同管理" ) |
| | | @SysLog("新增合同管理" ) |
| | | @PostMapping |
| | | @PreAuthorize("@pms.hasPermission('business_contract_add')" ) |
| | | public R save(@RequestBody Contract contract) { |
| | | return R.ok(contractService.save(contract)); |
| | | } |
| | | |
| | | /** |
| | | * 修改合同管理 |
| | | * @param contract 合同管理 |
| | | * @return R |
| | | */ |
| | | @Operation(summary = "修改合同管理" , description = "修改合同管理" ) |
| | | @SysLog("修改合同管理" ) |
| | | @PutMapping |
| | | @PreAuthorize("@pms.hasPermission('business_contract_edit')" ) |
| | | public R updateById(@RequestBody Contract contract) { |
| | | return R.ok(contractService.updateById(contract)); |
| | | } |
| | | |
| | | /** |
| | | * 通过id删除合同管理 |
| | | * @param ids id列表 |
| | | * @return R |
| | | */ |
| | | @Operation(summary = "通过id删除合同管理" , description = "通过id删除合同管理" ) |
| | | @SysLog("通过id删除合同管理" ) |
| | | @DeleteMapping |
| | | @PreAuthorize("@pms.hasPermission('business_contract_del')" ) |
| | | public R removeById(@RequestBody Long[] ids) { |
| | | return R.ok(contractService.removeBatchByIds(CollUtil.toList(ids))); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出excel 表格 |
| | | * @param contract 查询条件 |
| | | * @param ids 导出指定ID |
| | | * @return excel 文件流 |
| | | */ |
| | | @ResponseExcel |
| | | @GetMapping("/export") |
| | | @PreAuthorize("@pms.hasPermission('business_contract_export')" ) |
| | | public List<Contract> export(Contract contract,Long[] ids) { |
| | | return contractService.list(Wrappers.lambdaQuery(contract).in(ArrayUtil.isNotEmpty(ids), Contract::getId, ids)); |
| | | } |
| | | } |