NAV
json

ForForm API WIKI 文档

ForForm API WIKI 自定义表单接口文档

接口调用的参数格式

目前接口部分使用 HTTP 的 Body 来进行参数传递,接口支持 application/json 的 Body 格式

同时也支持 application/x-www-form-urlencoded 的 Body 格式

两种方式均需要在 Header 中注明内容类型的属性。

请勿使用from-data传递Payload

鉴权

获取APP_ID和APP_SECRET后,通过/api/auth/token接口获取token,将token通过 authorization Bearer token的形式传递,接口详情查看具体接口文档。

接口返回说明

第一层 http code返回码,目前常见返回码如下

Http code 说明
200 调用成功
304 本地资源为最新资源,无需从服务器获取
400 调用失败,返回自定义错误
401 鉴权失败
403 权限不足,没有调用权限
412 本地资源版本和服务器资源版本不一致,请刷新
500 服务器本身出错

第二层 接口返回内容中的status和error字段

对于status,我们有如下规定

错误说明

error(针对于APP端)

为字符串,会给出status的具体错误原因描述,可信赖字段,可直接展示至前端页面

errors (针对于PC端 用于表单验证)

为一个对象,会给出status的具体错误原因描述,这个字段适用于程序开发中的错误调试,不应该把他的返回内容作为代码逻辑判断的条件。也不应直接在前端页面显示。

示例

{
    "status": 1,
    "errors": {
        "account": " account 不能为空",
        "code": " code 不能为空"
    }
}

接口地址说明

http https
线下 http://47.112.148.159:8981
预发布
正式 待定

自定义表单

获取token

HTTP Method

POST

HTTP Request

/api/auth/token

Request Parameters Query

无

Request Parameters Body

Title Description Type Required Tips
app_key app Key string 是
app_secret 密钥 string 是

Response Data

Title Description Type Required Tips
status 状态:0成功 非0失败 integer 是
token status非0时,返回错误信息,键值对 string 否
token_method 加密算法 string 是
token_type token类型 string 是
expire_time 过期时间 int 是

Response Data Json

{
    "status": 0,
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImtpZCI6ImZvcmZvcm0ifQ.eyJpc3MiOiJmb3Jmb3JtIiwic3ViIjoibmV3X21lZXRpbmdfc3lzIiwiaWRlbnQiOiIxZjY2ODQ3OGMyNDM0NGM5YjA0ZjE4MzhlYjc2MDFkNSIsImlhdCI6MTY2OTM0ODU0NywiZXhwIjoxNjY5MzUyMTQ3LCJhcHBfaWQiOjEsInJlYWQiOjEsIndyaXRlIjowfQ.1L4Lz1-Xg09VcyUw6M375jo2X5vAfnCKdkNPmgT_q8c",
    "token_method": "HS256",
    "token_type": "Bearer",
    "expire_time": 1669352147
}

获取表单配置

GET_FROM

获取表单配置

HTTP Method

GET

HTTP Request

/api/form/{id}

Request Parameters Query

Title Description Type Required Tips
id 表单ID integer 是

Request Parameters Body

无

Response Data

Title Description Type Required Tips
status 状态:0成功 非0失败 integer 是
errors status非0时,返回错误信息,键值对 object 否
data 表单具体数据 object 是

data

Title Description Type Required Tips
id 表单ID integer 是
name 表单名称 integer 是
description 表单描述 string 是
modules 表单组件列表 array 是

modules item

Title Description Type Required Tips
id 组件ID integer 是
label 组件名称 string 是
field 字段值(用于表单提交) string 是
value 组件默认值 string 是
logic_id 组件逻辑ID,用来处理逻辑组件关系 int 是
required 是否必填 bool 是
placeholder 占位符 bool 是
full_module 是否展示组件label bool 是
display 是否展示(根据logic计算) bool 是
editable 是否可编辑 bool 是
tips 组件提示 string 是
engine 组件引擎配置 object 是
regx_list 组件校验规则列表 array 是
resource 组件资源 array 是
style 组件样式(现在没有数据,待定...) array 是

engine

Title Description Type Required Tips
name 引擎名称 string 是
config 引擎配置(键值对,服务端不关心具体内容) object 否

regx_list item

Title Description Type Required Tips
id 校验ID integer 是
name 校验规则名称 string 是
expression 校验规则 string 是
error_message 错误提示 string 是

resource -> type = 1

Title Description Type Required Tips
id 资源ID integer 是
type 资源类型1本地资源 2远程资源 integer 是
title 资源名称 string 是
options 本地资源列表 object 是
api_setting 远程资源 type为1时,该值为null object 是

