Skip to content

collect

YourtionGuo edited this page Feb 26, 2021 · 2 revisions

数据收集 ( Collect ) 相关文档

数据表信息 ✅

请求地址:GET /collect/:table

参数:

参数名 位置 类型 格式化 必填 说明
table params String 表名

使用示例:

// 数据表信息 - /api/collect/collect_test 
input = {};
output = {
  "success": true,
  "result": {
    "schema": {
      "id": {
        "name": "id",
        "type": "Integer",
        "comment": "",
        "nullable": false,
        "default": null
      },
      "article": {
        "name": "article",
        "type": "String",
        "comment": "",
        "nullable": false,
        "default": ""
      },
      "count": {
        "name": "count",
        "type": "Integer",
        "comment": "",
        "nullable": false,
        "default": "0"
      }
    },
    "primary": "id",
    "id": 1,
    "table_name": "collect_test",
    "is_update": 1
  }
};

创建收集数据 ✅

请求地址:POST /collect/:table

参数:

参数名 位置 类型 格式化 必填 说明
table params String 表名
data body Object 收集的数据
update body Boolean 插入冲突是否更新数据
info body Boolean 是否需要插入后详情

使用示例:

// 创建收集数据 - /api/collect/collect_test 
input = {
  "data": {
    "article": "CWed Feb 24 2021 17:41:19 GMT+0800 (China Standard Time)"
  }
};
output = {
  "success": true,
  "result": "操作成功"
};

// 创建收集数据 - /api/collect/collect_test 
input = {
  "data": {
    "count": 30,
    "id": 1,
    "article": "AWed Feb 24 2021 17:41:19 GMT+0800 (China Standard Time)"
  },
  "update": true
};
output = {
  "success": true,
  "result": "操作成功"
};

修改收集数据 ✅

请求地址:PUT /collect/:table

参数:

参数名 位置 类型 格式化 必填 说明
table params String 表名
field body String 唯一键名
data body Object 需要修改的对象

使用示例:

// 修改收集数据 - /api/collect/collect_test 
input = {
  "field": "id",
  "data": {
    "count": 20,
    "id": 2
  }
};
output = {
  "success": true,
  "result": "操作成功"
};

获取收集数据列表 ✅

请求地址:GET /collect/:table/list

参数:

参数名 位置 类型 格式化 必填 说明
table params String 表名
page query Integer 第n页
page_count query Integer 每页数量(默认30)
order query String 排序字段(默认id)
asc query Boolean 是否升序(默认false)
limit query Integer 限制n条数据(优先)
offset query Integer 跳过n条数据(优先)

使用示例:

// 获取收集数据列表 - /api/collect/collect_test/list 
input = {};
output = {
  "success": true,
  "result": {
    "page_data": {
      "page": 1,
      "page_count": 30,
      "count": 2
    },
    "list": [
      {
        "id": 1,
        "article": "AWed Feb 24 2021 17:41:19 GMT+0800 (China Standard Time)",
        "count": 30
      },
      {
        "id": 2,
        "article": "CWed Feb 24 2021 17:41:19 GMT+0800 (China Standard Time)",
        "count": 0
      }
    ]
  }
};

获取收集数据条目 ✅

请求地址:GET /collect/:table/item

参数:

参数名 位置 类型 格式化 必填 说明
table params String 表名
field query String 键名
data query String 键值
rank query String 排名字段
count query Boolean 是否获取总数

使用示例:

// 获取收集数据条目 - /api/collect/collect_test/item?field=id&data=2&rank=id&count=true 
input = {
  "field": "id",
  "data": 2,
  "rank": "id",
  "count": true
};
output = {
  "success": true,
  "result": {
    "id": 2,
    "article": "CWed Feb 24 2021 17:41:19 GMT+0800 (China Standard Time)",
    "count": 2,
    "rank": 1
  }
};

获取收集数据列自增 ✅

请求地址:POST /collect/:table/incr

参数:

参数名 位置 类型 格式化 必填 说明
table params String 表名
primary body String 主键值
primaryName body String 主键名
field body String 增加键
count body Integer 增加数量(默认1)

使用示例:

// 获取收集数据列自增 - /api/collect/collect_test/incr 
input = {
  "primary": "2",
  "field": "count",
  "count": 2
};
output = {
  "success": true,
  "result": "操作成功"
};