-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from platinouss/feature/231125-enter-room-api
Feature: DBμμ μ°Έμ¬ μ½λ κ΄λ¦¬ & κ°μμ€ μ μ₯ μ ν΄λΉ μ μ μ μκ°ν κ°μ λͺ©λ‘μ μΆκ°
- Loading branch information
Showing
9 changed files
with
82 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export class CreateRoomDto { | ||
email: string; | ||
title: string; | ||
description: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export class EnterRoomDto { | ||
email: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | ||
import mongoose from 'mongoose'; | ||
import { Lecture } from '../lecture/lecture.schema'; | ||
|
||
@Schema() | ||
export class EnterCode { | ||
@Prop({ required: true }) | ||
code: string; | ||
|
||
@Prop({ type: mongoose.Schema.Types.ObjectId, ref: 'Lecture' }) | ||
lecture_id: Lecture; | ||
} | ||
|
||
export const EnterCodeSchema = SchemaFactory.createForClass(EnterCode); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,31 @@ | ||
import { Body, Controller, HttpStatus, Post, Res } from '@nestjs/common'; | ||
import { Body, Controller, HttpStatus, Param, Patch, Post, Res } from '@nestjs/common'; | ||
import { RoomService } from './room.service'; | ||
import { Response } from 'express'; | ||
import { CreateRoomDto } from './dto/create-room.dto'; | ||
import { EnterRoomDto } from './dto/enter-room.dto'; | ||
import { UserService } from '../user/user.service'; | ||
|
||
@Controller('/room') | ||
export class RoomController { | ||
constructor(private readonly roomService: RoomService) {} | ||
constructor( | ||
private readonly roomService: RoomService, | ||
private readonly userService: UserService | ||
) {} | ||
|
||
@Post() | ||
create(@Body() createRoomDto: CreateRoomDto, @Res() res: Response) { | ||
this.roomService.createRoom(createRoomDto); | ||
res.status(HttpStatus.CREATED).send({ code: this.roomService.generateRoomCode() }); | ||
async create(@Body() createRoomDto: CreateRoomDto, @Res() res: Response) { | ||
const code = await this.roomService.createRoom(createRoomDto); | ||
res.status(HttpStatus.CREATED).send({ code: code }); | ||
} | ||
|
||
@Patch('/:code') | ||
async enter(@Param('code') code: string, @Body() enterRoomDto: EnterRoomDto, @Res() res: Response) { | ||
const enterCodeDocument = await this.roomService.findRoomByCode(code); | ||
if (!enterCodeDocument) { | ||
res.status(HttpStatus.NOT_FOUND).send(); | ||
return; | ||
} | ||
const result = await this.userService.updateLecture(enterRoomDto.email, enterCodeDocument.lecture_id); | ||
res.status(HttpStatus.OK).send(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
backend/src/user/dto/username.update.dto.ts β backend/src/user/dto/user.update.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export class UsernameUpdateDto { | ||
export class UserUpdateDto { | ||
email: string; | ||
username: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters