阶段报告API文档

本文档描述了如何使用阶段报告API获取会员的阶段训练报告数据。

API概述

阶段报告API提供了获取会员阶段训练报告的功能,包括基本信息、身体数据、体成分趋势、围度趋势、体型变化照片和阶段总结等内容。

接口详情

获取阶段报告数据

GET /gym/member/stage_summery

获取指定阶段的报告数据,包括会员基本信息、身体数据、体成分趋势、围度趋势、体型变化照片和阶段总结等内容。

请求参数

参数名 类型 必填 描述
stage_id Integer 阶段ID

响应格式

API返回JSON格式的数据,包含以下字段:

{
    "error": 0,                      // 错误码,0表示成功,非0表示失败
    "message": "",                   // 错误信息,仅在error非0时有值
    "basic_info": {                  // 基本信息
        "member_name": "张三",        // 会员姓名
        "trainer_name": "刘尚武",     // 教练姓名
        "gym_location": "玻曼健身四川北路店", // 健身房地址
        "report_date": "2024-04-10", // 报告日期
        "stage_name": "快速减脂阶段",   // 阶段名称
        "start_date": "2024-01-01",  // 开始日期
        "end_date": "2024-03-31"     // 结束日期
    },
    "body_data": {                   // 身体数据
        "weight": {                  // 体重
            "current": 70.2,         // 当前值
            "initial": 78.6,         // 初始值
            "diff": -8.4             // 变化值
        },
        "body_fat_percentage": {     // 体脂率
            "current": 21.5,         // 当前值
            "initial": 28.1,         // 初始值
            "diff": -6.6             // 变化值
        },
        "skeletal_muscle": {         // 骨骼肌
            "current": 29.8,         // 当前值
            "initial": 27.2,         // 初始值
            "diff": 2.6              // 变化值
        },
        "body_fat_mass": {           // 体脂肪
            "current": 20.2,         // 当前值
            "initial": 27.3,         // 初始值
            "diff": -7.1             // 变化值
        },
        "basal_metabolism": {        // 基础代谢
            "current": 1620,         // 当前值
            "initial": 1495,         // 初始值
            "diff": 125              // 变化值
        },
        "chest_circumference": {     // 胸围
            "current": 24.8,         // 当前值
            "initial": 23.2,         // 初始值
            "diff": 1.6              // 变化值
        },
        "waist_circumference": {     // 腰围
            "current": 17.5,         // 当前值
            "initial": 18.8,         // 初始值
            "diff": -1.3             // 变化值
        },
        "hip_circumference": {       // 臀围
            "current": 21.5,         // 当前值
            "initial": 21.3,         // 初始值
            "diff": 0.2              // 变化值
        },
        "hip_circumference_left": {  // 左臀围
            "current": 7.5,          // 当前值
            "initial": 7.2,          // 初始值
            "diff": 0.3              // 变化值
        },
        "hip_circumference_right": { // 右臀围
            "current": 7.5,          // 当前值
            "initial": 7.2,          // 初始值
            "diff": 0.3              // 变化值
        },
        "thigh_circumference_left": { // 左腿围
            "current": 9.2,          // 当前值
            "initial": 10.5,         // 初始值
            "diff": -1.3             // 变化值
        },
        "thigh_circumference_right": { // 右腿围
            "current": 9.2,          // 当前值
            "initial": 10.6,         // 初始值
            "diff": -1.4             // 变化值
        }
    },
    "body_composition_trend": [      // 体成分趋势
        {
            "month": "第1月",         // 月份
            "weight": 78.6,          // 体重
            "body_fat_percentage": 27.3, // 体脂率
            "skeletal_muscle": 27.2, // 骨骼肌
            "body_fat_mass": 27.3,   // 体脂肪
            "basal_metabolism": 1500 // 基础代谢
        },
        {
            "month": "第2月",
            "weight": 77.3,
            "body_fat_percentage": 26.5,
            "skeletal_muscle": 27.6,
            "body_fat_mass": 26.5,
            "basal_metabolism": 1511
        },
        {
            "month": "第3月",
            "weight": 77.1,
            "body_fat_percentage": 26.2,
            "skeletal_muscle": 28.0,
            "body_fat_mass": 26.2,
            "basal_metabolism": 1513
        }
    ],
    "circumference_trend": [         // 围度趋势
        {
            "month": "第1月",         // 月份
            "waist_circumference": 18.6, // 腰围
            "hip_circumference_left": 7.3, // 左臀围
            "hip_circumference_right": 7.3, // 右臀围
            "thigh_circumference_left": 10.3, // 左腿围
            "thigh_circumference_right": 10.3, // 右腿围
            "chest_circumference": 20.3, // 胸围
            "hip_circumference": 19.3 // 臀围
        },
        {
            "month": "第2月",
            "waist_circumference": 17.3,
            "hip_circumference_left": 7.4,
            "hip_circumference_right": 7.4,
            "thigh_circumference_left": 10.4,
            "thigh_circumference_right": 10.4,
            "chest_circumference": 20.5,
            "hip_circumference": 19.5
        },
        {
            "month": "第3月",
            "waist_circumference": 17.1,
            "hip_circumference_left": 7.5,
            "hip_circumference_right": 7.5,
            "thigh_circumference_left": 10.5,
            "thigh_circumference_right": 10.5,
            "chest_circumference": 20.8,
            "hip_circumference": 19.6
        }
    ],
    "photos": {                      // 照片数据
        "first": {                   // 初始照片
            "front": "base64编码的图片数据", // 正面照
            "side": "base64编码的图片数据",  // 侧面照
            "back": "base64编码的图片数据"   // 背面照
        },
        "last": {                    // 最新照片
            "front": "base64编码的图片数据", // 正面照
            "side": "base64编码的图片数据",  // 侧面照
            "back": "base64编码的图片数据"   // 背面照
        }
    },
    "summary": "1、体脂肪改善明显,体脂率得到明显的降低;\n2、体重降低明显;\n3、身体围度变化不明显,后面可通过加强力量训练来改善。", // 阶段总结
    "assessment": {                  // 最新评估记录的详细信息
        "id": 123,                   // 评估记录ID
        "assessment_date": "2024-03-15", // 评估日期
        
        // 体成分测试数据
        "weight": 70.2,              // 体重
        "body_fat_percentage": 21.5, // 体脂率
        "skeletal_muscle": 29.8,     // 骨骼肌
        "body_fat_mass": 20.2,       // 体脂肪
        "basal_metabolism": 1620,    // 基础代谢
        
        // 围度测量数据
        "waist_circumference": 17.5, // 腰围
        "hip_circumference_left": 7.5, // 左臀围
        "hip_circumference_right": 7.5, // 右臀围
        "thigh_circumference_left": 9.2, // 左腿围
        "thigh_circumference_right": 9.2, // 右腿围
        "chest_circumference": 24.8, // 胸围
        "hip_circumference": 21.5,   // 臀围
        
        // 上次评估数据
        "previous_weight": 78.6,     // 上次体重
        "previous_body_fat_percentage": 28.1, // 上次体脂率
        "previous_skeletal_muscle": 27.2, // 上次骨骼肌
        "previous_body_fat_mass": 27.3, // 上次体脂肪
        "previous_basal_metabolism": 1495, // 上次基础代谢
        "previous_waist_circumference": 18.8, // 上次腰围
        "previous_hip_circumference_left": 7.2, // 上次左臀围
        "previous_hip_circumference_right": 7.2, // 上次右臀围
        "previous_thigh_circumference_left": 10.5, // 上次左腿围
        "previous_thigh_circumference_right": 10.6, // 上次右腿围
        "previous_chest_circumference": 23.2, // 上次胸围
        "previous_hip_circumference": 21.3, // 上次臀围
        
        // 照片数据
        "front_photo": "base64编码的图片数据", // 正面照
        "side_photo": "base64编码的图片数据",  // 侧面照
        "back_photo": "base64编码的图片数据",   // 背面照
        "previous_front_photo": "base64编码的图片数据", // 上次正面照
        "previous_side_photo": "base64编码的图片数据",  // 上次侧面照
        "previous_back_photo": "base64编码的图片数据"   // 上次背面照
    }
}