resource -> type = 1 -> options

Title Description Type Required Tips
label 资源名称 string 是
value 资源值1本地资源 2远程资源 string 是
event 事件 object 是

resource -> type = 1 -> options -> event

Title Description Type Required Tips
event_type 事件类型 hidden隐藏、show展示、editable编辑、disabled禁用 string 是
link_module 组件ID列表 array(integer) 是

resource -> type = 2

Title Description Type Required Tips
id 资源ID integer 是
type 资源类型1本地资源 2远程资源 integer 是
title 资源名称 string 是
options 本地资源 type为2时,该值为空数组 array 是
api_setting 远程资源配置 object 是

resource -> type = 2 -> api_setting

Title Description Type Required Tips
uri 资源地址 string 是
list_key 数据的下标 string 是
label_key 资源名称的下标 string 是
value_key 资源值的下标 string 是
children_key 子级数据下标 string 是

Response Data Json

{
    "status": 0,
    "errors": "",
    "data": {
      "id": 1,
      "title": "参会信息报名数据表单",
      "description": "会展报名的表单的介绍哦",
      "style": [],
      "modules": [
        {
          "id": 1,
          "required": true,
          "full_module": true,
          "display": true,
          "editable": true,
          "value": "",
          "logic_id": 1,
          "field": "nickname",
          "label": "参会人",
          "placeholder": "请输入您的真实姓名",
          "tips": "请确保工作人员可以联系到您",
          "engine": {
            "name": "simpleText",
            "config": {
              "length": 8
            }
          },
          "regx_list": [
            {
              "id": 13,
              "name": "中文",
              "expression": "/[一-龥豈-鶴]/",
              "error_message": "包含无效字符"
            }
          ],
          "resource": [],
          "style": []
        },
        {
          "id": 2,
          "required": true,
          "full_module": true,
          "display": true,
          "editable": true,
          "value": "",
          "logic_id": 2,
          "field": "phone",
          "label": "联系电话",
          "placeholder": "请输入您的手机号",
          "tips": "请确保工作人员可以联系到您",
          "engine": {
            "name": "simpleText",
            "config": {
              "length": 13
            }
          },
          "regx_list": [
            {
              "id": 23,
              "name": "手机号",
              "expression": "/^1[34578]\\d{9}$/",
              "error_message": "手机号不符合格式"
            }
          ],
          "resource": [],
          "style": []
        },
        {
          "id": 3,
          "required": true,
          "full_module": true,
          "display": true,
          "editable": true,
          "value": "否",
          "logic_id": 3,
          "field": "join_school_meeting",
          "label": "参加校友会",
          "placeholder": "",
          "tips": "参加校友会需要填写学校和活动类型哦",
          "engine": {
            "name": "radio",
            "config": []
          },
          "regx_list": [],
          "resource": [
            {
              "id": 23,
              "title": "选项是否",
              "type": 1,
              "api_setting": null,
              "options": [
                {
                  "label": "是",
                  "value": "是",
                  "event": {
                    "event_type": "display_on",
                    "link_module": [
                      4,
                      5
                    ]
                  }
                },
                {
                  "label": "否",
                  "value": "否",
                  "event": {
                    "event_type": "display_off",
                    "link_module": [
                      4,
                      5
                    ]
                  }
                }
              ]
            }
          ],
          "style": []
        },
        {
          "id": 4,
          "required": false,
          "full_module": true,
          "display": false,
          "editable": true,
          "value": "",
          "logic_id": 4,
          "field": "attendee_in",
          "label": "校友会活动",
          "placeholder": "请选择您想要参加的活动",
          "tips": "每人最多参加2项",
          "engine": {
            "name": "select",
            "config": {
              "max": 3,
              "searchable": true,
              "multi": true
            }
          },
          "regx_list": [],
          "resource": [
            {
              "id": 121,
              "title": "2021峰会校友会活动列表",
              "type": 2,
              "api_setting": {
                "uri": "https://www.fastmock.site/mock/532e60f1fc8ce344d5709c8f022f5cc7/api/school/attendee",
                "list_key": "data",
                "label_key": "label",
                "value_key": "value",
                "children_key": ""
              },
              "options": []
            }
          ],
          "style": []
        },
        {
          "id": 5,
          "required": false,
          "full_module": true,
          "display": false,
          "editable": true,
          "value": "",
          "logic_id": 5,
          "logic_Id": "",
          "field": "school",
          "label": "毕业院校",
          "placeholder": "请选择您的毕业院校",
          "tips": "目前仅支持本地的院校哦",
          "engine": {
            "name": "select",
            "config": {
              "max": 1,
              "searchable": true,
              "multi": false
            }
          },
          "regx_list": [],
          "resource": [
            {
              "id": 121,
              "title": "2021峰会校友会活动列表",
              "type": 2,
              "api_setting": {
                "uri": "https://www.fastmock.site/mock/532e60f1fc8ce344d5709c8f022f5cc7/api/school",
                "list_key": "data",
                "label_key": "label",
                "value_key": "value",
                "children_key": ""
              },
              "options": []
            }
          ],
          "style": []
        }
      ]
    }
}

