Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: event module #2

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -16,6 +17,7 @@ import { ConfigModule } from '@nestjs/config';
AuthModule,
TransactionModule,
MemberModule,
EventModule,
],
})
export class AppModule {}
1 change: 1 addition & 0 deletions src/config.swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const configSwagger = (app: INestApplication<any>) => {
.addTag('Member', '모임 회원 관련 API')
.addTag('Transaction', '거래내역 관련 API')
.addTag('User', '사용자 관련 API')
.addTag('Event', '이벤트 관련 API')
.build();

const document = SwaggerModule.createDocument(app, config);
Expand Down
1 change: 1 addition & 0 deletions src/event/dto/create-event.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class CreateEventDto {}
4 changes: 4 additions & 0 deletions src/event/dto/update-event.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/swagger';
import { CreateEventDto } from './create-event.dto';

export class UpdateEventDto extends PartialType(CreateEventDto) {}
1 change: 1 addition & 0 deletions src/event/entities/event.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class Event {}
20 changes: 20 additions & 0 deletions src/event/event.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -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>(EventController);
});

it('should be defined', () => {
expect(controller).toBeDefined();
});
});
44 changes: 44 additions & 0 deletions src/event/event.controller.ts
Original file line number Diff line number Diff line change
@@ -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);
}
}
9 changes: 9 additions & 0 deletions src/event/event.module.ts
Original file line number Diff line number Diff line change
@@ -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 {}
18 changes: 18 additions & 0 deletions src/event/event.service.spec.ts
Original file line number Diff line number Diff line change
@@ -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>(EventService);
});

it('should be defined', () => {
expect(service).toBeDefined();
});
});
26 changes: 26 additions & 0 deletions src/event/event.service.ts
Original file line number Diff line number Diff line change
@@ -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) {
Fixed Show fixed Hide fixed
return createEventDto;
}

findAll() {
return `This action returns all event`;
}

findOne(id: number) {
return `This action returns a #${id} event`;
}

update(id: number, updateEventDto: UpdateEventDto) {
Fixed Show fixed Hide fixed
return `This action updates a #${id} event` + updateEventDto;
}

remove(id: number) {
return `This action removes a #${id} event`;
}
}
Loading