V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
wen20
V2EX  ›  程序员

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

  •  
  •   wen20 · May 21, 2024 · 1448 views
    This topic created in 709 days ago, the information mentioned may be changed or developed.

    工具名称 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

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5224 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 08:02 · PVG 16:02 · LAX 01:02 · JFK 04:02
    ♥ Do have faith in what you're doing.