Skip to content

Commit 93fe456

Browse files
authored
Merge pull request #191 from boostcampwm-2024/feature-be-#190
엣지 API, DB 스키마 업데이트
2 parents 773d59b + ce2ac9b commit 93fe456

File tree

5 files changed

+3
-42
lines changed

5 files changed

+3
-42
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ lerna-debug.log*
4848
!.vscode/tasks.json
4949
!.vscode/launch.json
5050
!.vscode/extensions.json
51-
backend/db.sqlite
51+
apps/backend/db.sqlite
Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import { ApiProperty } from '@nestjs/swagger';
2-
import { IsString, IsNumber, IsIn } from 'class-validator';
3-
// import { Direction } from '../edge.entity';
4-
5-
const Direction = ['N', 'S', 'E', 'W'];
2+
import { IsNumber } from 'class-validator';
63

74
export class CreateEdgeDto {
85
@IsNumber()
@@ -12,26 +9,10 @@ export class CreateEdgeDto {
129
})
1310
fromNode: number;
1411

15-
@IsString()
16-
@IsIn(Direction)
17-
@ApiProperty({
18-
example: 'N',
19-
description: '출발 노드 지점 방향 (N, S, E, W 중 하나)',
20-
})
21-
fromPoint: string;
22-
2312
@IsNumber()
2413
@ApiProperty({
2514
example: 1,
2615
description: '도착 노드의 ID',
2716
})
2817
toNode: number;
29-
30-
@IsString()
31-
@IsIn(Direction)
32-
@ApiProperty({
33-
example: 'N',
34-
description: '도착 노드 지점 방향 (N, S, E, W 중 하나)',
35-
})
36-
toPoint: string;
3718
}

apps/backend/src/edge/dtos/findEdgesResponse.dto.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ export class FindEdgesResponseDto {
1515
{
1616
id: 1,
1717
fromNode: 2,
18-
fromPoint: 'N',
1918
toNode: 7,
20-
toPoint: 'W',
2119
},
2220
],
2321
description: '모든 Edge 배열',

apps/backend/src/edge/edge.entity.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ import {
88
} from 'typeorm';
99
import { Node } from '../node/node.entity';
1010

11-
// TODO: frontend, backend가 공유하는 shared에 direction.enum.ts로 분리
12-
// export enum Direction {
13-
// NORTH = 'N',
14-
// SOUTH = 'S',
15-
// EAST = 'E',
16-
// WEST = 'W',
17-
// }
18-
1911
@Entity()
2012
export class Edge {
2113
@PrimaryGeneratedColumn('increment')
@@ -29,12 +21,6 @@ export class Edge {
2921
@JoinColumn({ name: 'to_node_id' })
3022
toNode: Node;
3123

32-
@Column()
33-
fromPoint: string;
34-
35-
@Column()
36-
toPoint: string;
37-
3824
@Column({ nullable: true })
3925
type: string;
4026

apps/backend/src/edge/edge.service.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class EdgeService {
1313
) {}
1414

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

1818
// 출발 노드를 조회한다.
1919
const existingFromNode = await this.nodeRepository.findOneBy({
@@ -25,9 +25,7 @@ export class EdgeService {
2525
// 엣지를 생성한다.
2626
return await this.edgeRepository.save({
2727
fromNode: existingFromNode,
28-
fromPoint,
2928
toNode: existingToNode,
30-
toPoint,
3129
});
3230
}
3331

@@ -50,11 +48,9 @@ export class EdgeService {
5048
fromNode: {
5149
id: true,
5250
},
53-
fromPoint: true,
5451
toNode: {
5552
id: true,
5653
},
57-
toPoint: true,
5854
},
5955
});
6056
// 엣지가 없으면 NotFound 에러

0 commit comments

Comments
 (0)