mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 07:10:57 +00:00
Project Initialization
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
import { TrackingEvent } from './entities/tracking-event.entity';
|
||||
|
||||
@Injectable()
|
||||
export class TrackingService {
|
||||
constructor(
|
||||
@InjectRepository(TrackingEvent)
|
||||
private readonly trackingRepository: Repository<TrackingEvent>,
|
||||
) {}
|
||||
|
||||
/** Get the full timeline of tracking events for a consignment. */
|
||||
findByConsignment(consignmentId: string): Promise<TrackingEvent[]> {
|
||||
return this.trackingRepository.find({
|
||||
where: { consignmentId },
|
||||
order: { occurredAt: 'ASC' },
|
||||
});
|
||||
}
|
||||
|
||||
/** Record a new tracking event for a consignment. */
|
||||
record(event: Partial<TrackingEvent>): Promise<TrackingEvent> {
|
||||
const entity = this.trackingRepository.create(event);
|
||||
return this.trackingRepository.save(entity);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user