package cn.axzo.workflow.server.controller.web.form;

import cn.axzo.workflow.common.model.request.form.instance.FormContentUpdateDTO;
import cn.axzo.workflow.core.service.FormInstanceService;
import cn.axzo.workflow.server.common.annotation.ErrorReporter;
import cn.azxo.framework.common.model.CommonResponse;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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 static cn.azxo.framework.common.model.CommonResponse.success;

/**
 * 表单模型相关控制器
 *
 * @author wangli
 * @since 2023/7/21 15:23
 */
@Slf4j
@RequestMapping("/web/v1/api/form/instance")
@RestController
@ErrorReporter
@Validated
public class FormInstanceController {

    @Autowired
    private FormInstanceService formInstanceService;

    @Operation(summary = "更新表单内容")
    @PostMapping("/content/update")
    public CommonResponse<Boolean> updateFormContent(@Validated @RequestBody FormContentUpdateDTO dto) {
        formInstanceService.updateFormContent(dto);
        return success(true);
    }

}
