yaowanxin
3 天以前 e83d4cecece6e8677392229e996dea22bbe2d1e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.ruoyi.inventory.controller;
 
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.inventory.mapper.StockManagementMapper;
import com.ruoyi.inventory.mapper.StockProductMapper;
import com.ruoyi.inventory.service.StockInService;
import com.ruoyi.inventory.domain.StockIn;
import com.ruoyi.project.system.domain.SysPost;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.util.List;
 
@RestController
@RequestMapping("/stockin")
public class StockInController extends BaseController {
    @Autowired
    private StockInService stockInService;
    @Autowired
    private StockManagementMapper stockManagementMapper;
    @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<StockIn> 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<StockIn> stockIns = stockInService.listStockIns();
        ExcelUtil<StockIn> util = new ExcelUtil<StockIn>(StockIn.class);
        util.exportExcel(stockIns, "库存入库信息");
        return success();
    }
 
 
}