package com.by4cloud.platformx.business.controller;
|
|
import cn.hutool.core.util.StrUtil;
|
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.common.core.util.R;
|
import com.by4cloud.platformx.common.log.annotation.SysLog;
|
import com.by4cloud.platformx.business.entity.ContractOutBound;
|
import com.by4cloud.platformx.business.service.ContractOutBoundService;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import com.by4cloud.platformx.common.excel.annotation.ResponseExcel;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import org.springdoc.core.annotations.ParameterObject;
|
import org.springframework.http.HttpHeaders;
|
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 syt
|
* @date 2026-05-14 09:21:54
|
*/
|
@RestController
|
@RequiredArgsConstructor
|
@RequestMapping("/contractOutBound" )
|
@Tag(description = "contractOutBound" , name = "合同出库管理" )
|
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
public class ContractOutBoundController {
|
|
private final ContractOutBoundService contractOutBoundService;
|
|
/**
|
* 分页查询
|
* @param page 分页对象
|
* @param contractOutBound 合同出库
|
* @return
|
*/
|
@Operation(summary = "分页查询" , description = "分页查询" )
|
@GetMapping("/page" )
|
@PreAuthorize("@pms.hasPermission('business_contractOutBound_view')" )
|
public R getContractOutBoundPage(@ParameterObject Page page, @ParameterObject ContractOutBound contractOutBound) {
|
LambdaQueryWrapper<ContractOutBound> wrapper = Wrappers.lambdaQuery();
|
wrapper.like(StrUtil.isNotBlank(contractOutBound.getBusGuestName()),ContractOutBound::getBusGuestName,contractOutBound.getBusGuestName());
|
wrapper.like(StrUtil.isNotBlank(contractOutBound.getContractName()),ContractOutBound::getContractName,contractOutBound.getContractName());
|
wrapper.like(StrUtil.isNotBlank(contractOutBound.getSubjectMatterName()),ContractOutBound::getSubjectMatterName,contractOutBound.getSubjectMatterName());
|
wrapper.orderByDesc(ContractOutBound::getCreateTime);
|
return R.ok(contractOutBoundService.pageByScope(page, wrapper));
|
}
|
|
|
/**
|
* 通过id查询合同出库
|
* @param id id
|
* @return R
|
*/
|
@Operation(summary = "通过id查询" , description = "通过id查询" )
|
@GetMapping("/{id}" )
|
@PreAuthorize("@pms.hasPermission('business_contractOutBound_view')" )
|
public R getById(@PathVariable("id" ) Long id) {
|
return R.ok(contractOutBoundService.getById(id));
|
}
|
|
/**
|
* 新增合同出库
|
* @param contractOutBound 合同出库
|
* @return R
|
*/
|
@Operation(summary = "新增合同出库" , description = "新增合同出库" )
|
@SysLog("新增合同出库" )
|
@PostMapping
|
@PreAuthorize("@pms.hasPermission('business_contractOutBound_add')" )
|
public R save(@RequestBody ContractOutBound contractOutBound) {
|
return R.ok(contractOutBoundService.save(contractOutBound));
|
}
|
|
/**
|
* 修改合同出库
|
* @param contractOutBound 合同出库
|
* @return R
|
*/
|
@Operation(summary = "修改合同出库" , description = "修改合同出库" )
|
@SysLog("修改合同出库" )
|
@PutMapping
|
@PreAuthorize("@pms.hasPermission('business_contractOutBound_edit')" )
|
public R updateById(@RequestBody ContractOutBound contractOutBound) {
|
return R.ok(contractOutBoundService.updateById(contractOutBound));
|
}
|
|
/**
|
* 通过id删除合同出库
|
* @param ids id列表
|
* @return R
|
*/
|
@Operation(summary = "通过id删除合同出库" , description = "通过id删除合同出库" )
|
@SysLog("通过id删除合同出库" )
|
@DeleteMapping
|
@PreAuthorize("@pms.hasPermission('business_contractOutBound_del')" )
|
public R removeById(@RequestBody Long[] ids) {
|
return R.ok(contractOutBoundService.removeBatchByIds(CollUtil.toList(ids)));
|
}
|
|
|
/**
|
* 导出excel 表格
|
* @param contractOutBound 查询条件
|
* @param ids 导出指定ID
|
* @return excel 文件流
|
*/
|
@ResponseExcel
|
@GetMapping("/export")
|
@PreAuthorize("@pms.hasPermission('business_contractOutBound_export')" )
|
public List<ContractOutBound> export(ContractOutBound contractOutBound,Long[] ids) {
|
return contractOutBoundService.list(Wrappers.lambdaQuery(contractOutBound).in(ArrayUtil.isNotEmpty(ids), ContractOutBound::getId, ids));
|
}
|
}
|