Skip to content

Commit

Permalink
feat: 코스에 장소를 추가할 때 본인이 만든 코스인지 확인 후 수정 가능하도록 구현 #83
Browse files Browse the repository at this point in the history
  • Loading branch information
koomchang committed Nov 9, 2024
1 parent 2171778 commit d39672d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions backend/src/course/course.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { CourseService } from './course.service';
import { SetPlacesOfCourseRequest } from './dto/AddPlaceToCourseRequest';
import { JwtAuthGuard } from '../auth/JwtAuthGuard';
import { AuthUser } from '../auth/AuthUser.decorator';
import { CoursePermissionGuard } from './guards/CoursePermissionGuard';

@Controller('/courses')
export class CourseController {
Expand Down Expand Up @@ -46,13 +47,19 @@ export class CourseController {
}

@Post()
async createCourse(@Body() createCourseRequest: CreateCourseRequest) {
const userId = 1; // Todo. 로그인 기능 완성 후 수정
@UseGuards(JwtAuthGuard)
async createCourse(
@AuthUser() user: AuthUser,
@Body() createCourseRequest: CreateCourseRequest,
) {
const userId = Number(user.userId);
return await this.courseService.createCourse(userId, createCourseRequest);
}

@Put('/:id/places')
@UseGuards(JwtAuthGuard, CoursePermissionGuard)
async setPlacesOfCourse(
@AuthUser() user: AuthUser,
@Param('id') id: number,
@Body() setPlacesOfCourseRequest: SetPlacesOfCourseRequest,
) {
Expand Down

0 comments on commit d39672d

Please sign in to comment.