-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] 녹화 영상 조회 api 구현
- Loading branch information
Showing
19 changed files
with
230 additions
and
33 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
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 |
---|---|---|
|
@@ -20,4 +20,5 @@ GG_CALLBACK_URL= | |
|
||
|
||
#JWT | ||
JWT_SECRET= | ||
JWT_SECRET= | ||
CALLBACK_URI= |
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
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,4 @@ | ||
export class CreateRecordDto { | ||
title: string; | ||
roomId: 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,55 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { Record } from '../record.entity'; | ||
|
||
class RecordDto { | ||
@ApiProperty() | ||
recordId: number; | ||
|
||
@ApiProperty() | ||
video: string; | ||
|
||
@ApiProperty() | ||
title: string; | ||
|
||
@ApiProperty() | ||
date: string; | ||
|
||
static from(record: Record) { | ||
const dto = new RecordDto(); | ||
dto.recordId = record.id; | ||
dto.video = record.video; | ||
dto.title = record.title; | ||
dto.date = this.formatDate(new Date(record.attendance.startTime)); | ||
return dto; | ||
} | ||
|
||
static fromList(records: Record[]) { | ||
return records.map(record => this.from(record)); | ||
} | ||
|
||
private static formatDate(date: Date): string { | ||
return date | ||
.toLocaleDateString('ko-KR', { | ||
year: 'numeric', | ||
month: '2-digit', | ||
day: '2-digit', | ||
}) | ||
.replace(/\. /g, '.') | ||
.slice(0, -1); | ||
} | ||
} | ||
|
||
export class RecordsResponseDto { | ||
@ApiProperty({ | ||
type: RecordDto, | ||
isArray: true, | ||
}) | ||
records: RecordDto[]; | ||
|
||
static from(records: Record[]) { | ||
const dto = new RecordsResponseDto(); | ||
dto.records = RecordDto.fromList(records); | ||
|
||
return dto; | ||
} | ||
} |
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,4 @@ | ||
export class UpdateRecordDto { | ||
video: string; | ||
roomId: 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,37 @@ | ||
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common'; | ||
import { RecordService } from './record.service'; | ||
import { CreateRecordDto } from './dto/create-record.dto'; | ||
import { UpdateRecordDto } from './dto/update-record.dto'; | ||
import { RecordsResponseDto } from './dto/records-response.dto'; | ||
import { SwaggerTag } from 'src/common/constants/swagger-tag.enum'; | ||
import { ApiSuccessResponse } from 'src/common/decorators/success-res.decorator'; | ||
import { SuccessStatus } from 'src/common/responses/bases/successStatus'; | ||
import { ApiErrorResponse } from 'src/common/decorators/error-res.decorator'; | ||
import { ErrorStatus } from 'src/common/responses/exceptions/errorStatus'; | ||
import { ApiOperation, ApiTags } from '@nestjs/swagger'; | ||
|
||
@Controller('v1/records') | ||
export class RecordController { | ||
constructor(private readonly recordService: RecordService) {} | ||
|
||
@Get(':attendanceId') | ||
@ApiTags(SwaggerTag.MYPAGE) | ||
@ApiOperation({ summary: '녹화 리스트 조회' }) | ||
@ApiSuccessResponse(SuccessStatus.OK(RecordsResponseDto), RecordsResponseDto) | ||
@ApiErrorResponse(500, ErrorStatus.INTERNAL_SERVER_ERROR) | ||
async getRecordsByAttendanceId(@Param('attendanceId') attendanceId: string) { | ||
const records = await this.recordService.getRecordsByAttendanceId(attendanceId); | ||
|
||
return RecordsResponseDto.from(records); | ||
} | ||
|
||
@Post() | ||
async createRecord(@Body() createRecordDto: CreateRecordDto) { | ||
return this.recordService.createRecord(createRecordDto); | ||
} | ||
|
||
@Patch() | ||
async updateRecord(@Body() updateRecordDto: UpdateRecordDto) { | ||
return this.recordService.updateRecord(updateRecordDto); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { Record } from './record.entity'; | ||
import { RecordService } from './record.service'; | ||
import { AttendanceModule } from 'src/attendance/attendance.module'; | ||
import { RecordController } from './record.controller'; | ||
|
||
@Module({}) | ||
@Module({ | ||
imports: [TypeOrmModule.forFeature([Record]), AttendanceModule], | ||
controllers: [RecordController], | ||
providers: [RecordService], | ||
}) | ||
export class RecordModule {} |
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
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
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
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
Oops, something went wrong.