package vip.xiaonuo.quality.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.quality.entity.QualityReagentStock;
import vip.xiaonuo.quality.entity.QualityTarget;
import vip.xiaonuo.quality.param.QualityParam;
import vip.xiaonuo.quality.param.QualityStockPageParam;
import vip.xiaonuo.quality.service.IQualityReagentStockService;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 质量试剂仓库 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-03-10
 */
@RestController
@Api(tags = "质量试剂仓库")
@ApiSupport(author = "wang", order = 1)
@Validated
public class QualityReagentStockController {

    @Autowired
    private IQualityReagentStockService stockService;

    @PostMapping("/quality-reagent-stock/page")
    @ApiOperationSupport(order = 1)
    @ApiOperation("质量试剂仓库分页")
    public CommonResult<Page<QualityReagentStock>> page(@RequestBody QualityStockPageParam stockPageParam) {
        return CommonResult.data(stockService.page(stockPageParam));
    }

    @PostMapping("/quality-reagent-stock/add")
    @ApiOperationSupport(order = 2)
    @ApiOperation("质量试剂仓库库存添加")
    public CommonResult add(@RequestBody QualityReagentStock qualityReagentStock) {
        return stockService.add(qualityReagentStock);
    }


    @PostMapping("/quality-reagent-stock/edit")
    @ApiOperationSupport(order = 3)
    @ApiOperation("质量试剂仓库库存修改")
    public CommonResult edit(@RequestBody QualityReagentStock qualityReagentStock) {
        return stockService.edit(qualityReagentStock);
    }


    @PostMapping("/quality-reagent-stock/list")
    @ApiOperationSupport(order = 4)
    @ApiOperation("质量试剂仓库列表")
    public CommonResult<List<QualityReagentStock>> list(@RequestBody Map<String,String> paramsMap) {
        String id = paramsMap.get("orgId");
        QueryWrapper<QualityReagentStock> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("org_id", id);
        return CommonResult.data(stockService.list(queryWrapper));
    }

}
