32 lines
791 B
TypeScript
32 lines
791 B
TypeScript
import { inject, injectable } from "tsyringe";
|
|
import { Location } from "../models/location";
|
|
import { LocationRepository } from "../repositories/locationRepository";
|
|
|
|
@injectable()
|
|
export class LocationService {
|
|
constructor(
|
|
@inject(LocationRepository)
|
|
private repository: LocationRepository
|
|
) {}
|
|
|
|
public async getAllLocations() {
|
|
return this.repository.findAll();
|
|
}
|
|
|
|
public async getLocationById(id: string) {
|
|
return this.repository.findById(id);
|
|
}
|
|
|
|
public async createLocation(data: Partial<Location>) {
|
|
return this.repository.create(data);
|
|
}
|
|
|
|
public async updateLocation(id: string, data: Partial<Location>) {
|
|
return this.repository.update(id, data);
|
|
}
|
|
|
|
public async deleteLocation(id: string) {
|
|
return this.repository.delete(id);
|
|
}
|
|
}
|