package thyyxxk.webserver.controller.medicalinsurance;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.medicalinsurance.manage.inventory.*;
import thyyxxk.webserver.service.medicalinsurance.SiInventoryService;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/siInventory")
public class SiInventoryController {
    private final SiInventoryService service;

    @Autowired
    public SiInventoryController(SiInventoryService service) {
        this.service = service;
    }

    @PassToken
    @PostMapping("/uploadInvinfo")
    public ResultVo<String> uploadInvinfo(@RequestBody List<InvinfoUpload> invinfo) {
        return service.uploadInvinfo(invinfo);
    }

    @PassToken
    @PostMapping("/modifyInvinfo")
    public ResultVo<JSONObject> modifyInvinfo(@RequestBody List<InvinfoModify> invinfo) {
        return service.modifyInvinfo(invinfo);
    }

    @PassToken
    @PostMapping("/modifyInvinfoItem")
    public ResultVo<JSONObject> modifyInvinfoItem(@RequestBody InvinfoModify invinfo) {
        return service.modifyInvinfoItem(invinfo);
    }

    @PassToken
    @PostMapping("/purchaseGoods")
    public ResultVo<String> purchaseGoods(@RequestBody List<PurcinfoBought> purcinfo) {
        return service.purchaseGoods(purcinfo);
    }

    @PassToken
    @PostMapping("/saleGoodsItem")
    public ResultVo<JSONObject> saleGoodsItem(@RequestBody Map<String, Object> selinfo) throws IOException {
        return service.saleGoodsItem(selinfo);
    }

    @PassToken
    @PostMapping("/returnGoodsItem")
    public ResultVo<JSONObject> returnGoodsItem(@RequestBody Map<String, Object> selinfo) throws IOException {
        return service.returnGoodsItem(selinfo);
    }

    @PassToken
    @PostMapping("/selectSalesGoodsItem")
    public ResultVo<JSONObject> selectSalesGoodsItem(@RequestBody Map<String, Object> selinfo) {
        return service.selectSalesGoodsItem(selinfo);
    }

    @PassToken
    @PostMapping("/selectModifyInvinfoItem")
    public ResultVo<JSONObject> selectModifyInvinfoItem(@RequestBody Map<String, Object> selinfo) {
        return service.selectModifyInvinfoItem(selinfo);
    }

    @PassToken
    @PostMapping("/returnGoods")
    public ResultVo<String> returnGoods(@RequestBody List<PurcinfoBought> purcinfo) {
        return service.returnGoods(purcinfo);
    }

    @PassToken
    @PostMapping("/saleGoods")
    public ResultVo<JSONObject> saleGoods(@RequestBody List<SelinfoSold> selinfo) {
        return service.saleGoods(selinfo);
    }

    @PassToken
    @PostMapping("/returnSales")
    public ResultVo<JSONObject> returnSales(@RequestBody List<SelinfoReturn> selinfo) {
        return service.returnSales(selinfo);
    }

    @PassToken
    @PostMapping("/deleteGoods")
    public ResultVo<JSONObject> deleteGoods(@RequestBody List<InvinfoDelete> invinfo) {
        return service.deleteGoods(invinfo);
    }
}
