耳机阻抗上报
This commit is contained in:
@@ -464,6 +464,69 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/audio/reportImpedance": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Device"
|
||||
],
|
||||
"summary": "上报耳机阻抗",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "设备 MAC 地址",
|
||||
"name": "mac",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "设备型号",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "耳机品牌",
|
||||
"name": "brand",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "耳机型号",
|
||||
"name": "model",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "阻抗值(整数)",
|
||||
"name": "value",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "操作成功",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/audio/shareAccept": {
|
||||
"get": {
|
||||
"description": "根据分享码获取他人分享的 EQ 数据",
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
# 用户上报耳机阻抗(最新值)需求文档
|
||||
|
||||
## 背景与目标
|
||||
|
||||
- 用户在设备上报其耳机阻抗值,用于后续业务使用(本需求仅覆盖**存储**与**去重更新**规则)。
|
||||
- 一个 **MAC 地址代表一个用户**。
|
||||
- 一个用户可以上报/维护多个耳机(以“耳机品牌 + 耳机型号”区分)。
|
||||
|
||||
## 核心字段
|
||||
|
||||
- 设备:`Luxsin-X8` / `Luxsin-X9`
|
||||
- 阻抗值:整数,单位 Ω
|
||||
- 耳机品牌:字符串
|
||||
- 耳机型号:字符串
|
||||
- 设备 MAC 地址:字符串(用户标识)
|
||||
- 设备 IP 地址:服务端获取(与 `reportDevInfo` 接口一致),落库保存**最新值**
|
||||
|
||||
## 去重与更新规则(关键)
|
||||
|
||||
- 唯一判定条件:`mac_addr + headphone_brand + headphone_model`
|
||||
- 品牌/型号的对比规则:对比前做 `trim`(去首尾空格)+ `lower`(忽略大小写)
|
||||
- 若命中同一条(按上述规则),则:
|
||||
- 更新最新 `impedance_ohm`
|
||||
- 覆盖更新 `device_model`
|
||||
- 覆盖更新 `ip_addr`
|
||||
- 更新 `update_at`
|
||||
- 不保留历史:同一条记录始终反映该用户该耳机的**最新阻抗值**
|
||||
|
||||
## 数据库设计
|
||||
|
||||
### 表
|
||||
|
||||
- 表名:`user_headphone_impedance`
|
||||
- 建表脚本:`sql/user_headphone_impedance.sql`
|
||||
|
||||
### 字段说明
|
||||
|
||||
- `mac_addr`:用户标识(设备 MAC)
|
||||
- `device_model`:设备型号(`Luxsin-X8/Luxsin-X9`)
|
||||
- `impedance_ohm`:阻抗整数(Ω)
|
||||
- `headphone_brand` / `headphone_model`:原始输入(用于展示/回显)
|
||||
- `headphone_brand_norm` / `headphone_model_norm`:归一化值(trim+lower,用于唯一索引与去重)
|
||||
- `ip_addr`:服务端获取的设备 IP(最新值)
|
||||
- `create_at` / `update_at`:创建/更新时间
|
||||
|
||||
### 索引
|
||||
|
||||
- 唯一索引:`uniq_mac_brand_model(mac_addr, headphone_brand_norm, headphone_model_norm)`
|
||||
- 辅助索引:`idx_mac(mac_addr)`、`idx_device_model(device_model)`
|
||||
|
||||
## 非目标(本期不做)
|
||||
|
||||
- 不做历史版本/上报流水表
|
||||
- 不做品牌/型号的字典化与关联(仅存字符串)
|
||||
- 不在文档中定义具体 API(仅描述存储需求与规则)
|
||||
|
||||
@@ -457,6 +457,69 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/audio/reportImpedance": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Device"
|
||||
],
|
||||
"summary": "上报耳机阻抗",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "设备 MAC 地址",
|
||||
"name": "mac",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "设备型号",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "耳机品牌",
|
||||
"name": "brand",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "耳机型号",
|
||||
"name": "model",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "阻抗值(整数)",
|
||||
"name": "value",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "操作成功",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/audio/shareAccept": {
|
||||
"get": {
|
||||
"description": "根据分享码获取他人分享的 EQ 数据",
|
||||
|
||||
@@ -303,6 +303,49 @@ paths:
|
||||
summary: 上报设备信息
|
||||
tags:
|
||||
- Device
|
||||
/audio/reportImpedance:
|
||||
get:
|
||||
parameters:
|
||||
- description: 设备 MAC 地址
|
||||
in: query
|
||||
name: mac
|
||||
required: true
|
||||
type: string
|
||||
- description: 设备型号
|
||||
in: query
|
||||
name: name
|
||||
required: true
|
||||
type: string
|
||||
- description: 耳机品牌
|
||||
in: query
|
||||
name: brand
|
||||
required: true
|
||||
type: string
|
||||
- description: 耳机型号
|
||||
in: query
|
||||
name: model
|
||||
required: true
|
||||
type: string
|
||||
- description: 阻抗值(整数)
|
||||
in: query
|
||||
name: value
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 操作成功
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
type: object
|
||||
summary: 上报耳机阻抗
|
||||
tags:
|
||||
- Device
|
||||
/audio/shareAccept:
|
||||
get:
|
||||
description: 根据分享码获取他人分享的 EQ 数据
|
||||
|
||||
Reference in New Issue
Block a user