创建表单

HTTP Method

POST

HTTP Request

/api/form

Request Parameters Query

无

Request Parameters Body

Title Description Type Required Tips
title 表单标题 integer 是
description 表单描述 string 是
modules 表单组件列表 array 是

modules item

Title Description Type Required Tips
label 组件名称 string 是
field 字段值(用于提交) string 是
value 组件默认值 string 是
logic_id 组件逻辑ID,用来处理逻辑组件关系 int 是
placeholder 占位符 bool 是
full_module 是否展示组件label bool 是
display 是否展示(根据logic计算) bool 是
editable 是否可编辑 bool 是
tips 组件提示 string 是
engine 组件引擎配置 object 是
regx_list 组件校验规则列表 array 是
resource 组件资源 array 是
style 组件样式(现在没有数据,待定...) array 是

engine

Title Description Type Required Tips
name 引擎名称 string 是
config 引擎配置 object 是

regx_list item

Title Description Type Required Tips
name 规则名称 string 是
expression 校验规则 string 是
error_message 错误提示 string 是

resource -> type = 1

Title Description Type Required Tips
type 资源类型1本地资源 2远程资源 integer 是
title 资源名称 string 是
options 本地资源列表 object 是
api_setting 远程资源 type为1时,该值为null object 是

resource -> type = 1 -> options

Title Description Type Required Tips
label 资源名称 string 是
value 资源值 string 是
event 事件 object 否

resource -> type = 1 -> options -> event

Title Description Type Required Tips
event_type 事件类型 display_on隐藏、display_off展示 string 是
link_module 组件ID列表 array(integer) 是

resource -> type = 2

Title Description Type Required Tips
type 资源类型1本地资源 2远程资源 integer 是
title 资源名称 string 是
options 本地资源 type为2时,该值为空数组 array 是
api_setting 远程资源配置 object 是

resource -> type = 2 -> api_setting

Title Description Type Required Tips
uri 资源地址 string 是
list_key 数据的下标 string 是
label_key 资源名称的下标 string 是
value_key 资源值的下标 string 是
children_key 子级数据下标 string 是

Request Parameters Body Json

