forked from Yara724/api
fanavaran stage by stage implemented i am so bored to send smart commit sorry MR sina
This commit is contained in:
@@ -2,6 +2,7 @@ import { Injectable, Logger, NotFoundException } from "@nestjs/common";
|
||||
import { resolveFanavaranClientKey } from "src/core/config/fanavaran-client.config";
|
||||
import {
|
||||
FANAVARAN_REMOTE_LOOKUPS,
|
||||
type FanavaranRemoteLookupDefinition,
|
||||
TEJARAT_STATIC_ACCIDENT_FILES,
|
||||
} from "src/fanavaran/fanavaran-lookup.config";
|
||||
import { FanavaranLookupService } from "src/fanavaran/fanavaran-lookup.service";
|
||||
@@ -31,10 +32,14 @@ export class LookupsService {
|
||||
return resolveFanavaranClientKey();
|
||||
}
|
||||
|
||||
listFanavaranRemoteLookups(): FanavaranRemoteLookupDefinition[] {
|
||||
return FANAVARAN_REMOTE_LOOKUPS;
|
||||
}
|
||||
|
||||
private findRemoteLookup(name: string) {
|
||||
const lookup = FANAVARAN_REMOTE_LOOKUPS.find((item) => item.name === name);
|
||||
if (!lookup) {
|
||||
throw new Error(`Unknown Fanavaran remote lookup: ${name}`);
|
||||
throw new NotFoundException(`Unknown Fanavaran remote lookup: ${name}`);
|
||||
}
|
||||
return lookup;
|
||||
}
|
||||
@@ -52,7 +57,7 @@ export class LookupsService {
|
||||
return doc.response;
|
||||
}
|
||||
|
||||
private async getClientRemoteLookup(lookupName: string): Promise<unknown> {
|
||||
async getClientRemoteLookup(lookupName: string): Promise<unknown> {
|
||||
const clientKey = this.activeClientKey();
|
||||
const definition = this.findRemoteLookup(lookupName);
|
||||
|
||||
@@ -90,6 +95,26 @@ export class LookupsService {
|
||||
return await this.getClientRemoteLookup("accident-culprit-type");
|
||||
}
|
||||
|
||||
async getInspectionPlace(): Promise<any> {
|
||||
return await this.getClientRemoteLookup("inspection-place");
|
||||
}
|
||||
|
||||
async getDropAmountStatus(): Promise<any> {
|
||||
return await this.getClientRemoteLookup("drop-amount-status");
|
||||
}
|
||||
|
||||
async getCarComponents(): Promise<any> {
|
||||
return await this.getClientRemoteLookup("car-components");
|
||||
}
|
||||
|
||||
async getAccidentLevel(): Promise<any> {
|
||||
return await this.getClientRemoteLookup("accident-level");
|
||||
}
|
||||
|
||||
async getExpertStatus(): Promise<any> {
|
||||
return await this.getClientRemoteLookup("expert-status");
|
||||
}
|
||||
|
||||
async getAccidentWay(): Promise<{ id: number; label: string }[]> {
|
||||
const clientKey = this.activeClientKey();
|
||||
const fileName = TEJARAT_STATIC_ACCIDENT_FILES.accidentWay;
|
||||
@@ -129,10 +154,9 @@ export class LookupsService {
|
||||
|
||||
if (clientKey === "parsian") {
|
||||
const cacheFile = "accident-reason-options.json";
|
||||
const cached =
|
||||
await this.fanavaranLookupService.readCacheFile<
|
||||
{ id: number; label: string; fanavaran: number }[]
|
||||
>(clientKey, cacheFile);
|
||||
const cached = await this.fanavaranLookupService.readCacheFile<
|
||||
{ id: number; label: string; fanavaran: number }[]
|
||||
>(clientKey, cacheFile);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user