kindergarten_java/reading-platform-frontend/src/api/parent.ts

153 lines
3.6 KiB
TypeScript
Raw Normal View History

import { http } from './index';
// ==================== 类型定义 ====================
export interface ChildInfo {
id: number;
name: string;
gender?: string;
birthDate?: string;
relationship: string;
class: {
id: number;
name: string;
grade: string;
};
readingCount: number;
lessonCount: number;
}
export interface ChildProfile extends ChildInfo {
stats: {
lessonRecords: number;
growthRecords: number;
taskCompletions: number;
};
}
export interface LessonRecord {
id: number;
lesson: {
id: number;
startDatetime: string;
endDatetime?: string;
actualDuration?: number;
course: {
id: number;
name: string;
pictureBookName?: string;
};
};
focus?: number;
participation?: number;
interest?: number;
understanding?: number;
notes?: string;
createdAt: string;
}
export interface TaskWithCompletion {
id: number;
status: string;
completedAt?: string;
feedback?: string;
parentFeedback?: string;
task: {
id: number;
title: string;
description?: string;
taskType: string;
startDate: string;
endDate: string;
course?: {
id: number;
name: string;
};
};
}
export interface GrowthRecord {
id: number;
title: string;
content?: string;
images: string[];
recordDate: string;
recordType: string;
class?: {
id: number;
name: string;
};
createdAt: string;
}
export interface Notification {
id: number;
title: string;
content: string;
notificationType: string;
isRead: boolean;
readAt?: string;
createdAt: string;
}
// ==================== 孩子信息 API ====================
export const getChildren = (): Promise<ChildInfo[]> =>
http.get('/parent/children');
export const getChildProfile = (childId: number): Promise<ChildProfile> =>
http.get(`/parent/children/${childId}`);
// ==================== 阅读记录 API ====================
export const getChildLessons = (
childId: number,
params?: { page?: number; pageSize?: number }
): Promise<{ items: LessonRecord[]; total: number; page: number; pageSize: number }> =>
http.get(`/parent/children/${childId}/lessons`, { params });
// ==================== 任务 API ====================
export const getChildTasks = (
childId: number,
params?: { page?: number; pageSize?: number; status?: string }
): Promise<{ items: TaskWithCompletion[]; total: number; page: number; pageSize: number }> =>
http.get(`/parent/children/${childId}/tasks`, { params });
export const submitTaskFeedback = (
childId: number,
taskId: number,
feedback: string
): Promise<any> =>
http.put(`/parent/children/${childId}/tasks/${taskId}/feedback`, { feedback });
// ==================== 成长档案 API ====================
export const getChildGrowthRecords = (
childId: number,
params?: { page?: number; pageSize?: number }
): Promise<{ items: GrowthRecord[]; total: number; page: number; pageSize: number }> =>
http.get(`/parent/children/${childId}/growth-records`, { params });
// ==================== 通知 API ====================
export const getNotifications = (
params?: { page?: number; pageSize?: number; isRead?: boolean; notificationType?: string }
): Promise<{
items: Notification[];
total: number;
unreadCount: number;
page: number;
pageSize: number;
}> =>
http.get('/parent/notifications', { params });
export const getUnreadCount = (): Promise<number> =>
http.get('/parent/notifications/unread-count');
export const markNotificationAsRead = (id: number): Promise<any> =>
http.put(`/parent/notifications/${id}/read`);
export const markAllNotificationsAsRead = (): Promise<any> =>
http.put('/parent/notifications/read-all');