فهرست منبع

提供公共设备时用户查看和修改自己个人信息

jiapu 2 ماه پیش
والد
کامیت
9e3ccf85df
1فایلهای تغییر یافته به همراه313 افزوده شده و 0 حذف شده
  1. 313 0
      code/app对接接口说明.md

+ 313 - 0
code/app对接接口说明.md

@@ -26,6 +26,8 @@
 | 11 | 新增群组成员 | `POST` | `/api/app/group/{groupId}/members` | 当前 APP 账号向指定家庭设备群组添加新成员(包含用户档案信息),需校验群组归属 |
 | 11 | 新增群组成员 | `POST` | `/api/app/group/{groupId}/members` | 当前 APP 账号向指定家庭设备群组添加新成员(包含用户档案信息),需校验群组归属 |
 | 12 | 修改群组成员 | `PUT` | `/api/app/group/{groupId}/members/{profileId}` | 当前 APP 账号修改指定群组下已有成员的用户档案信息,需校验群组归属 |
 | 12 | 修改群组成员 | `PUT` | `/api/app/group/{groupId}/members/{profileId}` | 当前 APP 账号修改指定群组下已有成员的用户档案信息,需校验群组归属 |
 | 13 | 删除群组成员 | `DELETE` | `/api/app/group/{groupId}/members/{profileId}` | 当前 APP 账号从指定家庭设备群组中移除成员(软删除),需校验群组归属且禁止删除自身 |
 | 13 | 删除群组成员 | `DELETE` | `/api/app/group/{groupId}/members/{profileId}` | 当前 APP 账号从指定家庭设备群组中移除成员(软删除),需校验群组归属且禁止删除自身 |
+| 14 | 查询当前账号个人资料 | `GET` | `/api/app/user/profile` | 通过 Token 获取当前 APP 账号对应的个人资料(昵称、头像、用户档案等),适用于家庭设备和公共设备 |
+| 15 | 修改当前账号个人资料 | `PUT` | `/api/app/user/profile` | 通过 Token 修改当前 APP 账号对应的个人资料,部分字段(昵称/头像)更新到 `app_user` 表,其余字段(体型、地址等)更新到 `user_profile` 表,适用于家庭设备和公共设备 |
 ## 3. 接口详情
 ## 3. 接口详情
 
 
 ### 3.1 查询用户背部产品穴位坐标列表
 ### 3.1 查询用户背部产品穴位坐标列表
@@ -1573,4 +1575,315 @@ curl -X DELETE "http://localhost:18888/api/app/group/2001/members/124" \
 - 本接口不会级联删除用户的 `user_profile` 档案或 `user_device` 绑定记录;如需彻底清理用户档案,请使用其他档案管理接口。
 - 本接口不会级联删除用户的 `user_profile` 档案或 `user_device` 绑定记录;如需彻底清理用户档案,请使用其他档案管理接口。
 - 已删除的成员记录若需要重新加入群组,请使用"新增群组成员"接口(3.11 节)重新创建。
 - 已删除的成员记录若需要重新加入群组,请使用"新增群组成员"接口(3.11 节)重新创建。
 
 
