Asset - 友好速搭 -- 开发文档

友好速搭

开放 API
使用说明 获取授权 全部 API 特殊 API 开放功能

Asset

Asset

#实体关系 Asset 为 Theme 包含的文件,一个 Theme 包含多个 Asset 。

Asset 相关API

GET /themes/#{id}/assets获取 Theme 所有的 AssetGET /themes/#{id}/assets?asset[key]=获取 Theme 的单个 AssetPOST /themes/#{id}/assets创建 AssetPUT /themes/#{id}/assets更新 AssetDELETE /themes/#{id}/assets?asset[key]=删除 Asset

Asset 属性

    • theme_id
    •   { "theme_id" : 1480 }
      
      Number 类型,Asset 所属 Theme 的唯一整型标识。
    • key
    •   { "key" : "assets/favicon.ico" }
      
      String 类型,Asset 的路径,包含五个路径分别为:layout, config, assets, templates, snippets, 在 assets 文件夹中.jpg .jpeg .gif .png .bmp .webp格式的图片是不带后缀的。
    • type
    •   { "type" : "system" }
      
      String 类型,Asset 读取的位置,system 表示为主题模版文件,custom 表示为自定义文件。
    • trash
    •   { "trash" : false }
      
      Bool 类型,Asset 是否能删除,true 表示可以删除,false 表示不允许删除。
    • rename
    •   { "rename" : false }
      
      Bool 类型,Asset 是否能重命名,true 表示可以重命名,false 表示不允许重命名。
    • value
    •   { "value" : "12345" }
      
      String 类型,Asset 的内容,当文件为图片文件的时候为 null,图片只提供访问路径,在 public_url 里面。
    • public_url
    •   { "public_url" : //asset.ibanquan.com/middle/1482/c/122/54fd4a906387e4ead9000776/blogs_banner_img?rand=1427792969 }
      
      String 类型,Asset 的内容,当文件不是图片时为 null。
    • version
    •   { "version" : "d66407160dc04dc2aa4946c205afabe0" }
      
      String 类型,Asset 的当前版本,当文件变更时,版本号会对应进行变更。

GET /themes/#{id}/assets

获取 Theme 所有的 Asset

    • fields
    • 需要查询的字段
    • 获取 Theme 所有的 Asset
    • GET /themes/1482/assets
    • {
          "assets": [
              {
                  "key": "assets/favicon.ico",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "assets/jquery.slides.min.js",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "assets/logo",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "assets/main.css",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "assets/main.js",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "assets/pro_list_banner_img",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "assets/share_box.js",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "assets/user.css",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "config/settings.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "config/settings_data.json",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "layout/theme.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "snippets/filter.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "snippets/filter_simple.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "snippets/footer.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "snippets/go_top.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "snippets/nav_list.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "snippets/oauth.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false
              },
              {
                  "key": "snippets/page_mod.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "snippets/popup.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "snippets/products_filter.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "snippets/products_grid.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "snippets/products_grid_item.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "snippets/products_list_mod.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "snippets/products_paginate.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "snippets/sample_blogs.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "snippets/sample_products.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "snippets/share_box.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "snippets/sys_mod.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/account/change_password.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/account/create_order.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/account/forget_password.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/account/index.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/account/login.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/account/order.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/account/orders_list.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/account/register.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/account/reset_password.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/account/validate_email.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/blog.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/blogs_list.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/cart.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/discount.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/index.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/page.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/product.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/products_list.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/search.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/system/404.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/system/500.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/system/closing.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/system/protecting.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/type.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              },
              {
                  "key": "templates/vendor.html",
                  "theme_id": 1482,
                  "type": "system",
                  "trash": false,
                  "rename": false,
                  "version": null
              }
          ]
      }
      

GET /themes/#{id}/assets?asset[key]=

获取 Theme 的单个 Asset

    • fields
    • 需要查询的字段
    • 获取 Asset 文本文件内容
    • GET /themes/1482/assets?asset[key]=templates/account/change_password.html
    • {
          "asset": {
              "theme_id": 1482,
              "key": "templates/account/change_password.html",
              "type": "system",
              "value": "{% unless form.posted_successfully? %}\n\n...",
              "public_url": null,
              "trash": false,
              "rename": false,
              "version": null
          }
      }
      
    • 获取 Asset 图片文件内容
    • GET /themes/1482/assets?asset[key]=assets/blogs_banner_img
    • {
          "asset": {
              "theme_id": 1482,
              "key": "assets/blogs_banner_img",
              "type": "system",
              "value": null,
              "public_url": "//asset.ibanquan.com/middle/1482/c/122/54fd4a906387e4ead9000776/blogs_banner_img?rand=1427792969",
              "trash": false,
              "rename": false,
              "version": null
          }
      }
      

POST /themes/#{id}/assets

创建 Asset

    • asset[key]
    • 文件名
    • asset[value]
    • 内容
    • 创建 Asset 文本文件
    • POST /themes/1482/assets
      {
          "asset": {
              "key": "templates/test.html",
              "value": "987654321"
          }
      }
      
    • {
          "asset": {
              "theme_id": 1482,
              "key": "templates/test.html",
              "type": "custom",
              "value": "987654321",
              "public_url": null,
              "trash": true,
              "rename": true
          }
      }
      
    • 创建 Asset 图片文件
    • POST /themes/1482/assets
      {
          "asset": {
              "key": "assets/test.gif",
              "value": "data:image/gif;base64,R0lGODlhAQABAID/AP///wAAACwAAAAAAQABAAACAkQBADs="
          }
      }
      
    • {
          "asset": {
              "theme_id": 1482,
              "key": "assets/test",
              "type": "custom",
              "value": null,
              "public_url": "//asset.ibanquan.com/asset/551a656e6387e4bb1a000001/test?rand=1427794434",
              "trash": true,
              "rename": true
          }
      }}
      

PUT /themes/#{id}/assets

更新 Asset

    • asset[key]
    • 主题访问路径
    • asset[value]
    • 新内容
    • asset[version]
    • 文件版本号,非必须,当回传该参数时,表示验证文件版本是否被变更,有变更时返回422错误,没有变更时,直接保存,当不回传该参数时,表示强制保存。
    • 更新 Asset 文本文件
    • PUT /themes/1482/assets
      {
          "asset": {
              "key": "templates/test.html",
              "value": "987654321",
              "version": "d66407160dc04dc2aa4946c205afabe0"
          }
      }
      
    • {
          "asset": {
              "theme_id": 1482,
              "key": "templates/test.html",
              "type": "custom",
              "value": "987654321",
              "public_url": null,
              "trash": true,
              "rename": true
          }
      }
      
    • 更新 Asset 图片文件
    • PUT /themes/1482/assets
      {
          "asset": {
              "key": "assets/test.gif",
              "value": "data:image/gif;base64,R0lGODlhAQABAID/AP///wAAACwAAAAAAQABAAACAkQBADs="
          }
      }
      
    • {
          "asset": {
              "theme_id": 1482,
              "key": "assets/test",
              "type": "custom",
              "value": null,
              "public_url": "//asset.ibanquan.com/asset/551a656e6387e4bb1a000001/test?rand=1427794434",
              "trash": true,
              "rename": true
          }
      }
      

DELETE /themes/#{id}/assets?asset[key]=

删除 Asset

    • 删除 Asset
    • DELETE /themes/1482/assets?asset[key]=layout/theme.123.html
    • {}
      
免费领取15天试用
立即注册
联系客服
微信咨询
微信二维码

领取免费试用资格

姓名 *

电话 *

公司名称

所在地区

意向产品

提交

提交成功

你好, XXX女士/先生 ,你的需求已提交成功,后续会有专门的客户经理与你电话联系。谢谢!