-
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.
Merge pull request #60 from boostcampwm-2024/be-feat#59
[BE] 기수별 프로젝트 리스트 응답 API 구현
- Loading branch information
Showing
7 changed files
with
264 additions
and
138 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
6 changes: 6 additions & 0 deletions
6
backend/console-server/src/project/dto/find-by-generation-response.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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { IsNotEmpty } from 'class-validator'; | ||
|
||
export class FindByGenerationResponseDto { | ||
@IsNotEmpty() | ||
name: string; | ||
} |
9 changes: 9 additions & 0 deletions
9
backend/console-server/src/project/dto/find-by-generation.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { IsNotEmpty, IsNumber } from 'class-validator'; | ||
import { Type } from 'class-transformer'; | ||
|
||
export class FindByGenerationDto { | ||
@IsNotEmpty() | ||
@Type(() => Number) | ||
@IsNumber() | ||
generation: number; | ||
} |
25 changes: 14 additions & 11 deletions
25
backend/console-server/src/project/entities/project.entity.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,21 +1,24 @@ | ||
import { Entity, Unique } from 'typeorm'; | ||
import { Column, PrimaryGeneratedColumn } from 'typeorm'; | ||
|
||
@Entity('projects') | ||
@Entity('project') | ||
@Unique(['domain']) | ||
export class Project { | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column({ type: 'varchar', length: 255 }) | ||
name: string; | ||
@Column({ type: 'varchar', length: 255 }) | ||
name: string; | ||
|
||
@Column({ type: 'varchar', length: 255 }) | ||
ip: string; | ||
@Column({ type: 'varchar', length: 255 }) | ||
ip: string; | ||
|
||
@Column({ type: 'varchar', length: 255, unique: true }) | ||
domain: string; | ||
@Column({ type: 'varchar', length: 255, unique: true }) | ||
domain: string; | ||
|
||
@Column({ type: 'varchar', length: 255 }) | ||
email: string; | ||
@Column({ type: 'varchar', length: 255 }) | ||
email: string; | ||
|
||
@Column({ type: 'int' }) | ||
generation: 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,16 +1,23 @@ | ||
import { Controller, HttpCode, HttpStatus } from '@nestjs/common'; | ||
import { Controller, Get, HttpCode, HttpStatus, Param, Query } from '@nestjs/common'; | ||
import { Post } from '@nestjs/common'; | ||
import { Body } from '@nestjs/common'; | ||
import { ProjectService } from './project.service'; | ||
import { CreateProjectDto } from './dto/create-project.dto'; | ||
import { FindByGenerationDto } from './dto/find-by-generation.dto'; | ||
|
||
@Controller('project') | ||
export class ProjectController { | ||
constructor(private readonly projectService: ProjectService) {} | ||
constructor(private readonly projectService: ProjectService) {} | ||
|
||
@Post() | ||
@HttpCode(HttpStatus.CREATED) | ||
create(@Body() createProjectDto: CreateProjectDto) { | ||
return this.projectService.create(createProjectDto); | ||
} | ||
@Post() | ||
@HttpCode(HttpStatus.CREATED) | ||
create(@Body() createProjectDto: CreateProjectDto) { | ||
return this.projectService.create(createProjectDto); | ||
} | ||
|
||
@Get() | ||
@HttpCode(HttpStatus.OK) | ||
findByGeneration(@Query() findGenerationProjectDto: FindByGenerationDto) { | ||
return this.projectService.findByGeneration(findGenerationProjectDto); | ||
} | ||
} |
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.