diff --git a/API文档.md b/API文档.md index 646be5d..e2fecdd 100644 --- a/API文档.md +++ b/API文档.md @@ -56,11 +56,12 @@ ### 课程任务相关字段 1. **进度状态 (progressStatus)** - - 0: 脚本上传 - - 1: 脚本确认 - - 2: 视频拍摄 - - 3: 后期制作 - - 4: 任务完成 + - 0: 未开始 + - 1: 脚本制作 + - 2: 脚本审核 + - 3: 脚本确认 + - 4: 视频拍摄与制作 + - 5: 视频确认 ## 用户接口 @@ -274,12 +275,12 @@ ### 1. 获取课程任务列表 - **接口**:`GET /api/lesson-tasks` -- **描述**:分页获取课程任务列表 +- **描述**:分页获取课程任务列表,可按用户筛选 - **认证**:需要 - **查询参数**: - `page`: 页码(从 1 开始) - `size`: 每页数量(默认 10) - - `userId`: 用户 ID(可选) + - `userId`: 用户ID(可选) - **成功响应**: ```json { @@ -288,27 +289,35 @@ "data": { "content": [ { - "id": 6, - "courseName": "Test Course", - "microLessonName": "Test Lesson", - "userId": 12, - "progressStatus": 1, - "scriptUploadTime": 1734578081, - "scriptConfirmTime": 1734578081, - "videoCaptureTime": 1734578081, - "videoConfirmTime": 1734578081, - "finishTime": 1734578081, - "advise": "Test advice", - "createdAt": 1734578081, - "updatedAt": 1734578081 + "id": 1, + "courseName": "数学", + "microLessonName": "数学1-1", + "userId": 1, + "progressStatus": 4, + "scriptCreateTime": 1734940587, + "scriptReviewTime": null, + "scriptConfirmTime": 1734940825, + "videoCreateTime": 1734940832, + "videoConfirmTime": 1734940837, + "finishTime": 1734940837, + "advise": "", + "createdAt": 1734674726, + "updatedAt": 1734940837 } ], - "totalElements": 4, + "pageable": { + "pageNumber": 0, + "pageSize": 10, + "sort": { + "empty": true, + "unsorted": true, + "sorted": false + } + }, + "totalElements": 7, "totalPages": 1, - "size": 10, - "number": 0, - "first": true, "last": true, + "first": true, "empty": false } } @@ -317,29 +326,30 @@ ### 2. 获取单个课程任务 - **接口**:`GET /api/lesson-tasks/{id}` -- **描述**:获取指定 ID 的课程任务 +- **描述**:根据ID获取课程任务详情 - **认证**:需要 - **路径参数**: - - `id`: 课程任务 ID + - `id`: 课程任务ID - **成功响应**: ```json { "code": 10000, "message": "成功", "data": { - "id": 6, - "courseName": "Test Course", - "microLessonName": "Test Lesson", - "userId": 12, - "progressStatus": 1, - "scriptUploadTime": 1734578081, - "scriptConfirmTime": 1734578081, - "videoCaptureTime": 1734578081, - "videoConfirmTime": 1734578081, - "finishTime": 1734578081, - "advise": "Test advice", - "createdAt": 1734578081, - "updatedAt": 1734578081 + "id": 1, + "courseName": "数学", + "microLessonName": "数学1-1", + "userId": 1, + "progressStatus": 4, + "scriptCreateTime": 1734940587, + "scriptReviewTime": null, + "scriptConfirmTime": 1734940825, + "videoCreateTime": 1734940832, + "videoConfirmTime": 1734940837, + "finishTime": 1734940837, + "advise": "", + "createdAt": 1734674726, + "updatedAt": 1734940837 } } ``` @@ -352,55 +362,10 @@ - **请求体**: ```json { - "courseName": "Java基础", // 课程名称,不可为空 - "microLessonName": "Java变量", // 微课名称,不可为空 - "userId": 1, // 负责人ID,不可为空,关联users表 - "advise": "请注意讲解速度" // 任务建议或备注,可选 - } - ``` -- **成功响应**: - ```json - { - "code": 10000, - "message": "成功", - "data": { - "id": 6, - "courseName": "Java基础", - "microLessonName": "Java变量", - "userId": 1, - "progressStatus": 1, - "scriptUploadTime": , - "scriptConfirmTime": , - "videoCaptureTime": , - "videoConfirmTime": , - "finishTime": , - "advise": "请注意讲解速度", - "createdAt": 1734578081, - "updatedAt": 1734578081 - } - } - ``` - -### 4. 更新课程任务 - -- **接口**:`PUT /api/lesson-tasks/{id}` -- **描述**:更新指定 ID 的课程任务 -- **认证**:需要 -- **路径参数**: - - `id`: 课程任务 ID -- **请求体**: - ```json - { - "courseName": "Updated Course", // 课程名称 - "microLessonName": "Updated Lesson", // 微课名称 - "userId": 12, // 用户ID - "progressStatus": 2, // 进度状态 - "scriptUploadTime": 1734578081, // 脚本上传时间 - "scriptConfirmTime": 1734578081, // 脚本确认时间 - "videoCaptureTime": 1734578081, // 视频录制时间 - "videoConfirmTime": 1734578081, // 视频确认时间 - "finishTime": 1734578081, // 完成时间 - "advise": "Updated advice" // 建议 + "courseName": "测试课程", + "microLessonName": "测试微课", + "userId": 1, + "advise": "任务说明" } ``` - **成功响应**: @@ -409,46 +374,69 @@ "code": 10000, "message": "成功", "data": { - "id": 6, - "courseName": "Updated Course", - "microLessonName": "Updated Lesson", - "userId": 12, - "progressStatus": 2, - "scriptUploadTime": 1734578081, - "scriptConfirmTime": 1734578081, - "videoCaptureTime": 1734578081, - "videoConfirmTime": 1734578081, - "finishTime": 1734578081, - "advise": "Updated advice", - "createdAt": 1734578081, - "updatedAt": 1734578081 + "id": 11, + "courseName": "测试课程", + "microLessonName": "测试微课", + "userId": 1, + "progressStatus": 0, + "scriptCreateTime": null, + "scriptReviewTime": null, + "scriptConfirmTime": null, + "videoCreateTime": null, + "videoConfirmTime": null, + "finishTime": null, + "advise": "任务说明", + "createdAt": 1735003870, + "updatedAt": 1735003870 } } ``` -### 5. 删除课程任务 +### 4. 更新课程任务 -- **接口**:`DELETE /api/lesson-tasks/{id}` -- **描述**:删除指定 ID 的课程任务 +- **接口**:`PUT /api/lesson-tasks/{id}` +- **描述**:更新课程任务信息 - **认证**:需要 - **路径参数**: - - `id`: 课程任务 ID + - `id`: 课程任务ID +- **请求体**: + ```json + { + "progressStatus": 1, + "advise": "更新的任务说明" + } + ``` - **成功响应**: ```json { "code": 10000, "message": "成功", - "data": null + "data": { + "id": 11, + "courseName": "测试课程", + "microLessonName": "测试微课", + "userId": 1, + "progressStatus": 1, + "scriptCreateTime": 1735003922, + "scriptReviewTime": null, + "scriptConfirmTime": null, + "videoCreateTime": null, + "videoConfirmTime": null, + "finishTime": null, + "advise": "更新的任务说明", + "createdAt": 1735003870, + "updatedAt": 1735003922 + } } ``` -### 6. 按部门 ID 查询课程任务 +### 5. 获取部门课程任务 - **接口**:`GET /api/lesson-tasks/department/{departmentId}` -- **描述**:获取指定部门下正常状态用户的课程任务列表(分页) +- **描述**:获取指定部门的课程任务列表 - **认证**:需要 - **路径参数**: - - `departmentId`: 部门 ID + - `departmentId`: 部门ID - **查询参数**: - `page`: 页码(从 1 开始) - `size`: 每页数量(默认 10) @@ -461,89 +449,51 @@ "content": [ { "id": 1, - "courseName": "物理", - "microLessonName": "微课1-1", + "courseName": "数学", + "microLessonName": "数学1-1", "userId": 1, - "username": "教师账号1", // 新增:用户名字段 + "username": "教师账号1", "progressStatus": 4, - "scriptUploadTime": 1734498510, - "scriptConfirmTime": 1734498510, - "videoCaptureTime": 1734498510, - "videoConfirmTime": 1734498510, - "finishTime": 1734498510, - "advise": null, - "createdAt": 1734578081, - "updatedAt": 1734580393 + "scriptCreateTime": 1734940587, + "scriptReviewTime": null, + "scriptConfirmTime": 1734940825, + "videoCreateTime": 1734940832, + "videoConfirmTime": 1734940837, + "finishTime": 1734940837, + "advise": "", + "createdAt": 1734674726, + "updatedAt": 1734940837 } ], - "totalElements": 10, - "totalPages": 1, - "size": 10, - "number": 0, - "first": true, - "last": true, - "empty": false + "pageable": { + "pageNumber": 0, + "pageSize": 10 + }, + "totalElements": 11, + "totalPages": 2 } } ``` -### 7. 更新课程任务进度 +### 6. 删除课程任务 -- **接口**:`PUT /api/lesson-tasks/{id}` -- **描述**:更新课程任务的进度状态和建议 +- **接口**:`DELETE /api/lesson-tasks/{id}` +- **描述**:删除指定的课程任务 - **认证**:需要 - **路径参数**: - - `id`: 课程任务 ID -- **请求体**: - ```json - { - "progressStatus": 2, // 进度状态(可选) - "advise": "{\"method\":\"wechat\",\"uploaded\":true}" // 建议(可选) - } - ``` -- **说明**: - - 更新进度状态时会自动更新对应的时间戳: - - 状态 1:更新 scriptUploadTime - - 状态 2:更新 scriptConfirmTime - - 状态 3:更新 videoCaptureTime - - 状态 4:更新 videoConfirmTime - - 状态 5:更新 finishTime - - 只会更新请求体中包含的字段,未提供的字段保持不变 + - `id`: 课程任务ID - **成功响应**: ```json { "code": 10000, "message": "成功", - "data": { - "id": 10, - "courseName": "测试课程", - "microLessonName": "测试微课", - "userId": 1, - "progressStatus": 2, - "scriptUploadTime": null, - "scriptConfirmTime": 1734663755, - "videoCaptureTime": null, - "videoConfirmTime": null, - "finishTime": null, - "advise": "{\"method\":\"wechat\",\"uploaded\":true}", - "createdAt": 1734602440, - "updatedAt": 1734663755 - } + "data": null } ``` ## 注意事项 -1. 所有需要认证的接口必须在请求头中携带有效的 JWT 令牌 -2. 所有时间戳字段均为秒级时间戳 -3. 分页接口的页码从 1 开始 -4. 用户密码在传输和存储时都会进行加密处理 -5. 课程任务的 progressStatus 字段状态码说明: - - 0: 脚本上传 - - 1: 脚本确认 - - 2: 视频拍摄 - - 3: 后期制作 - - 4: 任务完成 -6. 用户状态说明: - - 1: 正常 - - 0: 禁用 +1. 所有时间戳字段均使用秒级时间戳(10位) +2. 课程任务状态变更时会自动记录相应的时间戳 +3. 部门课程任务列表会额外返回用户名信息 +4. 分页参数中的页码从1开始 diff --git a/components.d.ts b/components.d.ts index 6ad8f77..18ec8fb 100644 --- a/components.d.ts +++ b/components.d.ts @@ -11,6 +11,7 @@ declare module 'vue' { TabBar: typeof import('./src/components/TabBar.vue')['default'] WdBadge: typeof import('wot-design-uni/components/wd-badge/wd-badge.vue')['default'] WdButton: typeof import('wot-design-uni/components/wd-button/wd-button.vue')['default'] + WdCard: typeof import('wot-design-uni/components/wd-card/wd-card.vue')['default'] WdCell: typeof import('wot-design-uni/components/wd-cell/wd-cell.vue')['default'] WdCellGroup: typeof import('wot-design-uni/components/wd-cell-group/wd-cell-group.vue')['default'] WdCheckbox: typeof import('wot-design-uni/components/wd-checkbox/wd-checkbox.vue')['default'] @@ -31,6 +32,7 @@ declare module 'vue' { WdSteps: typeof import('wot-design-uni/components/wd-steps/wd-steps.vue')['default'] WdTabbar: typeof import('wot-design-uni/components/wd-tabbar/wd-tabbar.vue')['default'] WdTabbarItem: typeof import('wot-design-uni/components/wd-tabbar-item/wd-tabbar-item.vue')['default'] + WdTextarea: typeof import('wot-design-uni/components/wd-textarea/wd-textarea.vue')['default'] WdToast: typeof import('wot-design-uni/components/wd-toast/wd-toast.vue')['default'] } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 409ecb3..3da3520 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1509,55 +1509,46 @@ packages: resolution: {integrity: sha512-btVgIsCjuYFKUjopPoWiDqmoUXQDiW2A4C3Mtmp5vACm7/GnyuprqIDPNczeyR5W8rTXEbkmrJux7cJmD99D2g==} cpu: [arm] os: [linux] - libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.21.3': resolution: {integrity: sha512-zmjbSphplZlau6ZTkxd3+NMtE4UKVy7U4aVFMmHcgO5CUbw17ZP6QCgyxhzGaU/wFFdTfiojjbLG3/0p9HhAqA==} cpu: [arm] os: [linux] - libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.21.3': resolution: {integrity: sha512-nSZfcZtAnQPRZmUkUQwZq2OjQciR6tEoJaZVFvLHsj0MF6QhNMg0fQ6mUOsiCUpTqxTx0/O6gX0V/nYc7LrgPw==} cpu: [arm64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.21.3': resolution: {integrity: sha512-MnvSPGO8KJXIMGlQDYfvYS3IosFN2rKsvxRpPO2l2cum+Z3exiExLwVU+GExL96pn8IP+GdH8Tz70EpBhO0sIQ==} cpu: [arm64] os: [linux] - libc: [musl] '@rollup/rollup-linux-powerpc64le-gnu@4.21.3': resolution: {integrity: sha512-+W+p/9QNDr2vE2AXU0qIy0qQE75E8RTwTwgqS2G5CRQ11vzq0tbnfBd6brWhS9bCRjAjepJe2fvvkvS3dno+iw==} cpu: [ppc64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-riscv64-gnu@4.21.3': resolution: {integrity: sha512-yXH6K6KfqGXaxHrtr+Uoy+JpNlUlI46BKVyonGiaD74ravdnF9BUNC+vV+SIuB96hUMGShhKV693rF9QDfO6nQ==} cpu: [riscv64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-s390x-gnu@4.21.3': resolution: {integrity: sha512-R8cwY9wcnApN/KDYWTH4gV/ypvy9yZUHlbJvfaiXSB48JO3KpwSpjOGqO4jnGkLDSk1hgjYkTbTt6Q7uvPf8eg==} cpu: [s390x] os: [linux] - libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.21.3': resolution: {integrity: sha512-kZPbX/NOPh0vhS5sI+dR8L1bU2cSO9FgxwM8r7wHzGydzfSjLRCFAT87GR5U9scj2rhzN3JPYVC7NoBbl4FZ0g==} cpu: [x64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-x64-musl@4.21.3': resolution: {integrity: sha512-S0Yq+xA1VEH66uiMNhijsWAafffydd2X5b77eLHfRmfLsRSpbiAWiRHV6DEpz6aOToPsgid7TI9rGd6zB1rhbg==} cpu: [x64] os: [linux] - libc: [musl] '@rollup/rollup-win32-arm64-msvc@4.21.3': resolution: {integrity: sha512-9isNzeL34yquCPyerog+IMCNxKR8XYmGd0tHSV+OVx0TmE0aJOo9uw4fZfUuk2qxobP5sug6vNdZR6u7Mw7Q+Q==} diff --git a/src/api/BussApi.ts b/src/api/BussApi.ts index a7ce03e..63f8eb1 100644 --- a/src/api/BussApi.ts +++ b/src/api/BussApi.ts @@ -1,9 +1,8 @@ import http from "@/http/HttpClient"; import { useUser } from "@/stores/useUser"; -import type { PagedData } from "@/types/api/common"; -import type { CreateLessonTaskRequest, LessonTask, UpdateLessonTaskRequest } from "@/types/api/lesson"; +import type { LessonTask, UpdateLessonTaskRequest } from "@/types/api/lesson"; import type { LoginRequest } from "@/types/api/auth"; -import type { CreateUserRequest, User } from "@/types/api/user"; +import type { User } from "@/types/api/user"; /** * 业务API类 @@ -176,13 +175,14 @@ export default class BussApi { /** * 更新课程进度 * @param lessonId - 课程ID + * @param progressStatus - 进度状态 (0-未开始, 1-脚本制作, 2-脚本审核, 3-脚本确认, 4-视频制作, 5-视频确认) * @returns Promise */ - static updateLessonProgress(lessonId: number): Promise { + static updateLessonProgress(lessonId: number, progressStatus: number): Promise { const user = useUser(); return http .server() - .post(`lesson/${lessonId}/progress`, null, { + .post(`lesson/${lessonId}/progress`, { progressStatus }, { headers: { Authorization: `Bearer ${user.token}`, }, diff --git a/src/components/TabBar.vue b/src/components/TabBar.vue index f6b54b3..667b43a 100644 --- a/src/components/TabBar.vue +++ b/src/components/TabBar.vue @@ -31,17 +31,17 @@ const nameLabelIconMap = { home: { title: '进度查看', icon: 'dashboard', - roles: ['teacher', 'admin', 'liaison', 'sysadmin'] as const // 使用 as const 来确保类型正确 + roles: ['teacher', 'liaison', 'admin', 'sysadmin'] as const // 校方教师、校方项目负责人、公司课程顾问、公司系统管理员 }, progress: { title: '进度管理', icon: 'transfer', - roles: ['teacher', 'admin', 'sysadmin'] as const + roles: ['teacher', 'admin', 'sysadmin'] as const // 校方教师、公司课程顾问、公司系统管理员 }, my: { title: '我的', icon: 'user', - roles: ['teacher', 'admin', 'liaison', 'sysadmin'] as const + roles: ['teacher', 'liaison', 'admin', 'sysadmin'] as const // 校方教师、校方项目负责人、公司课程顾问、公司系统管理员 } } diff --git a/src/composables/useConfig.ts b/src/composables/useConfig.ts index e22b42a..02c6c26 100644 --- a/src/composables/useConfig.ts +++ b/src/composables/useConfig.ts @@ -4,8 +4,8 @@ import { ref } from "vue"; export const useConfig = defineStore('config', () => { // const BASE_URL = ref("https://ppmp.fenshenzhike.com/api"); // const BASE_URL = ref("http://localhost:1218/api"); - const BASE_URL = ref("http://192.168.0.178:1218/api"); - // const BASE_URL = ref("http://192.30.5.16:1218/api"); + const BASE_URL = ref("http://192.168.0.119:1218/api"); + // const BASE_URL = ref("http://192.30.5.11:1218/api"); return { BASE_URL diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 5c3068a..a8d2491 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -4,7 +4,7 @@ import pageWrapper from '@/components/page-wrapper.vue'; import { useUser } from '@/stores/useUser'; import type { LessonTask } from '@/types/api/lesson'; import { calcLessonProgress } from '@/utils/lesson'; -import { onPageShow } from '@dcloudio/uni-app'; +import { onPageShow, onLoad, onPullDownRefresh } from '@dcloudio/uni-app'; import { useRouter } from 'uni-mini-router'; import { onMounted, ref, watch } from 'vue'; import { useToast } from 'wot-design-uni'; @@ -73,8 +73,24 @@ const loadLessons = async () => { toast.loading({ msg: '加载中...' }) try { - const userId = teacherFilterValue.value === 0 ? undefined : teacherFilterValue.value - const res = await BussApi.getLessonTasks(1, 512, userId) + let res; + + if (user.hasRole('teacher')) { + res = await BussApi.getLessonTasks(1, 512, user.userinfo.id) + } else if (user.hasRole('admin') || user.hasRole('liaison')) { + const userId = teacherFilterValue.value === 0 ? undefined : teacherFilterValue.value + if (userId) { + res = await BussApi.getLessonTasks(1, 512, userId) + } else { + res = await BussApi.getLessonTasks(1, 512) + } + } else if (user.hasRole('sysadmin')) { + const userId = teacherFilterValue.value === 0 ? undefined : teacherFilterValue.value + res = await BussApi.getLessonTasks(1, 512, userId) + } else { + toast.error({ msg: '无权限访问' }) + return + } if (res.code !== 10000 || !res.data?.content || !Array.isArray(res.data.content)) { toast.error({ msg: res.message || '获取数据失败' }) @@ -92,7 +108,6 @@ const loadLessons = async () => { }, {}) groupedLessons.value = groupData - // expand courses with lessons in progress expandedCourse.value = Object.keys(groupData).filter(courseName => { return groupData[courseName].filter((lesson: LessonTask) => calcLessonProgress(lesson) !== 0 && calcLessonProgress(lesson) !== 100 @@ -109,7 +124,6 @@ const loadLessons = async () => { } } -// 监听教师筛选值的变化 watch(teacherFilterValue, () => { loadLessons() }) @@ -125,6 +139,26 @@ const getUsernameById = (userId: number) => { } else return '' } + +const refresh = async () => { + try { + uni.reLaunch({ + url: '/pages/index/index' + }) + } catch (err) { + } finally { + uni.stopPullDownRefresh() + } +} + +onPullDownRefresh(() => { + refresh() +}) + +onLoad(() => { + loadLessons() +}) +