package com.huimv.receive.controller;


import com.huimv.receive.common.utils.Result;
import com.huimv.receive.common.utils.ResultCode;
import com.huimv.receive.service.IBillCleanBeforeService;
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-clean-before")
@CrossOrigin
public class BillCleanBeforeController {

    @Autowired
    private IBillCleanBeforeService billCleanBeforeService;

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


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

    @PostMapping("/getDetail")
    public Result getDetail(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap){
        return new Result(ResultCode.SUCCESS,billCleanBeforeService.getById(paramsMap.get("id")));
    }
    @PostMapping("/edit")
    public Result goodsCarClean(HttpServletRequest httpServletRequest, @RequestParam("id") String id,
                                @RequestParam("date") String data,
                                @RequestParam(value = "img1", required = false) MultipartFile img,
                                @RequestParam(value = "img2", required = false) MultipartFile img1,
                                @RequestParam(value = "img3", required = false) MultipartFile img2,
                                @RequestParam(value = "img4", required = false) MultipartFile img3,
                                @RequestParam("farmId") String farmId) throws IOException, ParseException {
        return billCleanBeforeService.edit(httpServletRequest, farmId, id, data, img,img1,img2,img3);
    }

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