<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          ZetaAPI動態(tài)生成 Api 文檔

          聯(lián)合創(chuàng)作 · 2023-09-29 22:39

          ZetaAPI 是一個使用 SQL + XML 快速創(chuàng)建 Api 接口與使用文檔的框架,幫助開發(fā)者提升開發(fā)效率。

          框架特性

          1. 配置簡單功能豐富
          2. 使用xml標(biāo)簽屬性就可支持緩存,默認(rèn)緩存實現(xiàn)為caffeine,也可自定義緩存實現(xiàn)
          3. 標(biāo)簽內(nèi)if分支判斷,用于處理各種復(fù)雜場景
          4. 自定義訪問攔截,可通過創(chuàng)建攔截器修改表達(dá)式與返回結(jié)果
          5. 動態(tài)生成Api文檔,可以方便的查看API接口,支持在線測試與接口編輯
          6. 支持xml熱更新,無需重啟容器,即可讀取最新xml配置

          使用方法

          1. 創(chuàng)建spring boot項目,添加zeta-api依賴
          2. 配置數(shù)據(jù)庫連接與數(shù)據(jù)庫驅(qū)動
          3. 入口類設(shè)置注解掃描路徑 @SpringBootApplication(scanBasePackages = "xyz.erupt")
          4. 創(chuàng)建配置文件,/resources/epi/xxx.xml
          5. xml文件示范例
          <?xml version="1.0" encoding="utf-8" ?>
          <zeta desc="zeta接口示例">
              <hello-world title="基礎(chǔ)使用">
                  select 'hello world' $key
              </hello-world>
          
              <cache cache="5000" title="使用緩存(cache單位毫秒)">
                  select 'cache',now() now
              </cache>
          
              <params title="參數(shù)獲取與處理">
                  <param key="param" default="hello zeta" title="返回值"/>
                  select :param param
              </params>
          
              <condition title="條件處理">
                  <param key="param" default="" title="數(shù)值"/>
                  select
                  <if test="param > 10">
                      'gt 10' param_status
                  </if>
                  <if test="param < 10">
                      'lt 10' param_status
                  </if>
                  <if test="param == 10">
                      'eq 10' param_status
                  </if>
              </condition>
          
              <insert title="插入數(shù)據(jù)">
                  <param key="content" title="待插入數(shù)據(jù)"/>
                  insert into demo(content) values (:content)
              </insert>
          </zeta>

          啟動項目,查看接口文檔:http://host/zeta?doc/host/zeta?doc/{xml文件名}.html
          img

          application.yml配置項說明

          zeta-api:
            #是否熱讀取xml配置,生產(chǎn)環(huán)境不要開啟此功能
            hotReadXml: true
            #是否開始緩存功能
            enableCache: true
            #是否開啟Api文檔查詢功能
            enableApiDoc: true
            #自定義緩存實現(xiàn),需實現(xiàn)xyz.erupt.zeta_api.handler.ZetaCache接口
            cacheHandlerPath: xyz.erupt.xxxx
            #是否打印sql語句
            showSql: true
            #訪問白名單,空表示不對ip進(jìn)行鑒權(quán)
            ipWhite:
              - 127.0.0.1
              - 192.168.1.1
              - 192.168.1.187

          接口請求示例

          // jquery為例
          $.ajax({
              type: "POST",
              url: "/zeta-api/sql/{file}/{name}",
              contentType: "application/json",    //請求內(nèi)容需要為json
              data: JSON.stringify({ param: 10}), //必須使用JSON.stringify
              success: function (res) {
                  alert(res);
              }
          });

           

          瀏覽 25
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  久久系列| 一级婬片A片试看50分钟 | 国产亚洲色婷婷精品99久久 | 香蕉视频在线色 | A片黄色电影 |