package com.fjhx.controller.water;

import com.fjhx.entity.water.WaterBatch;
import com.fjhx.params.water.WaterBatchVo;
import com.fjhx.service.water.WaterBatchService;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
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 java.util.Map;

/**
 * <p>
 * 批次 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-09-20
 */
@RestController
@RequestMapping("/waterBatch")
public class WaterBatchController {

    @Autowired
    private WaterBatchService waterBatchService;

    @PostMapping("/getDetailsByContract")
    public R getByContract(@RequestBody WaterBatch waterBatch) {
        Map<String, Object> result = waterBatchService.getDetailsByContract(waterBatch.getContractId());
        return R.success(result);
    }

    @PostMapping("/add")
    public R add(@RequestBody WaterBatchVo waterBatchVo) {
        waterBatchService.add(waterBatchVo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody WaterBatchVo waterBatchVo) {
        waterBatchService.delete(waterBatchVo);
        return R.success();
    }

    /**
     * 出货
     */
    @PostMapping("/shipment")
    public R shipment(WaterBatch waterBatch) {
        waterBatchService.shipment(waterBatch);
        return R.success();
    }

    /**
     * 批次详情
     */
    @PostMapping("/details")
    public R details(WaterBatch waterBatch) {
        return R.success(waterBatchService.getById(waterBatch.getId()));
    }

}

