package com.hys.app.controller.erp.use;

import com.hys.app.framework.context.user.AdminUserContext;
import com.hys.app.framework.database.WebPage;
import com.hys.app.model.erp.dto.StockDamageReportDTO;
import com.hys.app.model.erp.dto.StockDamageReportParam;
import com.hys.app.model.erp.dto.StockDamageReportStatisticsParam;
import com.hys.app.model.erp.vo.StockDamageReportVO;
import com.hys.app.model.support.LogClient;
import com.hys.app.model.support.validator.annotation.Log;
import com.hys.app.service.erp.StockDamageReportManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * 库存报损单相关API
 *
 * @author dmy
 * 2023-12-05
 */
@Api(description = "库存报损单相关API")
@RestController
@RequestMapping("/admin/stock/damage/report")
@Validated
public class StockDamageReportManagerController {

    @Autowired
    private StockDamageReportManager stockDamageReportManager;

    @ApiOperation(value = "查询库存报损单分页列表数据")
    @GetMapping
    public WebPage list(StockDamageReportParam params) {
        return stockDamageReportManager.list(params);
    }

    @ApiOperation(value = "新增库存报损单")
    @PostMapping
    @Log(client = LogClient.admin, detail = "新增库存报损单")
    public void add(@RequestBody @Valid StockDamageReportDTO stockDamageReportDTO) {
        AdminUserContext.hasCompany();
        this.stockDamageReportManager.add(stockDamageReportDTO);
    }

    @ApiOperation(value = "查询库存报损单详细信息")
    @GetMapping("/{id}")
    public StockDamageReportVO getDetail(@PathVariable Long id) {
        return stockDamageReportManager.getDetail(id);
    }

    @ApiOperation(value = "导出库存报损单商品统计列表")
    @GetMapping("/export")
    public void export(HttpServletResponse response, StockDamageReportStatisticsParam params) {
        this.stockDamageReportManager.export(response, params);
    }
}
