Skip to content

Commit

Permalink
Merge pull request #191 from boostcampwm-2024/feature-be-#190
Browse files Browse the repository at this point in the history
엣지 API, DB 스키마 업데이트
  • Loading branch information
ezcolin2 authored Nov 18, 2024
2 parents 773d59b + ce2ac9b commit 93fe456
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ lerna-debug.log*
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
backend/db.sqlite
apps/backend/db.sqlite
21 changes: 1 addition & 20 deletions apps/backend/src/edge/dtos/createEdge.dto.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsString, IsNumber, IsIn } from 'class-validator';
// import { Direction } from '../edge.entity';

const Direction = ['N', 'S', 'E', 'W'];
import { IsNumber } from 'class-validator';

export class CreateEdgeDto {
@IsNumber()
Expand All @@ -12,26 +9,10 @@ export class CreateEdgeDto {
})
fromNode: number;

@IsString()
@IsIn(Direction)
@ApiProperty({
example: 'N',
description: '출발 노드 지점 방향 (N, S, E, W 중 하나)',
})
fromPoint: string;

@IsNumber()
@ApiProperty({
example: 1,
description: '도착 노드의 ID',
})
toNode: number;

@IsString()
@IsIn(Direction)
@ApiProperty({
example: 'N',
description: '도착 노드 지점 방향 (N, S, E, W 중 하나)',
})
toPoint: string;
}
2 changes: 0 additions & 2 deletions apps/backend/src/edge/dtos/findEdgesResponse.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ export class FindEdgesResponseDto {
{
id: 1,
fromNode: 2,
fromPoint: 'N',
toNode: 7,
toPoint: 'W',
},
],
description: '모든 Edge 배열',
Expand Down
14 changes: 0 additions & 14 deletions apps/backend/src/edge/edge.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ import {
} from 'typeorm';
import { Node } from '../node/node.entity';

// TODO: frontend, backend가 공유하는 shared에 direction.enum.ts로 분리
// export enum Direction {
// NORTH = 'N',
// SOUTH = 'S',
// EAST = 'E',
// WEST = 'W',
// }

@Entity()
export class Edge {
@PrimaryGeneratedColumn('increment')
Expand All @@ -29,12 +21,6 @@ export class Edge {
@JoinColumn({ name: 'to_node_id' })
toNode: Node;

@Column()
fromPoint: string;

@Column()
toPoint: string;

@Column({ nullable: true })
type: string;

Expand Down
6 changes: 1 addition & 5 deletions apps/backend/src/edge/edge.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class EdgeService {
) {}

async createEdge(dto: CreateEdgeDto): Promise<Edge> {
const { fromNode, fromPoint, toNode, toPoint } = dto;
const { fromNode, toNode } = dto;

// 출발 노드를 조회한다.
const existingFromNode = await this.nodeRepository.findOneBy({
Expand All @@ -25,9 +25,7 @@ export class EdgeService {
// 엣지를 생성한다.
return await this.edgeRepository.save({
fromNode: existingFromNode,
fromPoint,
toNode: existingToNode,
toPoint,
});
}

Expand All @@ -50,11 +48,9 @@ export class EdgeService {
fromNode: {
id: true,
},
fromPoint: true,
toNode: {
id: true,
},
toPoint: true,
},
});
// 엣지가 없으면 NotFound 에러
Expand Down

0 comments on commit 93fe456

Please sign in to comment.