feat: 支持先绑定设备后关联儿童档案
- 绑定模型新增 owner_user_id,支持 child_id 为空\n- 新增绑定后设置儿童接口 /bindings/{device_id}/child\n- 前端绑定页改为先绑设备后补充儿童\n- 补充数据库迁移脚本与 DAO 测试用例
This commit is contained in:
@@ -2,7 +2,7 @@ import { request } from './api'
|
||||
|
||||
export interface Binding {
|
||||
device_id: string
|
||||
child_id: number
|
||||
child_id: number | null
|
||||
status: number
|
||||
bound_at: string
|
||||
}
|
||||
@@ -14,7 +14,7 @@ export interface BindStartResponse {
|
||||
|
||||
export interface BindHistoryItem {
|
||||
device_id: string
|
||||
child_id: number
|
||||
child_id: number | null
|
||||
bound_at: string
|
||||
unbound_at?: string
|
||||
}
|
||||
@@ -40,7 +40,7 @@ export async function getCurrentBinding(): Promise<Binding | null> {
|
||||
// 开始绑定设备
|
||||
export async function startBind(data: {
|
||||
device_id: string
|
||||
child_id: number
|
||||
child_id?: number
|
||||
}): Promise<BindStartResponse> {
|
||||
return request<BindStartResponse>('/bindings/start', {
|
||||
method: 'POST',
|
||||
@@ -52,7 +52,7 @@ export async function startBind(data: {
|
||||
export async function confirmBind(data: {
|
||||
bind_token: string
|
||||
challenge_code: string
|
||||
}): Promise<{ device_id: string; child_id: number }> {
|
||||
}): Promise<{ device_id: string; child_id: number | null }> {
|
||||
return request('/bindings/confirm', {
|
||||
method: 'POST',
|
||||
data,
|
||||
@@ -83,14 +83,25 @@ export async function unbindDevice(deviceId: string): Promise<void> {
|
||||
// 直接绑定设备(手动输入设备码)
|
||||
export async function directBind(data: {
|
||||
device_id: string
|
||||
child_id: number
|
||||
}): Promise<{ device_id: string; child_id: number }> {
|
||||
child_id?: number
|
||||
}): Promise<{ device_id: string; child_id: number | null }> {
|
||||
return request('/bindings/direct', {
|
||||
method: 'POST',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
// Bind child profile after device has been bound to parent account.
|
||||
export async function setBindingChild(
|
||||
deviceId: string,
|
||||
data: { child_id: number }
|
||||
): Promise<{ device_id: string; child_id: number | null }> {
|
||||
return request(`/bindings/${deviceId}/child`, {
|
||||
method: 'PATCH',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
// 获取绑定历史
|
||||
export async function getBindHistory(
|
||||
deviceId: string,
|
||||
@@ -102,4 +113,4 @@ export async function getBindHistory(
|
||||
params.append('limit', String(limit))
|
||||
|
||||
return request<BindHistoryResponse>(`/bindings/history/${deviceId}?${params.toString()}`)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user