package com.huimv.receive.controller;


import com.huimv.receive.common.utils.Result;
import com.huimv.receive.common.utils.ResultCode;
import com.huimv.receive.service.IBillSamplingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.ParseException;
import java.util.Map;

/**
 * <p>
 * 洗消表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-03-11
 */
@RestController
@RequestMapping("/bill-sampling")
@CrossOrigin
public class BillSamplingController {

    @Autowired
    private IBillSamplingService billSamplingService;

    @RequestMapping("/listSampling")
    public Result listSampling(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
        return billSamplingService.list(httpServletRequest, paramsMap);
    }

    @RequestMapping("/listById")
    public Result listById(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
        return billSamplingService.listById(httpServletRequest, paramsMap);
    }

    @PostMapping("/listPersonalSample")
    public Result listPersonalSample(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap){
        return billSamplingService.listPersonalSample(httpServletRequest,paramsMap);
    }

    @PostMapping("/getDetail")
    public Result getDetail(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap){
        return new Result(ResultCode.SUCCESS,billSamplingService.getById(paramsMap.get("id")));
    }

    @PostMapping("/edit")
    public Result goodsCarClean(HttpServletRequest httpServletRequest, @RequestParam("id") String id,
                                @RequestParam("date") String data,
                                @RequestParam(value = "video", required = false) MultipartFile video,
                                @RequestParam("farmId") String farmId) throws IOException, ParseException {
        return billSamplingService.edit(httpServletRequest, farmId, id, data, video);
    }
}
