Bài tập nhóm: Thực hiện module đặt xe từ hệ thống tổng đài theo mô tả bên dưới
- Chọn loại topology theo kiến trúc Event-Driven : Mediator/Broker
- Vẽ flow tương ứng với loại Topology đã chọn tương ứng với đặc tả
- Code theo đặc tả
- Deadline : 16/08/2023-Nộp trên moodle
├── reception-service (S1)
├── location-service (S2)
├── booking-service (S3)
├── client
├── doc (tài liệu)
├── docker (file docker compose)
└── README.md
- Đã tải Docker, Docker Desktop, Docker Compose
- Kiểm tra bằng cách gõ cmd (này check các images có trong docker)
docker images
- Nếu có lỗi thì có thể cần chạy docker trước (khởi động Docker Desktop)
- Gõ lệnh cmd tại thư mục gốc để bulild (tải image, chuẩn bị container,...)
docker compose build
- Gõ lệnh cmd để chạy (có thể thêm -d ở cuối để chạy background)
docker compose up -d
- Theo dõi docker container tại Docker Desktop (xem log)
- Đợi một chút cho toàn bộ container chạy thì vào
http:\\localhost:4000
để truy cập giao diện tổng đài
- Thay đổi map service plugin tại GeoModule ở location-service/src/geocoding/geocoding.module.ts
{
provide: 'MAP_SERVICE',
inject: [HttpService, ConfigService],
useFactory: (
httpService: HttpService,
configService: ConfigService,
): MapService => {
// thay đổi map service plugin tại đây bằng lớp map service phù hợp
return new GoongService(httpService, configService);
},
},
- Dễ dàng tạo thêm plugin map service bằng cách kế thừa MapService
import { HttpService } from '@nestjs/axios';
import { ConfigService } from '@nestjs/config';
export class Coordinates {
lat: number;
long: number;
}
export class MapData {
place_id: string;
address: string;
}
export class MapDataDetail extends MapData {
coordinates: Coordinates;
}
export abstract class MapService {
abstract host: string;
protected httpService: HttpService;
protected configService: ConfigService;
constructor(httpService: HttpService, configService: ConfigService) {
this.httpService = httpService;
this.configService = configService;
}
abstract geocoding(address: string): Promise<MapData[]>;
abstract getPlaceDetail(placeId: string): Promise<MapDataDetail>;
}