package com.bonus.material.ma.controller;

import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.bonus.material.ma.domain.PutInStorageBean;
import com.bonus.material.ma.domain.SavePutInfoDto;
import com.bonus.material.ma.domain.SupplierInfo;
import com.bonus.material.ma.service.WarehousingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.java.Log;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @description 入库盘点
*/
@Api(tags = " 入库盘点")
@RestController
@RequestMapping("/warehousing")
@Slf4j
public class WarehousingController extends BaseController {
    @Autowired
    private WarehousingService warehousingService;

    /**
     * 查询入库盘点列表
     */
    @ApiOperation(value = "获取入库盘点列表")
    @GetMapping("/getList")
    public TableDataInfo getList(PutInStorageBean bean) {
        startPage();
        List<PutInStorageBean> list = warehousingService.getList(bean);
        return getDataTable(list);
    }

    /**
     * 查询供应商管理列表
     */
    @ApiOperation(value = "查询供应商管理列表")
    @GetMapping("/supplierInfoList")
    public TableDataInfo supplierInfoList(SupplierInfo maSupplierInfo)
    {
        List<SupplierInfo> list = warehousingService.selectMaSupplierInfoList(maSupplierInfo);
        return getDataTable(list);
    }

    /**
     * 新增入库盘点
     * @param dto
     * @return
     */
    @ApiOperation(value = "新增入库盘点")
    @PreventRepeatSubmit
    @PostMapping("/addList")
    public AjaxResult savePutInfo(@RequestBody SavePutInfoDto dto) {
        return warehousingService.savePutInfo(dto);
    }


    /**
     * 根据入库单号查看详情
     * @param bean
     * @return
     */
    @ApiOperation(value = "根据入库单号查看详情")
    @GetMapping("/getDetail")
    public TableDataInfo getDetail(PutInStorageBean bean) {
        startPage();
        List<PutInStorageBean> list = warehousingService.getDetails(bean);
        return getDataTable(list);
    }

}