+### 3.14 查询当前账号个人资料
+
+#### 3.14.1 接口用途
+
+用于 APP 端通过 Token 获取当前登录 APP 账号对应的个人资料。
+
+后端从 Token 中解析当前账号 ID,若该账号下尚无用户档案,会自动创建一份空档案(`app_user_id = 当前账号ID`),并将该账号昵称、手机号写入档案,保证 APP 端"我的资料"页面始终有数据可展示。
+
+本接口**不区分家庭设备和公共设备**,所有登录后的 APP 账号均可调用。
+
+#### 3.14.2 请求信息
+
+- 请求方式:`GET`
+- URI:`/api/app/user/profile`
+- 完整示例:`http://localhost:18888/api/app/user/profile`
+
+#### 3.14.3 请求参数
+
+无路径参数、无查询参数、无请求体。请求头需携带登录后的 Token。
+
+#### 3.14.4 调用示例
+
+```http
+GET /api/app/user/profile HTTP/1.1
+Host: localhost:18888
+Authorization: Bearer <token>
+```
+
+```bash
+curl -X GET "http://localhost:18888/api/app/user/profile" \
+  -H "Authorization: Bearer <token>"
+```
+
+#### 3.14.5 返回示例
+
+```json
+{
+  "code": 200,
+  "message": "操作成功",
+  "data": {
+    "userId": 17320687382,
+    "appUserId": 17320687382,
+    "profileId": 123,
+    "id": 123,
+    "nickname": "张三",
+    "avatar": "https://cdn.example.com/avatar/17320687382.png",
+    "appId": "AJY00000001",
+    "accountPhone": "13800138000",
+    "phone": "13800138000",
+    "name": "张三",
+    "gender": 1,
+    "age": 35,
+    "provinceCode": "440000",
+    "cityCode": "440300",
+    "districtCode": "440305",
+    "address": "广东省深圳市南山区",
+    "shoulderWidth": 42.50,
+    "bodyHeight": 85.00,
+    "spineLength": 48.00,
+    "height": 175.00,
+    "weight": 70.00,
+    "fingerWidth1": 2.20,
+    "fingerWidth15": 3.20,
+    "fingerWidth3": 6.50,
+    "acupointTableId": 5001,
+    "userCategoryId": 1,
+    "profileComplete": true
+  }
+}
+```
+
+#### 3.14.6 字段说明
+
+| 字段名 | 类型 | 说明 |
+| --- | --- | --- |
+| `userId` | `number` | 当前 APP 账号 ID,对应 `app_user.id`(同 `appUserId`) |
+| `appUserId` | `number` | 当前 APP 账号 ID,对应 `app_user.id` |
+| `profileId` | `number` | 用户档案 ID,对应 `user_profile.id`(同 `id`) |
+| `id` | `number` | 用户档案 ID,对应 `user_profile.id` |
+| `nickname` | `string` | APP 账号昵称,对应 `app_user.nickname` |
+| `avatar` | `string` | APP 账号头像 URL,对应 `app_user.avatar` |
+| `appId` | `string` | APP 账号的 AppId,对应 `app_user.app_id` |
+| `accountPhone` | `string` | APP 账号手机号,对应 `app_user.phone` |
+| `phone` | `string` | 用户档案手机号,对应 `user_profile.phone`(与 `accountPhone` 通常一致) |
+| `name` | `string` | 姓名 |
+| `gender` | `number/null` | 性别:`1=男`,`2=女` |
+| `age` | `number/null` | 年龄 |
+| `provinceCode` | `string/null` | 省级行政区划编码 |
+| `cityCode` | `string/null` | 市级行政区划编码 |
+| `districtCode` | `string/null` | 区/县级行政区划编码 |
+| `address` | `string/null` | 详细地址 |
+| `shoulderWidth` | `number/null` | 肩宽(cm) |
+| `bodyHeight` | `number/null` | 身长/坐高(cm) |
+| `spineLength` | `number/null` | C7-S4 脊柱长度(cm) |
+| `height` | `number/null` | 身高(cm) |
+| `weight` | `number/null` | 体重(kg) |
+| `fingerWidth1` | `number/null` | 一寸指宽(cm),男 1.5~2.8,女 1.3~2.4 |
+| `fingerWidth15` | `number/null` | 1.5 寸指宽(cm),男 2.2~4.0,女 2.0~3.5 |
+| `fingerWidth3` | `number/null` | 三寸指宽(cm),男 4.5~8.0,女 4.0~7.0 |
+| `acupointTableId` | `number/null` | 已生成的穴位对照表 ID,对应 `user_acupoint.id` |
+| `userCategoryId` | `number/null` | 用户分类 ID,对应 `user_category.id` |
+| `profileComplete` | `boolean` | 用户档案是否已补全设备使用所需资料(`name`/`gender`/`age`/`shoulderWidth`/`bodyHeight`/`spineLength` 均已填写) |
+
+#### 3.14.7 失败返回示例
+
+未登录或 Token 无效:
+
+```json
+{
+  "code": 401,
+  "message": "请先登录",
+  "data": null
+}
+```
+
+APP 账号不存在或已禁用:
+
+```json
+{
+  "code": 1302,
+  "message": "APP账号不存在",
+  "data": null
+}
+```
+
+#### 3.14.8 备注
+
+- 本接口不接受任何参数,仅通过 Token 识别当前账号;不允许通过 `userId`、`appUserId`、`profileId` 等参数指定他人档案。
+- 若当前账号下无用户档案(`user_profile`),后端会自动创建一份以 `app_user_id` 关联的空档案,保证返回数据完整。
+- 响应中 `profileId` 与 `id` 内容一致,便于前端按不同字段名取值。
+- 该接口与"修改个人资料"(3.15 节)配套使用,修改后建议重新调用本接口刷新页面数据。
+
+### 3.15 修改当前账号个人资料
+
+#### 3.15.1 接口用途
+
+用于 APP 端通过 Token 修改当前登录 APP 账号对应的个人资料。
+
+后端逻辑:
+- `nickname`、`avatar` 字段会更新到 `app_user` 表
+- 其余字段(`name`、`gender`、`age`、`phone`、省市区/地址、肩宽、身长、脊柱长、身高、体重、指宽等)会更新到当前账号对应的 `user_profile` 表
+- 若当前账号下尚无用户档案,后端会自动创建一份
+- 修改后若档案已补全(`name`/`gender`/`age`/`shoulderWidth`/`bodyHeight`/`spineLength` 均已填写),会自动重新生成穴位对照表
+
+本接口**不区分家庭设备和公共设备**,所有登录后的 APP 账号均可调用,是用户在公共设备场景下修改自己资料的主入口。
+
+#### 3.15.2 请求信息
+
+- 请求方式:`PUT`
+- URI:`/api/app/user/profile`
+- 完整示例:`http://localhost:18888/api/app/user/profile`
+
+#### 3.15.3 请求参数
+
+请求体格式:`application/json`
+
+| 参数名 | 类型 | 是否必填 | 说明 | 示例 |
+| --- | --- | --- | --- | --- |
+| `nickname` | `string` | 否 | APP 账号昵称,传空字符串视为不更新 | `张三` |
+| `avatar` | `string` | 否 | APP 账号头像 URL,传空字符串视为不更新 | `https://cdn.example.com/avatar/xxx.png` |
+| `name` | `string` | 否 | 姓名,传空字符串视为不更新 | `张三` |
+| `gender` | `number` | 否 | 性别:`1=男`,`2=女` | `1` |
+| `age` | `number` | 否 | 年龄 | `35` |
+| `phone` | `string` | 否 | 手机号(11 位,1[3-9] 开头),传空字符串视为不更新 | `13800138000` |
+| `userCategoryId` | `number` | 否 | 用户分类 ID,对应 `user_category.id` | `1` |
+| `provinceCode` | `string/null` | 否 | 省级行政区划编码 | `440000` |
+| `cityCode` | `string/null` | 否 | 市级行政区划编码 | `440300` |
+| `districtCode` | `string/null` | 否 | 区/县级行政区划编码 | `440305` |
+| `address` | `string/null` | 否 | 详细地址 | `广东省深圳市南山区` |
+| `shoulderWidth` | `number/null` | 否 | 肩宽(cm) | `42.50` |
+| `bodyHeight` | `number/null` | 否 | 身长/坐高(cm) | `85.00` |
+| `spineLength` | `number/null` | 否 | C7-S4 脊柱长度(cm) | `48.00` |
+| `height` | `number/null` | 否 | 身高(cm) | `175.00` |
+| `weight` | `number/null` | 否 | 体重(kg) | `70.00` |
+| `fingerWidth1` | `number/null` | 否 | 一寸指宽(cm),男 1.5~2.8,女 1.3~2.4 | `2.20` |
+| `fingerWidth15` | `number/null` | 否 | 1.5 寸指宽(cm),男 2.2~4.0,女 2.0~3.5 | `3.20` |
+| `fingerWidth3` | `number/null` | 否 | 三寸指宽(cm),男 4.5~8.0,女 4.0~7.0 | `6.50` |
+| `acupointTableId` | `number/null` | 否 | 已存在的穴位对照表 ID,一般由后端自动生成,无需传入 | `null` |
+
+#### 3.15.4 调用示例
+
+```http
+PUT /api/app/user/profile HTTP/1.1
+Host: localhost:18888
+Authorization: Bearer <token>
+Content-Type: application/json
+
+{
+  "nickname": "张三",
+  "avatar": "https://cdn.example.com/avatar/17320687382.png",
+  "name": "张三",
+  "gender": 1,
+  "age": 35,
+  "phone": "13800138000",
+  "provinceCode": "440000",
+  "cityCode": "440300",
+  "districtCode": "440305",
+  "address": "广东省深圳市南山区",
+  "shoulderWidth": 42.50,
+  "bodyHeight": 85.00,
+  "spineLength": 48.00,
+  "height": 175.00,
+  "weight": 70.00,
+  "fingerWidth1": 2.20,
+  "fingerWidth15": 3.20,
+  "fingerWidth3": 6.50
+}
+```
+
+```bash
+curl -X PUT "http://localhost:18888/api/app/user/profile" \
+  -H "Authorization: Bearer <token>" \
+  -H "Content-Type: application/json" \
+  -d '{"nickname":"张三","avatar":"https://cdn.example.com/avatar/17320687382.png","name":"张三","gender":1,"age":35,"phone":"13800138000","shoulderWidth":42.50,"bodyHeight":85.00,"spineLength":48.00,"height":175.00,"weight":70.00,"fingerWidth1":2.20,"fingerWidth15":3.20,"fingerWidth3":6.50}'
+```
+
+#### 3.15.5 返回示例
+
+```json
+{
+  "code": 200,
+  "message": "操作成功",
+  "data": {
+    "userId": 17320687382,
+    "appUserId": 17320687382,
+    "profileId": 123,
+    "id": 123,
+    "nickname": "张三",
+    "avatar": "https://cdn.example.com/avatar/17320687382.png",
+    "appId": "AJY00000001",
+    "accountPhone": "13800138000",
+    "phone": "13800138000",
+    "name": "张三",
+    "gender": 1,
+    "age": 35,
+    "provinceCode": "440000",
+    "cityCode": "440300",
+    "districtCode": "440305",
+    "address": "广东省深圳市南山区",
+    "shoulderWidth": 42.50,
+    "bodyHeight": 85.00,
+    "spineLength": 48.00,
+    "height": 175.00,
+    "weight": 70.00,
+    "fingerWidth1": 2.20,
+    "fingerWidth15": 3.20,
+    "fingerWidth3": 6.50,
+    "acupointTableId": 5001,
+    "userCategoryId": 1,
+    "profileComplete": true
+  }
+}
+```
+
+#### 3.15.6 失败返回示例
+
+未登录或 Token 无效:
+
+```json
+{
+  "code": 401,
+  "message": "请先登录",
+  "data": null
+}
+```
+
+APP 账号不存在或已禁用:
+
+```json
+{
+  "code": 1302,
+  "message": "APP账号不存在",
+  "data": null
+}
+```
+
+手机号格式不正确:
+
+```json
+{
+  "code": 1108,
+  "message": "手机号格式不正确",
+  "data": null
+}
+```
+
+指宽数据超出性别对应范围:
+
+```json
+{
+  "code": 1203,
+  "message": "1.5寸指宽应在 2.2~4.0 cm 之间",
+  "data": null
+}
+```
+
+#### 3.15.7 备注
+
+- 本接口不接受路径参数与查询参数,仅通过 Token 识别当前账号;不允许通过 `userId`/`appUserId`/`profileId` 等参数修改他人档案。
+- 该接口与"修改群组成员"(3.12 节)的区别:
+  - 3.12 节需要 `groupId` + `profileId`,**仅服务家庭设备群组**,用于在群组维度编辑成员资料;
+  - 3.15 节只需要 Token,**同时适用于家庭设备和公共设备**,用于当前账号修改自己的资料;
+  - 公共设备场景下**不能**调用 3.12 节(无 `groupId`),应改用本接口。
+- 字段更新语义:
+  - `nickname` / `avatar`:仅在传入非空字符串时更新到 `app_user` 表;
+  - 其余字段:仅在传入非 `null` 时更新到 `user_profile` 表(`phone` 还会进行手机号格式校验)。
+- 当修改后档案完整时(`name`/`gender`/`age`/`shoulderWidth`/`bodyHeight`/`spineLength` 均已填写),后端会自动重新生成穴位对照表。
+- 不会影响 `device_group` 或 `user_device` 绑定关系,仅修改账号与档案自身数据。
+- 与"查询个人资料"(3.14 节)配套使用,修改成功后可直接复用返回结果刷新页面。
+
+