package com.gree.mall.miniapp.controller.material.parts;

import com.gree.mall.miniapp.bean.material.parts.WebsitPartsStockBean;
import com.gree.mall.miniapp.exception.RemoteServiceException;
import com.gree.mall.miniapp.helper.ResponseHelper;
import com.gree.mall.miniapp.logic.material.parts.WebsitPartsStockLogic;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController()
@Api(value = "网点配件库存查询", tags ={"网点配件库存查询"} )
@RequestMapping(value = "/app/parts/websit/stock", produces = "application/json; charset=utf-8")
public class WebsitStockController {

    @Resource
    WebsitPartsStockLogic websitPartsStockLogic;

    @ApiOperation(value = "查询网点库存物料分组")
    @PostMapping("/group/list")
    public ResponseHelper<List<String>> websitGroupList (
            @ApiParam(value = "网点编号",required = true) @RequestParam String websitId,
            @ApiParam(value = "配件网点编号",required = true) @RequestParam String partsWebsitId
    ) throws RemoteServiceException {
        return ResponseHelper.success(websitPartsStockLogic.websitGroupList(websitId, partsWebsitId));
    }

    @ApiOperation(value = "查询网点库存")
    @PostMapping("/list")
    public ResponseHelper<List<WebsitPartsStockBean>> existWebsitStockList (
            @ApiParam(value = "网点编号", required = true) @RequestParam String websitId,
            @ApiParam(value = "配件网点编号", required = true) @RequestParam String partsWebsitId,
            @ApiParam(value = "配件编码") @RequestParam(required = false) String partsNumber,
            @ApiParam(value = "配件名称") @RequestParam(required = false) String partsName,
            @ApiParam(value = "物料组名称") @RequestParam(required = false) String materialGroupName
    ) throws RemoteServiceException {
        return ResponseHelper.success(websitPartsStockLogic.existWebsitStockList(websitId, partsWebsitId, partsNumber, partsName, materialGroupName));
    }
}
