feat(parent,auth,onboarding,files,notifications,adaptive-practice,ai): add module updates
parent: - Add parent-student-attendance-detail component auth: - Add actions, data-access, schema, services, types onboarding: - Add parent-children-form and hooks directory files: - Add actions, schema, hooks directory notifications: - Add schema and schema test adaptive-practice: - Add answer-input, answer-result, practice-result-view, practice-starter-with-nav - Add question-card, question-content, lib and services directories ai: - Add context/create-ai-client-service, hooks/use-drag-position, hooks/use-position-persistence
This commit is contained in:
@@ -11,10 +11,10 @@ import {
|
||||
getStudentSchedule,
|
||||
} from "@/modules/classes/data-access"
|
||||
import {
|
||||
getStudentDashboardGrades,
|
||||
getStudentHomeworkAssignments,
|
||||
getStudentExamResults,
|
||||
} from "@/modules/homework/data-access"
|
||||
} from "@/modules/homework/data-access-student"
|
||||
import { getStudentDashboardGrades } from "@/modules/homework/stats-service"
|
||||
import { getStudentGradeSummary } from "@/modules/grades/data-access"
|
||||
import { getGradeNameById } from "@/modules/school/data-access"
|
||||
import { getUserBasicInfo, getUserNamesByIds } from "@/modules/users/data-access"
|
||||
@@ -283,3 +283,22 @@ export const getParentIdsByStudentIds = cache(
|
||||
return Array.from(new Set(rows.map((r) => r.parentId)))
|
||||
},
|
||||
)
|
||||
|
||||
/**
|
||||
* L-2: 批量查询学生→家长映射(保留关联关系)。
|
||||
* 用于考勤通知等需要按家长-学生分组发送的场景,避免 N+1 查询。
|
||||
* 返回数组形如 [{ parentId, studentId }],同一家长多个学生会出现多条。
|
||||
*/
|
||||
export const getParentStudentMapByStudentIds = cache(
|
||||
async (studentIds: string[]): Promise<Array<{ parentId: string; studentId: string }>> => {
|
||||
if (studentIds.length === 0) return []
|
||||
const rows = await db
|
||||
.select({
|
||||
parentId: parentStudentRelations.parentId,
|
||||
studentId: parentStudentRelations.studentId,
|
||||
})
|
||||
.from(parentStudentRelations)
|
||||
.where(inArray(parentStudentRelations.studentId, studentIds))
|
||||
return rows.map((r) => ({ parentId: r.parentId, studentId: r.studentId }))
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user