package com.by4cloud.platformx.device.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.common.core.util.R; import com.by4cloud.platformx.common.log.annotation.SysLog; import com.by4cloud.platformx.device.entity.InventoryFlowWater; import com.by4cloud.platformx.device.service.InventoryFlowWaterService; 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.api.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 pig * @date 2025-03-13 10:22:39 */ @RestController @RequiredArgsConstructor @RequestMapping("/inventoryFlowWater" ) @Tag(description = "inventoryFlowWater" , name = "库存流水表管理" ) @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class InventoryFlowWaterController { private final InventoryFlowWaterService inventoryFlowWaterService; /** * 分页查询 * @param page 分页对象 * @param inventoryFlowWater 库存流水表 * @return */ @Operation(summary = "分页查询" , description = "分页查询" ) @GetMapping("/page" ) @PreAuthorize("@pms.hasPermission('platformx_inventoryFlowWater_view')" ) public R getInventoryFlowWaterPage(@ParameterObject Page page, @ParameterObject InventoryFlowWater inventoryFlowWater) { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); return R.ok(inventoryFlowWaterService.page(page, wrapper)); } /** * 通过id查询库存流水表 * @param id id * @return R */ @Operation(summary = "通过id查询" , description = "通过id查询" ) @GetMapping("/{id}" ) @PreAuthorize("@pms.hasPermission('platformx_inventoryFlowWater_view')" ) public R getById(@PathVariable("id" ) Long id) { return R.ok(inventoryFlowWaterService.getById(id)); } /** * 新增库存流水表 * @param inventoryFlowWater 库存流水表 * @return R */ @Operation(summary = "新增库存流水表" , description = "新增库存流水表" ) @SysLog("新增库存流水表" ) @PostMapping @PreAuthorize("@pms.hasPermission('platformx_inventoryFlowWater_add')" ) public R save(@RequestBody InventoryFlowWater inventoryFlowWater) { return R.ok(inventoryFlowWaterService.save(inventoryFlowWater)); } /** * 修改库存流水表 * @param inventoryFlowWater 库存流水表 * @return R */ @Operation(summary = "修改库存流水表" , description = "修改库存流水表" ) @SysLog("修改库存流水表" ) @PutMapping @PreAuthorize("@pms.hasPermission('platformx_inventoryFlowWater_edit')" ) public R updateById(@RequestBody InventoryFlowWater inventoryFlowWater) { return R.ok(inventoryFlowWaterService.updateById(inventoryFlowWater)); } /** * 通过id删除库存流水表 * @param ids id列表 * @return R */ @Operation(summary = "通过id删除库存流水表" , description = "通过id删除库存流水表" ) @SysLog("通过id删除库存流水表" ) @DeleteMapping @PreAuthorize("@pms.hasPermission('platformx_inventoryFlowWater_del')" ) public R removeById(@RequestBody Long[] ids) { return R.ok(inventoryFlowWaterService.removeBatchByIds(CollUtil.toList(ids))); } /** * 导出excel 表格 * @param inventoryFlowWater 查询条件 * @param ids 导出指定ID * @return excel 文件流 */ @ResponseExcel @GetMapping("/export") @PreAuthorize("@pms.hasPermission('platformx_inventoryFlowWater_export')" ) public List export(InventoryFlowWater inventoryFlowWater,Long[] ids) { return inventoryFlowWaterService.list(Wrappers.lambdaQuery(inventoryFlowWater).in(ArrayUtil.isNotEmpty(ids), InventoryFlowWater::getId, ids)); } }