feat: 实现成长路径功能
All checks were successful
continuous-integration/drone/push Build is passing

- 新增数据库表: growth_path_nodes, user_growth_path_progress, user_node_completions
- 新增 Model: GrowthPathNode, UserGrowthPathProgress, UserNodeCompletion
- 新增 Service: GrowthPathService(管理端CRUD、学员端进度追踪)
- 新增 API: 学员端获取成长路径、管理端CRUD
- 前端学员端从API动态加载成长路径数据
- 更新管理端API接口定义
This commit is contained in:
yuliang_guo
2026-01-30 15:37:14 +08:00
parent d44111e712
commit b4906c543b
11 changed files with 1816 additions and 154 deletions

View File

@@ -40,7 +40,48 @@ export interface CourseMaterial {
createdAt: string
}
// 成长路径节点
// 成长路径节点(学员端)
export interface TraineeGrowthPathNode {
id: number
course_id: number
title: string
description?: string
stage_name?: string
is_required: boolean
estimated_days: number
order_num: number
status: 'locked' | 'unlocked' | 'in_progress' | 'completed'
progress: number
course_name?: string
course_cover?: string
}
// 成长路径阶段
export interface TraineeGrowthPathStage {
name: string
description?: string
completed: number
total: number
nodes: TraineeGrowthPathNode[]
}
// 成长路径(学员端响应)
export interface TraineeGrowthPath {
id: number
name: string
description?: string
position_id?: number
position_name?: string
total_progress: number
completed_nodes: number
total_nodes: number
status: 'not_started' | 'in_progress' | 'completed'
started_at?: string
estimated_completion_days?: number
stages: TraineeGrowthPathStage[]
}
// 兼容旧接口
export interface GrowthPathNode {
id: number
courseId: number
@@ -54,7 +95,7 @@ export interface GrowthPathNode {
order: number
}
// 成长路径
// 兼容旧接口
export interface GrowthPath {
id: number
name: string
@@ -226,10 +267,35 @@ export const markMaterialCompleted = (materialId: number) => {
}
/**
* 获取成长路径
* 获取成长路径(学员端)
*/
export const getGrowthPath = () => {
return request.get<GrowthPath>('/api/v1/trainee/growth-path')
export const getGrowthPath = (positionId?: number) => {
return request.get<TraineeGrowthPath>('/api/v1/trainee/growth-path', {
params: positionId ? { position_id: positionId } : {}
})
}
/**
* 开始学习成长路径
*/
export const startGrowthPath = (growthPathId: number) => {
return request.post<{ success: boolean; message: string; progress_id: number }>('/api/v1/trainee/growth-path/start', {
growth_path_id: growthPathId
})
}
/**
* 完成成长路径节点
*/
export const completeGrowthPathNode = (nodeId: number) => {
return request.post<{
completed: boolean
total_progress: number
is_path_completed: boolean
unlocked_nodes: number[]
}>('/api/v1/trainee/growth-path/node/complete', {
node_id: nodeId
})
}
/**