package com.ruoyi.inventory.controller; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.inventory.service.StockInService; import com.ruoyi.inventory.pojo.StockIn; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController @RequestMapping("/stockin") public class StockInController extends BaseController { @Autowired private StockInService stockInService; @PostMapping("/add")// 新增入库记录 public AjaxResult addStockIn(@RequestBody StockIn stockIn) { int i = stockInService.addStockIn(stockIn); if(i>0){ return success(); } return error(); } @GetMapping("/list")// 列出所有入库记录 public AjaxResult listStockIns() { List stockIns = stockInService.listStockIns(); return success(stockIns); } @GetMapping("/{id}")// 根据ID获取入库记录 public AjaxResult getStockInById(@PathVariable Long id) { StockIn stockIn = stockInService.getStockInById(id); return success(stockIn); } @PutMapping("/update")// 更新入库记录 public AjaxResult updateStockIn(@RequestBody StockIn stockIn) { int i = stockInService.updateStockIn(stockIn); if(i>0){ return success(); } return error(); } @DeleteMapping("/delete/{id}")// 删除入库记录 public AjaxResult deleteStockIn(@PathVariable Long id) { int i = stockInService.deleteStockIn(id); if(i>0){ return success(); } return error(); } // @Log(title = "岗位管理", businessType = BusinessType.EXPORT) // @PreAuthorize("@ss.hasPermi('system:post:export')") @GetMapping("/export")// 导出入库数据 public AjaxResult exportStockInData() { List stockIns = stockInService.listStockIns(); ExcelUtil util = new ExcelUtil(StockIn.class); util.exportExcel(stockIns, "库存入库信息"); return success(); } }