/*
 * Author: wangjian
 * 生成controller
 */
package com.tofly.stocks.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.stocks.dto.StockInfoQuery;
import com.tofly.stocks.service.StockInfoService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.web.bind.annotation.ModelAttribute;

import java.util.Arrays;
/**
 * 物资库存信息表
 *
 * @author admin
 * @date Fri Nov 25 00:00:00 CST 2022
 */
@RestController
@AllArgsConstructor
@RequestMapping("/stockinfo")
@Api(tags="物资库存信息表接口")
public class StockInfoController {

    private final  StockInfoService stockInfoService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param stockInfoQuery 物资库存信息表
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "物资库存信息，分页查询")
    public ResultRespone getStockInfoPage(Page page, @ModelAttribute StockInfoQuery stockInfoQuery) {
      return ResultRespone.success(stockInfoService.getDataByPage(page, stockInfoQuery));
    }


    /**
     * 通过id查询物资库存信息表
     * @param id id
     * @return ResultRespone
     */
    @GetMapping("/{id}" )
    @ApiOperation(value = "通过ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
    })
    public ResultRespone getById(@PathVariable("id" ) Long id) {
      return ResultRespone.success(stockInfoService.getById(id));
    }


    /**
     * 通过库存查询物资入库记录
     * @param stockInfoId id
     * @return ResultRespone
     */
    @GetMapping("/inStorePage" )
    @ApiOperation(value = "通过库存ID查询物资入库记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stockInfoId", value = "库存ID", required = false, dataType = "Long")
    })
    public ResultRespone getInStorePage(Page page, Long stockInfoId) {
        return ResultRespone.success(stockInfoService.getInStoreDataPage(page,stockInfoId));
    }

    /**
     * 通过库存查询物资入库记录
     * @param stockInfoId id
     * @return ResultRespone
     */
    @GetMapping("/outStorePage" )
    @ApiOperation(value = "通过库存ID查询物资出库记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stockInfoId", value = "库存ID", required = false, dataType = "Long")
    })
    public ResultRespone getOutStorePage(Page page, Long stockInfoId) {
        return ResultRespone.success(stockInfoService.getOutStoreDataPage(page,stockInfoId));
    }

    /**
     * 通过库存查询物资入库记录
     * @param stockInfoId id
     * @return ResultRespone
     */
    @GetMapping("/useStorePage" )
    @ApiOperation(value = "通过库存ID查询物资使用记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stockInfoId", value = "库存ID", required = false, dataType = "Long")
    })
    public ResultRespone getDrugUsePage(Page page, Long stockInfoId) {
        return ResultRespone.success(stockInfoService.getDrugUseDataPage(page,stockInfoId));
    }

    /**
     * 通过库存查询物资转移记录
     * @param stockInfoId id
     * @return ResultRespone
     */
    @GetMapping("/transStorePage" )
    @ApiOperation(value = "通过库存查询物资转移记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stockInfoId", value = "库存ID", required = false, dataType = "Long")
    })
    public ResultRespone getTransPage(Page page, Long stockInfoId) {
        return ResultRespone.success(stockInfoService.getTransDataPage(page,stockInfoId));
    }

    /**
     * 通过库存ID查询物资盘点记录
     * @param stockInfoId id
     * @return ResultRespone
     */
    @GetMapping("/checkStorePage" )
    @ApiOperation(value = "通过库存ID查询物资盘点记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stockInfoId", value = "库存ID", required = false, dataType = "Long")
    })
    public ResultRespone getCheckPage(Page page, Long stockInfoId) {
        return ResultRespone.success(stockInfoService.getCheckDataPage(page,stockInfoId));
    }


    /**
     * 通过库存ID查询物资处置信息
     * @param stockInfoId id
     * @return ResultRespone
     */
    @GetMapping("/handleStorePage" )
    @ApiOperation(value = "通过库存ID查询物资处置信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stockInfoId", value = "库存ID", required = false, dataType = "Long")
    })
    public ResultRespone getHandlePage(Page page, Long stockInfoId) {
        return ResultRespone.success(stockInfoService.getHandleDataPage(page,stockInfoId));
    }

    /**
     * 新增物资库存信息表
     * @param stockInfo 物资库存信息表
     * @return ResultRespone
     *//*
    @ToFlyAppLog(title="新增物资库存信息表" )
    @ApiOperation(value = "新增物资库存信息表")
    @PostMapping
    public ResultRespone save(@RequestBody StockInfo stockInfo) {
      return ResultRespone.success(stockInfoService.save(stockInfo));
    }

    *//**
     * 修改物资库存信息表
     * @param stockInfo 物资库存信息表
     * @return ResultRespone
     *//*
    @ToFlyAppLog(title="修改物资库存信息表" )
    @ApiOperation(value = "修改物资库存信息表")
    @PutMapping
    public ResultRespone updateById(@RequestBody StockInfo stockInfo) {
      return ResultRespone.success(stockInfoService.updateById(stockInfo));
    }

    *//**
     * 通过id删除物资库存信息表
     * @param id id
     * @return ResultRespone
     *//*
    @ToFlyAppLog(title="通过id删除物资库存信息表" )
    @ApiOperation(value = "通过ID删除物资库存信息表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
    })
    @DeleteMapping("/{id}" )
    public ResultRespone removeById(@PathVariable Long id) {
      return ResultRespone.success(stockInfoService.removeById(id));
    }

    *//**
     * 通过id批量删除物资库存信息表
     * @param ids id
     * @return ResultRespone
     *//*
    @ToFlyAppLog(title="通过id批量删除物资库存信息表" )
    @ApiOperation(value = "通过ID批量删除物资库存信息表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/deleteByIds" )
    public ResultRespone removeById(String ids) {
        return ResultRespone.success(stockInfoService.removeByIds(Arrays.asList(ids.split(","))));
    }*/
}
