package com.jwipc.order.controller.pc;

import com.jwipc.order.dto.PurchaseOrderMarkDTO;
import com.jwipc.order.logic.PurchaseOrderMarkLogic;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Set;

import static com.jwipc.order.constant.ModuleConst.MODULE_ROOT;

/**
 * <p> </p>
 *
 * @author ZhangJie
 * @version 1.0
 * @since JDK 1.8
 */
@RestController
@RequestMapping(MODULE_ROOT + "/purchaseOrderMark/rest")
@RequiredArgsConstructor
public class PurchaseOrderMarkRestController {
    private final PurchaseOrderMarkLogic purchaseOrderMarkLogic;

    @PostMapping("/import/mark/{type}")
    public ResponseEntity<Set<String>> importMark(
            @PathVariable("type") int type, @RequestPart("file") MultipartFile file
    )
    {
        Set<String> msg = purchaseOrderMarkLogic.importMark(file, type);
        return ResponseEntity.ok(msg);
    }

    @PostMapping("/import/mark1")
    public ResponseEntity<Set<String>> importMark1(@RequestPart("file") MultipartFile file
    )
    {
        Set<String> msg = purchaseOrderMarkLogic.importMark1(file);
        return ResponseEntity.ok(msg);
    }

    @PostMapping("/updateBatch")
    public ResponseEntity updateBatch(@RequestBody List<PurchaseOrderMarkDTO> purchaseOrderMark) {
        purchaseOrderMarkLogic.updateBatch(purchaseOrderMark);
        return ResponseEntity.ok().build();
    }
}
