diff --git a/README.md b/README.md index 0d60a7d..0d52cd4 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,19 @@ 提供webp生成服务 +```javascript +// GET /webp/{type}-{id}-{version}-{width}-{height}-{fit}.{format} +// @type: image avatar article article_attribute ad +// @id: int 图片ID或是文章ID或是广告ID +// @version: update_time 时间戳 +// @width: 宽度 1x 2x 3x 倍图直接输入尺寸 +// @height: 高度 1x 2x 3x 倍图直接输入尺寸 +// @fit: 裁切方式 cover contain fill auto + +// GET /img/{type}-{id}.{format}?width=320&height=320&fit=cover +// 更优雅的实现, 使用查询参数的接口 (不幸的是CDN与OSS都不支持) +``` + ## Update diff --git a/models/mysql.go b/models/mysql.go index 4088f0f..fa05841 100644 --- a/models/mysql.go +++ b/models/mysql.go @@ -39,7 +39,7 @@ func (m *MysqlConnection) GetImageContent(group string, id string) (content stri err = m.db.QueryRow("SELECT image FROM web_article_attribute WHERE id=" + id).Scan(&content) case "ad": err = m.db.QueryRow("SELECT image FROM web_ad WHERE id=" + id).Scan(&content) - case "user": + case "avatar": err = m.db.QueryRow("SELECT avatar FROM web_member WHERE id=" + id).Scan(&content) case "image": err = m.db.QueryRow("SELECT content FROM web_images WHERE id=" + id).Scan(&content)