错误码说明

错误码 描述
0 成功
1 失败,具体原因见message字段

示例请求

GET /gym/member/stage_summery?stage_id=123

使用示例

JavaScript示例

// 使用fetch API获取阶段报告数据
fetch('/gym/member/stage_summery?stage_id=123')
    .then(response => response.json())
    .then(data => {
        if (data.error === 0) {
            // 处理成功响应
            console.log('会员姓名:', data.basic_info.member_name);
            console.log('当前体重:', data.body_data.weight.current);
            console.log('体重变化:', data.body_data.weight.diff);
            // 处理其他数据...
        } else {
            // 处理错误
            console.error('获取数据失败:', data.message);
        }
    })
    .catch(error => {
        console.error('请求出错:', error);
    });

Python示例

import requests
import json

# 发送请求获取阶段报告数据
response = requests.get('http://your-domain.com/gym/member/stage_summery', params={'stage_id': 123})

# 解析响应
if response.status_code == 200:
    data = response.json()
    if data['error'] == 0:
        # 处理成功响应
        print(f"会员姓名: {data['basic_info']['member_name']}")
        print(f"当前体重: {data['body_data']['weight']['current']}")
        print(f"体重变化: {data['body_data']['weight']['diff']}")
        # 处理其他数据...
    else:
        # 处理错误
        print(f"获取数据失败: {data['message']}")
else:
    print(f"请求失败,状态码: {response.status_code}")