package com.bonus.sgzb.material.controller;

import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
import com.bonus.sgzb.common.log.annotation.Log;
import com.bonus.sgzb.common.log.enums.BusinessType;
import com.bonus.sgzb.common.security.annotation.PreventRepeatSubmit;
import com.bonus.sgzb.material.domain.PutInStorageBean;
import com.bonus.sgzb.base.api.domain.SavePutInfoDto;
import com.bonus.sgzb.material.service.InventoryAndWarehousingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @description 入库盘点
* @author hay
* @date   2024/3/27 13:28
*/
@Api(tags = " 入库盘点")
@RestController
@RequestMapping("/inventoryAndWarehousing")
@Slf4j
public class InventoryAndWarehousingController extends BaseController {
    @Autowired
    private InventoryAndWarehousingService inventoryAndWarehousingService;

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

    /**
     * 新增入库盘点
     * @param dto
     * @return
     */
    @ApiOperation(value = "新增入库盘点")
    @PreventRepeatSubmit
    @PostMapping("/addList")
    @Log(title = "盘点入库操作", businessType = BusinessType.MATERIAL)
    public AjaxResult savePutInfo(@RequestBody SavePutInfoDto dto) {
        return inventoryAndWarehousingService.savePutInfo(dto);
    }


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

}
