package thyyxxk.webserver.controller.reports;

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 thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.reports.medicinestockcount.GetStockParam;
import thyyxxk.webserver.entity.reports.medicinestockcount.SaveStockDetailParam;
import thyyxxk.webserver.entity.reports.medicinestockcount.StockDetail;
import thyyxxk.webserver.entity.reports.medicinestockcount.StockIndex;
import thyyxxk.webserver.service.reports.MedicineStockCountService;

import java.util.List;

@RestController
@RequestMapping("/medicineStockCount")
public class MedicineStockCountController {
    private final MedicineStockCountService service;

    @Autowired
    public MedicineStockCountController(MedicineStockCountService service) {
        this.service = service;
    }

    @PostMapping("/getStockIndex")
    public ResultVo<List<StockIndex>> getStockIndex(@RequestBody @Validated GetStockParam param) {
        return service.getStockIndex(param);
    }

    @PostMapping("/getStockDetail")
    public ResultVo<List<StockDetail>> getStockDetail(@RequestBody GetStockParam param) {
        return service.getStockDetail(param);
    }

    @PostMapping("/saveStockChanges")
    public ResultVo<String> saveStockChanges(@RequestBody @Validated SaveStockDetailParam param) {
        return service.saveStockChanges(param);
    }
}
