feat: 新增领域模型与仓库接口
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package com.placeholder.ringhealth.domain.model
|
||||
|
||||
/** 健康指标类型。路由与详情页以此区分。 */
|
||||
enum class MetricType {
|
||||
STEP,
|
||||
HEART_RATE,
|
||||
SLEEP,
|
||||
BLOOD_OXYGEN,
|
||||
STRESS,
|
||||
TEMPERATURE,
|
||||
BLOOD_PRESSURE,
|
||||
}
|
||||
|
||||
/** 历史数据的时间范围。 */
|
||||
enum class DateRange { WEEK, MONTH }
|
||||
|
||||
/**
|
||||
* 戒指设备状态。M2 接入蓝牙后由真实 SDK 填充,当前由 Mock 提供。
|
||||
*/
|
||||
data class RingDeviceState(
|
||||
val connected: Boolean,
|
||||
val name: String,
|
||||
val batteryPercent: Int,
|
||||
val firmwareVersion: String,
|
||||
val charging: Boolean,
|
||||
)
|
||||
|
||||
/**
|
||||
* 今日健康概览。字段为 null 表示该指标未开启或暂无数据,UI 需展示“未开启”占位而非 0。
|
||||
*/
|
||||
data class HealthSummary(
|
||||
val steps: Int,
|
||||
val stepGoal: Int,
|
||||
val calories: Int,
|
||||
val distanceKm: Double,
|
||||
val heartRate: Int?,
|
||||
val sleepMinutes: Int?,
|
||||
val bloodOxygen: Int?,
|
||||
val stress: Int?,
|
||||
val temperature: Double?,
|
||||
val bloodPressure: String?,
|
||||
)
|
||||
|
||||
/** 一条历史数据点。 */
|
||||
data class MetricPoint(val timestamp: Long, val value: Double)
|
||||
|
||||
/** 一条运动记录。 */
|
||||
data class WorkoutRecord(
|
||||
val id: String,
|
||||
val type: String,
|
||||
val startTime: Long,
|
||||
val durationMinutes: Int,
|
||||
val distanceKm: Double,
|
||||
val calories: Int,
|
||||
)
|
||||
|
||||
/** 戒指功能开关项(对应协议中的自动监测开关)。 */
|
||||
data class DeviceFunctionSetting(
|
||||
val id: String,
|
||||
val title: String,
|
||||
val subtitle: String,
|
||||
val enabled: Boolean,
|
||||
)
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.placeholder.ringhealth.domain.repository
|
||||
|
||||
import com.placeholder.ringhealth.domain.model.DateRange
|
||||
import com.placeholder.ringhealth.domain.model.DeviceFunctionSetting
|
||||
import com.placeholder.ringhealth.domain.model.HealthSummary
|
||||
import com.placeholder.ringhealth.domain.model.MetricPoint
|
||||
import com.placeholder.ringhealth.domain.model.MetricType
|
||||
import com.placeholder.ringhealth.domain.model.RingDeviceState
|
||||
import com.placeholder.ringhealth.domain.model.WorkoutRecord
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
/**
|
||||
* 健康数据来源。M1 由 Mock 实现,M2/M3 由厂商 SDK 适配层实现,UI 无需改动。
|
||||
*/
|
||||
interface HealthDataRepository {
|
||||
/** 今日概览,随数据变化持续发射。 */
|
||||
fun observeTodaySummary(): Flow<HealthSummary>
|
||||
|
||||
/** 指定指标在指定时间范围内的历史数据。 */
|
||||
fun observeMetricHistory(metric: MetricType, range: DateRange): Flow<List<MetricPoint>>
|
||||
|
||||
/** 运动记录列表。 */
|
||||
fun observeWorkouts(): Flow<List<WorkoutRecord>>
|
||||
}
|
||||
|
||||
/**
|
||||
* 戒指设备状态与功能开关。M2 接入蓝牙后由真实实现替换。
|
||||
*/
|
||||
interface RingDeviceRepository {
|
||||
/** 设备状态(连接/电量/固件)。 */
|
||||
val deviceState: StateFlow<RingDeviceState>
|
||||
|
||||
/** 功能开关列表。 */
|
||||
val functionSettings: StateFlow<List<DeviceFunctionSetting>>
|
||||
|
||||
/** 主动刷新设备状态。 */
|
||||
suspend fun refreshDeviceState()
|
||||
|
||||
/** 切换某个功能开关(M1 仅改内存状态)。 */
|
||||
fun setFunctionEnabled(id: String, enabled: Boolean)
|
||||
}
|
||||
Reference in New Issue
Block a user