-
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.
* feat: Group 속성에 `events` 추가 * feat: Event CRUD * feat: Group.members > `any` * feat: [GET] /group/member 수정 * feat: groupService > addEvent, deleteEvent * feat: Event CRUD * feat: excel 서비스 common/excel로 이전 * lint: format @trivago/prettier-plugin-sort-imports * refactor: /common /excel 분리 * fix: eventService Update * fix: member.controller.spec.ts module dependency * fix: eslint.yml * feat: member/excel 엔드포인트 변경
- Loading branch information
Showing
42 changed files
with
408 additions
and
186 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 |
---|---|---|
@@ -1,8 +1,22 @@ | ||
{ | ||
"printWidth": 80, | ||
"tabWidth": 2, | ||
"trailingComma": "all", | ||
"singleQuote": true, | ||
"semi": true, | ||
"plugins": [ | ||
"@trivago/prettier-plugin-sort-imports" | ||
], | ||
"importOrderParserPlugins": [ | ||
"typescript", | ||
"decorators-legacy" | ||
], | ||
"importOrder": [ | ||
"^@core/(.*)$", | ||
"^@server/(.*)$", | ||
"^@ui/(.*)$", | ||
"^[./]" | ||
], | ||
"importOrderSeparation": true, | ||
"importOrderSortSpecifiers": true | ||
} | ||
} |
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
4 changes: 2 additions & 2 deletions
4
src/api-file.decorator.ts → src/common/decorators/api-file.decorator.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
File renamed without changes.
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 @@ | ||
import { Module } from '@nestjs/common'; | ||
|
||
import { databaseProviders } from './database.providers'; | ||
|
||
@Module({ | ||
|
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 +1,33 @@ | ||
export class CreateEventDto {} | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class CreateEventDto { | ||
@ApiProperty({ | ||
description: '이벤트 이름', | ||
example: '2024년 1학기 모임', | ||
}) | ||
name: string; | ||
|
||
@ApiProperty({ | ||
description: '이벤트 설명', | ||
example: '2024년 1학기 모임입니다.', | ||
}) | ||
description: string; | ||
|
||
@ApiProperty({ | ||
description: '이벤트 시작일', | ||
example: new Date().toISOString(), | ||
}) | ||
startDate: Date; | ||
|
||
@ApiProperty({ | ||
description: '이벤트 종료일', | ||
example: new Date(), | ||
}) | ||
endDate: Date; | ||
|
||
@ApiProperty({ | ||
description: '이벤트 참가비', | ||
example: 10000, | ||
}) | ||
fee: number; | ||
} |
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 @@ | ||
import { PartialType } from '@nestjs/swagger'; | ||
|
||
import { CreateEventDto } from './create-event.dto'; | ||
|
||
export class UpdateEventDto extends PartialType(CreateEventDto) {} |
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 +1,8 @@ | ||
export class Event {} | ||
export class Event { | ||
name: string; | ||
description: string; | ||
startDate: Date; | ||
endDate: Date; | ||
fee: number; | ||
attendees: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { EventService } from './event.service'; | ||
|
||
import { DatabaseModule } from '../database/database.module'; | ||
import { GroupModule } from '../group/group.module'; | ||
import { EventController } from './event.controller'; | ||
import { eventProviders } from './event.providers'; | ||
import { EventRepository } from './event.repository'; | ||
import { EventService } from './event.service'; | ||
|
||
@Module({ | ||
imports: [DatabaseModule, GroupModule], | ||
controllers: [EventController], | ||
providers: [EventService], | ||
providers: [EventService, ...eventProviders, EventRepository], | ||
}) | ||
export class EventModule {} |
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,12 @@ | ||
import { Connection } from 'mongoose'; | ||
|
||
import { EventSchema } from './schemas/event.schema'; | ||
|
||
export const eventProviders = [ | ||
{ | ||
provide: 'EVENT_MODEL', | ||
useFactory: (connection: Connection) => | ||
connection.model('Event', EventSchema), | ||
inject: ['MONGODB_CONNECTION'], | ||
}, | ||
]; |
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,35 @@ | ||
import { Inject, Injectable } from '@nestjs/common'; | ||
import { Model } from 'mongoose'; | ||
|
||
import { CreateEventDto } from './dto/create-event.dto'; | ||
import { Event } from './interfaces/event.interface'; | ||
|
||
@Injectable() | ||
export class EventRepository { | ||
constructor( | ||
@Inject('EVENT_MODEL') | ||
private readonly eventModel: Model<Event>, | ||
) {} | ||
|
||
async create(createEventDto: CreateEventDto): Promise<Event> { | ||
return await this.eventModel.create(createEventDto); | ||
} | ||
|
||
findAll(): Promise<Event[]> { | ||
return this.eventModel.find().exec(); | ||
} | ||
|
||
async findOne(eventId: string): Promise<Event> { | ||
return await this.eventModel.findById(eventId).exec(); | ||
} | ||
|
||
update(eventId: string, event: Event): Promise<Event> { | ||
return this.eventModel | ||
.findByIdAndUpdate(eventId, event, { new: true }) | ||
.exec(); | ||
} | ||
|
||
delete(eventId: string) { | ||
this.eventModel.findByIdAndDelete(eventId); | ||
} | ||
} |
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,29 +1,65 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
import { GroupService } from '../group/group.service'; | ||
import { CreateEventDto } from './dto/create-event.dto'; | ||
import { UpdateEventDto } from './dto/update-event.dto'; | ||
import { EventRepository } from './event.repository'; | ||
|
||
@Injectable() | ||
export class EventService { | ||
create(createEventDto: CreateEventDto) { | ||
return createEventDto; | ||
constructor( | ||
private readonly eventRepository: EventRepository, | ||
private readonly groupService: GroupService, | ||
) {} | ||
|
||
async create(groupId: string, createEventDto: CreateEventDto) { | ||
const createdEvent = await this.eventRepository.create(createEventDto); | ||
await this.groupService.addEvent(groupId, createdEvent.id); | ||
|
||
return createdEvent; | ||
} | ||
|
||
findAll() { | ||
return `This action returns all event`; | ||
async findAll(groupId: string) { | ||
const group = await this.groupService.findOne(groupId); | ||
|
||
const events = []; | ||
for (const eventId of group.events) { | ||
events.push(await this.eventRepository.findOne(eventId)); | ||
} | ||
|
||
return events; | ||
} | ||
|
||
findOne(groupId: string, eventId: string) { | ||
async findOne(groupId: string, eventId: string) { | ||
const group = await this.groupService.findOne(groupId); | ||
const event = await this.eventRepository.findOne(eventId); | ||
|
||
return { | ||
groupId, | ||
eventId, | ||
group, | ||
event, | ||
}; | ||
} | ||
|
||
update(eventId: number, updateEventDto: UpdateEventDto) { | ||
return `This action updates a #${eventId} event` + updateEventDto; | ||
async update( | ||
groupId: string, | ||
eventId: string, | ||
updateEventDto: UpdateEventDto, | ||
) { | ||
const group = await this.groupService.findOne(groupId); | ||
const event = await this.eventRepository.findOne(eventId); | ||
|
||
for (const key in updateEventDto) { | ||
event[key] = updateEventDto[key]; | ||
} | ||
await this.eventRepository.update(eventId, event); | ||
|
||
return { | ||
group, | ||
event, | ||
}; | ||
} | ||
|
||
remove(eventId: number) { | ||
return `This action removes a #${eventId} event`; | ||
async remove(groupId: string, eventId: string) { | ||
return await this.groupService.deleteEvent(groupId, eventId); | ||
} | ||
} |
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,10 @@ | ||
import { Document } from 'mongoose'; | ||
|
||
export interface Event extends Document { | ||
name: string; | ||
description: string; | ||
startDate: Date; | ||
endDate: Date; | ||
fee: number; | ||
attendees: string[]; | ||
} |
Oops, something went wrong.