From a46ab81470d92726e835764a89eb804bf8e6da49 Mon Sep 17 00:00:00 2001 From: So Hyeon Date: Mon, 8 Apr 2024 19:27:46 +0900 Subject: [PATCH] feat: event module (#2) * feat: event module * fix: event module lint --- src/app.module.ts | 2 ++ src/config.swagger.ts | 1 + src/event/dto/create-event.dto.ts | 1 + src/event/dto/update-event.dto.ts | 4 +++ src/event/entities/event.entity.ts | 1 + src/event/event.controller.spec.ts | 20 ++++++++++++++ src/event/event.controller.ts | 44 ++++++++++++++++++++++++++++++ src/event/event.module.ts | 9 ++++++ src/event/event.service.spec.ts | 18 ++++++++++++ src/event/event.service.ts | 26 ++++++++++++++++++ 10 files changed, 126 insertions(+) create mode 100644 src/event/dto/create-event.dto.ts create mode 100644 src/event/dto/update-event.dto.ts create mode 100644 src/event/entities/event.entity.ts create mode 100644 src/event/event.controller.spec.ts create mode 100644 src/event/event.controller.ts create mode 100644 src/event/event.module.ts create mode 100644 src/event/event.service.spec.ts create mode 100644 src/event/event.service.ts diff --git a/src/app.module.ts b/src/app.module.ts index 17b1a75..fa23786 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -5,6 +5,7 @@ import { AuthModule } from './auth/auth.module'; import { TransactionModule } from './transaction/transaction.module'; import { MemberModule } from './member/member.module'; import { ConfigModule } from '@nestjs/config'; +import { EventModule } from './event/event.module'; @Module({ imports: [ @@ -16,6 +17,7 @@ import { ConfigModule } from '@nestjs/config'; AuthModule, TransactionModule, MemberModule, + EventModule, ], }) export class AppModule {} diff --git a/src/config.swagger.ts b/src/config.swagger.ts index 8e84839..ab17f57 100644 --- a/src/config.swagger.ts +++ b/src/config.swagger.ts @@ -9,6 +9,7 @@ export const configSwagger = (app: INestApplication) => { .addTag('Member', '모임 회원 관련 API') .addTag('Transaction', '거래내역 관련 API') .addTag('User', '사용자 관련 API') + .addTag('Event', '이벤트 관련 API') .build(); const document = SwaggerModule.createDocument(app, config); diff --git a/src/event/dto/create-event.dto.ts b/src/event/dto/create-event.dto.ts new file mode 100644 index 0000000..f23a408 --- /dev/null +++ b/src/event/dto/create-event.dto.ts @@ -0,0 +1 @@ +export class CreateEventDto {} diff --git a/src/event/dto/update-event.dto.ts b/src/event/dto/update-event.dto.ts new file mode 100644 index 0000000..f161e01 --- /dev/null +++ b/src/event/dto/update-event.dto.ts @@ -0,0 +1,4 @@ +import { PartialType } from '@nestjs/swagger'; +import { CreateEventDto } from './create-event.dto'; + +export class UpdateEventDto extends PartialType(CreateEventDto) {} diff --git a/src/event/entities/event.entity.ts b/src/event/entities/event.entity.ts new file mode 100644 index 0000000..8c34a9a --- /dev/null +++ b/src/event/entities/event.entity.ts @@ -0,0 +1 @@ +export class Event {} diff --git a/src/event/event.controller.spec.ts b/src/event/event.controller.spec.ts new file mode 100644 index 0000000..66996db --- /dev/null +++ b/src/event/event.controller.spec.ts @@ -0,0 +1,20 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { EventController } from './event.controller'; +import { EventService } from './event.service'; + +describe('EventController', () => { + let controller: EventController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [EventController], + providers: [EventService], + }).compile(); + + controller = module.get(EventController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/src/event/event.controller.ts b/src/event/event.controller.ts new file mode 100644 index 0000000..35cfa8f --- /dev/null +++ b/src/event/event.controller.ts @@ -0,0 +1,44 @@ +import { + Body, + Controller, + Delete, + Get, + Param, + Patch, + Post, +} from '@nestjs/common'; +import { EventService } from './event.service'; +import { CreateEventDto } from './dto/create-event.dto'; +import { UpdateEventDto } from './dto/update-event.dto'; +import { ApiTags } from '@nestjs/swagger'; + +@ApiTags('Event') +@Controller('event') +export class EventController { + constructor(private readonly eventService: EventService) {} + + @Post() + create(@Body() createEventDto: CreateEventDto) { + return this.eventService.create(createEventDto); + } + + @Get() + findAll() { + return this.eventService.findAll(); + } + + @Get(':id') + findOne(@Param('id') id: string) { + return this.eventService.findOne(+id); + } + + @Patch(':id') + update(@Param('id') id: string, @Body() updateEventDto: UpdateEventDto) { + return this.eventService.update(+id, updateEventDto); + } + + @Delete(':id') + remove(@Param('id') id: string) { + return this.eventService.remove(+id); + } +} diff --git a/src/event/event.module.ts b/src/event/event.module.ts new file mode 100644 index 0000000..0ae4e92 --- /dev/null +++ b/src/event/event.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { EventService } from './event.service'; +import { EventController } from './event.controller'; + +@Module({ + controllers: [EventController], + providers: [EventService], +}) +export class EventModule {} diff --git a/src/event/event.service.spec.ts b/src/event/event.service.spec.ts new file mode 100644 index 0000000..78cb816 --- /dev/null +++ b/src/event/event.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { EventService } from './event.service'; + +describe('EventService', () => { + let service: EventService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [EventService], + }).compile(); + + service = module.get(EventService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/src/event/event.service.ts b/src/event/event.service.ts new file mode 100644 index 0000000..a806e91 --- /dev/null +++ b/src/event/event.service.ts @@ -0,0 +1,26 @@ +import { Injectable } from '@nestjs/common'; +import { CreateEventDto } from './dto/create-event.dto'; +import { UpdateEventDto } from './dto/update-event.dto'; + +@Injectable() +export class EventService { + create(createEventDto: CreateEventDto) { + return createEventDto; + } + + findAll() { + return `This action returns all event`; + } + + findOne(id: number) { + return `This action returns a #${id} event`; + } + + update(id: number, updateEventDto: UpdateEventDto) { + return `This action updates a #${id} event` + updateEventDto; + } + + remove(id: number) { + return `This action removes a #${id} event`; + } +}