V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
wen20
V2EX  ›  程序员

一个 GO 开发的 restful 读写 MySQL 小工具

  •  
  •   wen20 · 13 天前 · 560 次点击

    工具名称 FlyBird Restful

    FlyBird Restful 是一个提供 Restful 风格 json 格式读写 MySQL 数据的小工具。

    本工具从某 MySQL GUI 管理工具提取出的核心部分,做了精简,只支持指定数据库 CURD 操作。
    一个数据表对应 restful 接口的一个资源。

    支持复杂查询条件, 如:is between ,does not contain 等。具体见仓库文档

    支持原生 SQL Query,Execute 。(详见文档,本文只阐述 restful 使用)

    使用场景

    • 前端/小程序开发人员,开发有动态数据的简单应用。
    • 数据增删改查,为数据库提供 restful 风格 json 格式 的 api 接口

    restful 接口 说明

    • GET /restful/:tableName ( query 分页查询 )
    • GET /restful/:tableName/:id ( 获取单条数据)
    • PUT /restful/:tableName {body}( 新增数据 )
    • POST /restful/:tableName/:id {body}( 更新数据 )
    • DELETE /restful/:tableName/:id ( 删除数据 )

    put 和 post body 体为 json 格式

    如何使用

    下载 binary 执行包,直接运行, 支持 Linux, Windows, MacOS 。
    支持 Docker 和 k8s 云平台(如微信云平台),image 地址:youwen21/flybird-restful

    数据表设计

    要求表主键名为 ID

    接口示例

    Query

    parameters

    parameter type default
    page int 1
    psize int 20
    orderBy int -
    orderDirect int -
    GET {{host}}/restful/:tableName?page=2&psize=10&orderBy="id"&orderDirect="asc"
    

    Get

    GET {{host}}/restful/:tableName/:id
    

    Insert

    PUT {{host}}/restful/:tableName/
    
    {
      "params":{
        "key1":"value1",
        "key2":"value2"
      }
    }
    

    Update

    POST {{host}}/restful/:tableName/:id
    
    {
      "params":{
        "key1":"value1",
        "key2":"value2"
      }
    }
    

    Delete

    DELETE {{host}}/restful/:tableName/:id
    

    软件地址

    https://github.com/youwen21/flybird-restful

    Have fun

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3220 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 11:17 · PVG 19:17 · LAX 04:17 · JFK 07:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.