四端上传
This commit is contained in:
1 parent
25bbb5f9c8
commit
c6e2cb4d5b
276 files changed
+17812
-3
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import { Controller, Get, Param, Query } from '@nestjs/common';
|
||||
import { CurrentUser, Public, type AuthPrincipal } from '../../common/auth';
|
||||
import { AppError } from '../../common/errors';
|
||||
import { CoursesService } from './courses.service';
|
||||
|
||||
@Controller('v1')
|
||||
export class CoursesController {
|
||||
constructor(private readonly courses: CoursesService) {}
|
||||
|
||||
@Get('courses')
|
||||
list(@CurrentUser() user: AuthPrincipal) {
|
||||
return this.courses.list(user.id);
|
||||
}
|
||||
|
||||
@Get('courses/:code')
|
||||
detail(@CurrentUser() user: AuthPrincipal, @Param('code') code: string) {
|
||||
return this.courses.detail(user.id, code);
|
||||
}
|
||||
|
||||
@Get('courses/:code/lessons')
|
||||
lessons(@CurrentUser() user: AuthPrincipal, @Param('code') code: string) {
|
||||
return this.courses.lessons(user.id, code);
|
||||
}
|
||||
|
||||
@Get('courses/:code/play')
|
||||
play(
|
||||
@CurrentUser() user: AuthPrincipal,
|
||||
@Param('code') code: string,
|
||||
@Query('chapterId') chapterId?: string,
|
||||
@Query('playId') playId?: string,
|
||||
) {
|
||||
if (!chapterId || !playId) throw AppError.badRequest('参数错误:缺少 chapterId 或 playId');
|
||||
return this.courses.playUrl(user.id, code, chapterId, playId);
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Get('free-lessons')
|
||||
freeLessons(@Query('seriesNo') seriesNo?: string) {
|
||||
if (seriesNo === undefined || seriesNo === '') return this.courses.freeLessons();
|
||||
const n = Number(seriesNo);
|
||||
return this.courses.freeLessons(Number.isFinite(n) ? n : undefined);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user