NAV
json

ForForm API WIKI 文档

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

接口调用的参数格式

目前接口部分使用 HTTPBody 来进行参数传递,接口支持 application/jsonBody 格式

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

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

请勿使用from-data传递Payload

鉴权

获取APP_IDAPP_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 高亮

加粗 粗体

横线

下划线

斜体

链接

图片