{
    "title": "参会信息报名数据表单",
    "description": "会展报名的表单的介绍哦",
    "style": [],
    "modules": [
        {
            "required": true,
            "full_module": true,
            "display": true,
            "editable": true,
            "value": "",
            "logic_id": 1,
            "field": "nickname",
            "label": "参会人",
            "placeholder": "请输入您的真实姓名",
            "tips": "请确保工作人员可以联系到您",
            "engine": {
                "name": "simpleText",
                "config": {
                    "length": 8
                }
            },
            "regx_list": [
                {
                    "expression": "/[一-龥豈-鶴]/",
                    "error_message": "包含无效字符"
                }
            ],
            "resource": [],
            "style": []
        },
        {
            "required": true,
            "full_module": true,
            "display": true,
            "editable": true,
            "value": "",
            "logic_id": 2,
            "field": "phone",
            "label": "联系电话",
            "placeholder": "请输入您的手机号",
            "tips": "请确保工作人员可以联系到您",
            "engine": {
                "name": "simpleText",
                "config": {
                    "length": 13
                }
            },
            "regx_list": [
                {
                    "expression": "/^1[34578]\\d{9}$/",
                    "error_message": "手机号不符合格式"
                }
            ],
            "resource": [],
            "style": []
        },
        {
            "required": true,
            "full_module": true,
            "display": true,
            "editable": true,
            "value": "否",
            "logic_id": 3,
            "field": "join_school_meeting",
            "label": "参加校友会",
            "placeholder": "",
            "tips": "参加校友会需要填写学校和活动类型哦",
            "engine": {
                "name": "radio",
                "config": []
            },
            "regx_list": [],
            "resource": [
                {
                    "title": "选项是否",
                    "type": 1,
                    "api_setting": null,
                    "options": [
                        {
                            "label": "是",
                            "value": "是",
                            "event": {
                                "event_type": "display_on",
                                "link_module": [
                                    4,
                                    5
                                ]
                            }
                        },
                        {
                            "label": "否",
                            "value": "否",
                            "event": {
                                "event_type": "display_off",
                                "link_module": [
                                    4,
                                    5
                                ]
                            }
                        }
                    ]
                }
            ],
            "style": []
        },
        {
            "required": false,
            "full_module": true,
            "display": false,
            "editable": true,
            "value": "",
            "logic_id": 4,
            "field": "attendee_in",
            "label": "校友会活动",
            "placeholder": "请选择您想要参加的活动",
            "tips": "每人最多参加2项",
            "engine": {
                "name": "select",
                "config": {
                    "max": 3,
                    "searchable": true,
                    "multi": true
                }
            },
            "regx_list": [],
            "resource": [
                {
                    "title": "2021峰会校友会活动列表",
                    "type": 2,
                    "api_setting": {
                        "uri": "https://www.fastmock.site/mock/532e60f1fc8ce344d5709c8f022f5cc7/api/school/attendee",
                        "list_key": "data",
                        "label_key": "label",
                        "value_key": "value",
                        "children_key": ""
                    },
                    "options": []
                }
            ],
            "style": []
        },
        {
            "required": false,
            "full_module": true,
            "display": false,
            "editable": true,
            "value": "",
            "logic_id": 5,
            "field": "school",
            "label": "毕业院校",
            "placeholder": "请选择您的毕业院校",
            "tips": "目前仅支持本地的院校哦",
            "engine": {
                "name": "select",
                "config": {
                    "max": 1,
                    "searchable": true,
                    "multi": false
                }
            },
            "regx_list": [],
            "resource": [
                {
                    "title": "2021峰会校友会活动列表",
                    "type": 2,
                    "api_setting": {
                        "uri": "https://www.fastmock.site/mock/532e60f1fc8ce344d5709c8f022f5cc7/api/school",
                        "list_key": "data",
                        "label_key": "label",
                        "value_key": "value",
                        "children_key": ""
                    },
                    "options": []
                }
            ],
            "style": []
        }
    ]
}

Response Parameters Body

Title Description Type Required Tips
status 状态码 int 0成功 非0失败
data 表单数据 object 是

data

Title Description Type Required Tips
id 表单ID string 是
app_id 应用ID string 是
name 表单名称 string 是
description 表单描述 string 是
bg_img 表单背景图 string 是
status 表单状态 int 0禁用 1启用

Response Parameters Body Json

{
    "status": 0,
    "data": {
        "id": 186,
        "app_id": 1,
        "name": "参会信息报名数据表单",
        "description": "会展报名的表单的介绍哦",
        "source": null,
        "bg_img": null,
        "status": null
    }
}

更新表单

HTTP Method

PUT

HTTP Request

/api/form/{id}

Request Parameters Query

无

Request Parameters Body

Title Description Type Required Tips
title 表单标题 integer 是
description 表单描述 string 是
modules 表单组件列表 array 是 参数详情见创建表单接口

Response Data

Title Description Type Required Tips
status 状态0成功 非0失败 int 是
data 表单组件数据 string 是

data

Title Description Type Required Tips
id 表单ID string 是
app_id 应用ID string 是
name 表单名称 string 是
description 表单描述 string 是
bg_img 表单背景图 string 是
status 表单状态 int 0禁用 1启用

Response Parameters Body Json

{
    "status": 0,
    "data": {
        "id": 186,
        "app_id": 1,
        "name": "参会信息报名数据表单",
        "description": "会展报名的表单的介绍哦",
        "source": null,
        "bg_img": null,
        "status": null
    }
}

更新单个组件

HTTP Method

POST

HTTP Request

/api/form/module/{module_id}

Request Parameters Query

无

Request Parameters Body

Title Description Type Required Tips
label 组件名称 string 是
field 字段值(用于提交) string 是
value 组件默认值 string 是
logic_id 组件逻辑ID,用来处理逻辑组件关系 int 是
placeholder 占位符 bool 是
full_module 是否展示组件label bool 是
display 是否展示(根据logic计算) bool 是
editable 是否可编辑 bool 是
tips 组件提示 string 是
engine 组件引擎配置(详细参数:参考更新接口) object 是
regx_list 组件校验规则列表(详细参数:参考更新接口) array 是
resource 组件资源(详细参数:参考更新接口) array 是

Response Data

