package com.zhengmeng.ocrplatform.fill;

import com.zhengmeng.ocrplatform.form.FormTemplateService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/fill-data")
public class FillDataController {
    private final FillDataService fillDataService;

    public FillDataController(FillDataService fillDataService) {
        this.fillDataService = fillDataService;
    }

    @GetMapping("/{taskId}/form3")
    public FillDataContractResponse getForm3FillData(@PathVariable String taskId,
                                                     @RequestParam(required = false) String templateCode) {
        FillDataPayload payload = fillDataService.buildForm3Payload(taskId, templateCode);
        return new FillDataContractResponse(0, "success", payload);
    }
}
