Skip to content

Commit 54a7c26

Browse files
committed
- feature: stopDto 에 lat, lng 추가
1 parent 0210aab commit 54a7c26

File tree

6 files changed

+23
-9
lines changed

6 files changed

+23
-9
lines changed

drizzle/schema/schema.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ CREATE TABLE "stops"
8080
"pk" uuid NOT NULL,
8181
"name_kor" varchar(127) NOT NULL,
8282
"name_eng" varchar(127) NOT NULL,
83+
"lat" double precision NOT NULL,
84+
"lng" double precision NOT NULL,
8385
"created_at" timestamp with time zone NOT NULL DEFAULT NOW(),
8486
"updated_at" timestamp with time zone NOT NULL DEFAULT NOW()
8587
);

drizzle/schema/stops.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { pgTable, timestamp, uuid, varchar } from "drizzle-orm/pg-core";
1+
import {
2+
doublePrecision,
3+
pgTable,
4+
timestamp,
5+
uuid,
6+
varchar,
7+
} from "drizzle-orm/pg-core";
28
import { relations } from "drizzle-orm";
39
import { route } from "./route";
410

@@ -7,6 +13,8 @@ CREATE TABLE "stops" (
713
"pk" uuid NOT NULL,
814
"name_kor" varchar(127) NOT NULL,
915
"name_eng" varchar(127) NOT NULL,
16+
"lat" double precision NOT NULL,
17+
"lng" double precision NOT NULL,
1018
"created_at" timestamp with time zone NOT NULL DEFAULT NOW(),
1119
"updated_at" timestamp with time zone NOT NULL DEFAULT NOW()
1220
);
@@ -15,6 +23,8 @@ export const stops = pgTable("stops", {
1523
pk: uuid("pk").primaryKey().notNull(),
1624
nameKor: varchar("name_kor", { length: 127 }).notNull(),
1725
nameEng: varchar("name_eng", { length: 127 }).notNull(),
26+
lat: doublePrecision("lat").notNull(),
27+
lng: doublePrecision("lng").notNull(),
1828
createdAt: timestamp("created_at", { withTimezone: true })
1929
.notNull()
2030
.defaultNow(),

src/database/entity/stops.entity.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ export class StopsEntity {
22
pk?: string;
33
nameKor: string;
44
nameEng: string;
5+
lat: number;
6+
lng: number;
57
createdAt?: Date;
68
updatedAt?: Date;
79
}

src/database/repository/stops.repository.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export class StopsRepository {
2121
pk: result.pk,
2222
nameKor: result.nameKor,
2323
nameEng: result.nameEng,
24+
lat: result.lat,
25+
lng: result.lng,
2426
createdAt: result.createdAt,
2527
updatedAt: result.updatedAt,
2628
};

src/discovery/dto/stop.dto.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export class StopDto {
22
id: string;
33
name: string;
4+
lat: number;
5+
lng: number;
46
}

src/discovery/route.service.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,17 @@ export class RouteService implements OnModuleInit {
4040
routeEntityToDto(route: RouteEntity): RouteDto {
4141
return {
4242
id: route.pk,
43-
from: {
44-
id: route.fromStopFk,
45-
name: route.fromStop.nameKor,
46-
},
47-
to: {
48-
id: route.toStopFk,
49-
name: route.toStop.nameKor,
50-
},
43+
from: this.stopEntityToDto(route.fromStop),
44+
to: this.stopEntityToDto(route.toStop),
5145
};
5246
}
5347

5448
stopEntityToDto(stops: StopsEntity): StopDto {
5549
return {
5650
id: stops.pk,
5751
name: stops.nameKor,
52+
lat: stops.lat,
53+
lng: stops.lng,
5854
};
5955
}
6056
}

0 commit comments

Comments
 (0)