package ink.wgink.module.form.controller.api.design;

import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.form.pojo.dtos.design.FormFieldDTO;
import ink.wgink.module.form.service.design.IFormFieldService;
import ink.wgink.pojo.result.ErrorResult;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;

import java.util.List;

/**
 * @ClassName: FormController
 * @Description: 表单
 * @Author: wanggeng
 * @Date: 2022/3/10 7:38 AM
 * @Version: 1.0
 */
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "表单")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/form-field")
public class FormFieldController extends DefaultBaseController {

    @Autowired
    private IFormFieldService formFieldService;

    @ApiOperation(value = "字段列表", notes = "字段列表接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "formId", value = "表单ID", paramType = "path")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("list/form-id/{formId}")
    public List<FormFieldDTO> listByFormId(@PathVariable("formId") String formId) {
        return formFieldService.listByFormId(formId);
    }

}
