| | |
| | | package com.ruoyi.inventory.controller; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.basic.dto.SupplierManageDto; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.inventory.dto.StockManagementDto; |
| | | import com.ruoyi.inventory.dto.StockoutDto; |
| | | import com.ruoyi.inventory.pojo.StockManagement; |
| | | import com.ruoyi.inventory.service.StockManagementService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | import static com.ruoyi.framework.web.domain.AjaxResult.error; |
| | |
| | | public class StockManagementController { |
| | | @Autowired |
| | | private StockManagementService stockManagementService; |
| | | @RequestMapping("/list")// 列出所有出库记录 |
| | | public AjaxResult listStockOuts() { |
| | | List<StockManagement> stockManagements = stockManagementService.getStockManagements(); |
| | | return success(stockManagements); |
| | | } |
| | | @GetMapping("/{id}")// 根据ID获取出库记录 |
| | | public AjaxResult getStockOutById(@PathVariable Long id) { |
| | | StockManagement stockManagement = stockManagementService.getStockManagementById(id); |
| | | return success(stockManagement); |
| | | } |
| | | @PostMapping("add")// 新增出库记录 |
| | | public AjaxResult addStockOut(@RequestBody StockManagement stockManagement) { |
| | | int i = stockManagementService.addStockManagement(stockManagement); |
| | | if(i>0){ |
| | | return success(); |
| | | } |
| | | return error(); |
| | | } |
| | | @PutMapping("/update")// 更新出库记录 |
| | | public AjaxResult updateStockOut(@RequestBody StockManagement stockManagement) { |
| | | int i = stockManagementService.updateStockManagement(stockManagement); |
| | | if(i>0){ |
| | | return success(); |
| | | } |
| | | return error(); |
| | | } |
| | | @DeleteMapping("/delete/{id}")// 删除出库记录 |
| | | public AjaxResult deleteStockOut(@PathVariable Long id) { |
| | | int i = stockManagementService.deleteStockManagement(id); |
| | | if(i>0){ |
| | | return success(); |
| | | } |
| | | return error(); |
| | | } |
| | | |
| | | // 更新库存 |
| | | @PutMapping("/update") |
| | | public AjaxResult updateStockManagement(@RequestBody StockManagement stockManagement) { |
| | | stockManagementService.updateStockManagement(stockManagement); |
| | | return AjaxResult.success(); |
| | | } |
| | | @DeleteMapping("/del") |
| | | public AjaxResult delStockManage(@RequestBody List<Integer> ids) { |
| | | if(CollectionUtils.isEmpty(ids)){ |
| | | return AjaxResult.error("请选择至少一条数据"); |
| | | } |
| | | stockManagementService.delStockManage(ids); |
| | | return AjaxResult.success(); |
| | | } |
| | | // 分页查询 |
| | | @GetMapping("/page") |
| | | public AjaxResult getStockManagementPage(Page page, StockManagementDto stockManagementdto) { |
| | | return success(stockManagementService.selectStockManagePage(page, stockManagementdto)); |
| | | } |
| | | // 导出 |
| | | @PostMapping("/export") |
| | | public void stockmanageExport(HttpServletResponse response, StockManagementDto stockManagementDto) { |
| | | stockManagementService.stockManageExport(response, stockManagementDto); |
| | | } |
| | | } |