Title Description Type Required Tips
status 状态0成功 非0失败 int 是
data 表单组件数据 string 是

data

Title Description Type Required Tips
id 组件ID int 是
form_id 表单ID int 是
label 组件名称 string 是
field 组件字段 string 是
description 描述 string 是
tips 提示 string 是
value 默认值 string 是
placeholder 占位符 string 是
display 是否展示 bool 是
editable 是否禁用 bool 是

Response Data Json

{
    "status": 0,
    "data": {
        "id": 318,
        "form_id": 138,
        "label": "Test",
        "field": "api_test",
        "description": null,
        "tips": "这是测试",
        "value": "",
        "placeholder": "这是测试",
        "display": true,
        "editable": true
    }
}

删除单个组件

HTTP Method

DELETE

HTTP Request

/api/form/module/{module_id}

Request Parameters Query

无

Request Parameters Body

无

Response Data

Title Description Type Required Tips
status 状态0成功 非0失败 int 是

Response Data Json

{
    "status": 0
}

搜索校验规则

HTTP Method

GET

HTTP Request

/api/rule/search

Request Parameters Query

无

Request Parameters Body

无

Response Data

Title Description Type Required Tips
status 状态0成功 非0失败 int 是
data 规则列表 array 是

data

Title Description Type Required Tips
id 规则ID int 是
app_id 应用ID int 是
name 规则名称 string 是
expression 校验逻辑 string 是
error_message 错误提示 string 是

Response Data Json

{
  "status": 0,
  "data": [
    {
      "id": 37,
      "app_id": 1,
      "name": "必须是中文",
      "expression": "/[\u9e00-\u9fa5]/",
      "error_message": "包含无效字符"
    }
  ]
}

搜索资源

HTTP Method

GET

HTTP Request

/api/resource/search

Request Parameters Query

Title Description Type Required Tips
type 搜索的资源类型 int 否 默认搜索全部资源 1搜索本地资源 2搜索远程资源

Request Parameters Body

无

Response Data

Title Description Type Required Tips
status 状态0成功 非0失败 int 是
data 资源列表 array 是

data

Title Description Type Required Tips
id 资源ID int 是
app_id 应用ID int 是
type 资源类型 int 是 1本地资源 2远程资源
title 资源名称 string 是
api_settings 远程资源详情 object 否 当type为1时,值为null
options 本地资源详情 array 否 当type为2时,值为null

data -> type = 1

Title Description Type Required Tips
type 资源类型1本地资源 2远程资源 integer 是
title 资源名称 string 是
options 本地资源列表 object 是
api_setting 远程资源 type为1时,该值为null object 是

data -> type = 1 -> options

Title Description Type Required Tips
label 资源名称 string 是
value 资源值 string 是

resource -> type = 2 -> api_setting

Title Description Type Required Tips
uri 资源地址 string 是
list_key 数据的下标 string 是
label_key 资源名称的下标 string 是
value_key 资源值的下标 string 是
children_key 子级数据下标 string 是

Response Data Json -> type = 1

{
  "status": 0,
  "data": [
    {
      "id": 23,
      "app_id": 1,
      "type": 1,
      "title": "选项是否",
      "api_settings": [],
      "options": [
        {
          "id": 142,
          "resource_id": 23,
          "label": "是",
          "value": "是"
        },
        {
          "id": 143,
          "resource_id": 23,
          "label": "否",
          "value": "否"
        }
      ]
    }
  ]
}

Response Data Json -> type = 2

{
  "status": 0,
  "data": [
    {
      "id": 23,
      "app_id": 1,
      "type": 1,
      "title": "测试远程资源",
      "options": [],
      "api_settings": [
        {
          "id": 139,
          "resource_id": 121,
          "uri": "https://www.fastmock.site/mock/532e60f1fc8ce344d5709c8f022f5cc7/api/school",
          "list_key": "data",
          "label_key": "label",
          "value_key": "value",
          "children_key": ""
        }
      ]
    }
  ]
}

Log

日期 作者 内容
2022/11/18 xlq 创建

文档使用帮助

在index.html.md文件中进行编辑目录和文档总体结构,然后在includes目录中添加对应的模块。

文档使用Markdown语言排版。

Markdown格式示例


# 标题
## 二级标题
### .......
    ```json
      代码块
    ```

表格
表头 | 表头
---------- | -------
内容 | 内容
内容 | 内容

`Something`

表格

表头 表头
内容 内容
内容 内容

Json 是没有注释的 避免在json中写注释

Something 高亮

加粗 粗体

横线

下划线

斜体

链接

图片