b2aed2a6b5
- 新增 GET /audio/shareList?mac=xx 查询未过期分享码(纯 Redis,ZSET 索引)
- share:mac:{mac} 从 SET 改为 ZSET(score=expire_at),支持 ZREMRANGEBYSCORE 精确过期清理
- 空 ZSET 自动 DEL,避免 key 累积
- share:import:pending 增加 12h 兜底 TTL,防止 DB 不可用时内存泄漏
- 导入日志 field 改为 mac:code(去掉 nanotime),同 MAC+code 多次导入幂等去重
- MarkPersisted 保存/恢复 PTTL,防御性编程
- shareCreate 改为 POST + JSON body
- 全量 handler 补充 Swagger 注释,集成 swag 文档生成
- Makefile 使用 $(go env GOPATH)/bin/swag 解决 PATH 问题
613 lines
21 KiB
JSON
613 lines
21 KiB
JSON
{
|
||
"swagger": "2.0",
|
||
"info": {
|
||
"description": "耳机音频参数 EQ 后端服务",
|
||
"title": "App Audio API",
|
||
"contact": {
|
||
"name": "Luxsin"
|
||
},
|
||
"version": "1.0"
|
||
},
|
||
"basePath": "/",
|
||
"paths": {
|
||
"/api/v1/health": {
|
||
"get": {
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"System"
|
||
],
|
||
"summary": "健康检查",
|
||
"responses": {
|
||
"200": {
|
||
"description": "OK",
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/audio/getBrand": {
|
||
"get": {
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"Brand"
|
||
],
|
||
"summary": "获取品牌列表",
|
||
"parameters": [
|
||
{
|
||
"type": "string",
|
||
"description": "品牌名称(模糊匹配)",
|
||
"name": "brandName",
|
||
"in": "query"
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "是否返回 base64 编码响应",
|
||
"name": "base64Resp",
|
||
"in": "query"
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "OK",
|
||
"schema": {
|
||
"type": "array",
|
||
"items": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Internal Server Error",
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/audio/getCurve": {
|
||
"get": {
|
||
"description": "根据机型和目标曲线名称,计算并返回 parametric_eq 数据",
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"Curve"
|
||
],
|
||
"summary": "获取目标曲线参数化 EQ",
|
||
"parameters": [
|
||
{
|
||
"type": "string",
|
||
"description": "品牌名称",
|
||
"name": "brand",
|
||
"in": "query",
|
||
"required": true
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "型号名称",
|
||
"name": "name",
|
||
"in": "query",
|
||
"required": true
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "目标曲线名称",
|
||
"name": "target",
|
||
"in": "query",
|
||
"required": true
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "是否返回 base64 编码响应",
|
||
"name": "base64Resp",
|
||
"in": "query"
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "成功返回 parametric_eq 数据",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": true
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "参数校验失败",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": true
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Internal Server Error",
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/audio/getModel": {
|
||
"get": {
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"Model"
|
||
],
|
||
"summary": "获取型号列表",
|
||
"parameters": [
|
||
{
|
||
"type": "string",
|
||
"description": "品牌名称",
|
||
"name": "brandName",
|
||
"in": "query"
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "型号名称",
|
||
"name": "modelName",
|
||
"in": "query"
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "是否返回 base64 编码响应",
|
||
"name": "base64Resp",
|
||
"in": "query"
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "OK",
|
||
"schema": {
|
||
"type": "array",
|
||
"items": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Internal Server Error",
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/audio/getModelCSV": {
|
||
"get": {
|
||
"description": "从 S3 读取指定机型的测量 CSV 数据,返回 frequency 和 raw 数组",
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"Curve"
|
||
],
|
||
"summary": "获取耳机原始频响 CSV 数据",
|
||
"parameters": [
|
||
{
|
||
"type": "string",
|
||
"description": "品牌名称",
|
||
"name": "brand",
|
||
"in": "query",
|
||
"required": true
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "型号名称",
|
||
"name": "model",
|
||
"in": "query",
|
||
"required": true
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "耳机类型 (in-ear/over-ear)",
|
||
"name": "form",
|
||
"in": "query",
|
||
"required": true
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "是否返回 base64 编码响应",
|
||
"name": "base64Resp",
|
||
"in": "query"
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "成功返回 frequency 和 raw 数组",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": true
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "参数校验失败",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": true
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Internal Server Error",
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/audio/modelCurve": {
|
||
"get": {
|
||
"description": "返回指定机型的频响曲线数据(fr),固定使用 Harman over-ear 2018 target",
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"Curve"
|
||
],
|
||
"summary": "获取机型默认频响曲线",
|
||
"parameters": [
|
||
{
|
||
"type": "string",
|
||
"description": "品牌名称",
|
||
"name": "brand",
|
||
"in": "query",
|
||
"required": true
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "型号名称",
|
||
"name": "name",
|
||
"in": "query",
|
||
"required": true
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "是否返回 base64 编码响应",
|
||
"name": "base64Resp",
|
||
"in": "query"
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "成功返回 fr 数据",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": true
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "参数校验失败",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": true
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Internal Server Error",
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/audio/modelList": {
|
||
"get": {
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"Model"
|
||
],
|
||
"summary": "搜索型号列表(基于 Meilisearch)",
|
||
"parameters": [
|
||
{
|
||
"type": "string",
|
||
"description": "搜索关键词",
|
||
"name": "key",
|
||
"in": "query"
|
||
},
|
||
{
|
||
"type": "integer",
|
||
"description": "返回数量上限",
|
||
"name": "count",
|
||
"in": "query"
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "是否返回 base64 编码响应",
|
||
"name": "base64Resp",
|
||
"in": "query"
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "OK",
|
||
"schema": {
|
||
"type": "array",
|
||
"items": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Internal Server Error",
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/audio/ota": {
|
||
"get": {
|
||
"description": "根据设备型号和硬件版本查询最新 OTA 记录,支持黑名单过滤和定向升级逻辑",
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"OTA"
|
||
],
|
||
"summary": "获取 OTA 升级信息",
|
||
"parameters": [
|
||
{
|
||
"type": "string",
|
||
"description": "设备型号",
|
||
"name": "model",
|
||
"in": "query",
|
||
"required": true
|
||
},
|
||
{
|
||
"type": "integer",
|
||
"description": "硬件版本",
|
||
"name": "hw",
|
||
"in": "query",
|
||
"required": true
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "设备 MAC 地址",
|
||
"name": "mac",
|
||
"in": "query"
|
||
},
|
||
{
|
||
"type": "integer",
|
||
"description": "是否 beta 通道 (0=否,1=是)",
|
||
"name": "beta",
|
||
"in": "query"
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "成功返回 OTA 信息",
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "Bad Request",
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Internal Server Error",
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/audio/reportDevInfo": {
|
||
"get": {
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"Device"
|
||
],
|
||
"summary": "上报设备信息",
|
||
"parameters": [
|
||
{
|
||
"type": "string",
|
||
"description": "设备 MAC 地址",
|
||
"name": "mac",
|
||
"in": "query",
|
||
"required": true
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "设备型号",
|
||
"name": "model",
|
||
"in": "query",
|
||
"required": true
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "固件版本号",
|
||
"name": "ver",
|
||
"in": "query"
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "操作成功",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": true
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Internal Server Error",
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/audio/shareAccept": {
|
||
"get": {
|
||
"description": "根据分享码获取他人分享的 EQ 数据",
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"ShareCode"
|
||
],
|
||
"summary": "导入 EQ 分享码",
|
||
"parameters": [
|
||
{
|
||
"type": "string",
|
||
"description": "设备 MAC 地址",
|
||
"name": "mac",
|
||
"in": "query",
|
||
"required": true
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "5 位分享码",
|
||
"name": "shareCode",
|
||
"in": "query",
|
||
"required": true
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "成功返回 eq_data",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": true
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "参数校验失败",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": true
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "系统错误",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": true
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/audio/shareCreate": {
|
||
"post": {
|
||
"description": "将用户的 EQ 数据生成一个 5 位分享码,有效期 30 分钟",
|
||
"consumes": [
|
||
"application/json"
|
||
],
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"ShareCode"
|
||
],
|
||
"summary": "创建 EQ 分享码",
|
||
"parameters": [
|
||
{
|
||
"description": "分享请求",
|
||
"name": "body",
|
||
"in": "body",
|
||
"required": true,
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"eq_data": {
|
||
"type": "object"
|
||
},
|
||
"mac": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "成功返回 share_code、expire_at、eq_data",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": true
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "参数校验失败",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": true
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "系统错误",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": true
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/audio/shareList": {
|
||
"get": {
|
||
"description": "根据设备 MAC 地址查询该设备尚未过期的所有分享码(仅查询 Redis,依赖 TTL 自动过期)",
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"ShareCode"
|
||
],
|
||
"summary": "查询未过期分享码",
|
||
"parameters": [
|
||
{
|
||
"type": "string",
|
||
"description": "设备 MAC 地址",
|
||
"name": "mac",
|
||
"in": "query",
|
||
"required": true
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "成功返回 share_codes 列表",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": true
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "参数校验失败",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": true
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "系统错误",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": true
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} |