AW-803 Add CodeListItem + service.
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
This commit is contained in:
parent
3dca804acd
commit
e8845a092a
28
projects/common/src/fm/models/code.list.item.ts
Normal file
28
projects/common/src/fm/models/code.list.item.ts
Normal file
@ -0,0 +1,28 @@
|
||||
export interface ICodeListItem {
|
||||
codelist: string;
|
||||
code: string;
|
||||
codeGroup?: string;
|
||||
unit?: string;
|
||||
description?: string;
|
||||
validFrom?: Date;
|
||||
validTo?: Date;
|
||||
created?: Date;
|
||||
updated?: Date;
|
||||
data?:any
|
||||
}
|
||||
|
||||
export class CodeListItem implements ICodeListItem {
|
||||
public codelist: string;
|
||||
public code: string;
|
||||
public codeGroup?: string;
|
||||
public unit?: string;
|
||||
public description:string;
|
||||
public validFrom?: Date;
|
||||
public validTo?: Date;
|
||||
public created?: Date;
|
||||
public updated?: Date;
|
||||
public data?:any;
|
||||
|
||||
constructor() {
|
||||
}
|
||||
}
|
26
projects/common/src/fm/services/codelistitem.service.ts
Normal file
26
projects/common/src/fm/services/codelistitem.service.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { HttpClient, HttpParams } from "@angular/common/http";
|
||||
import { AppConfig } from "../shared/app.config";
|
||||
import { ICodeListItem } from '../models/code.list.item';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CodeListItemService {
|
||||
constructor(public httpClient: HttpClient, public appConfig: AppConfig) {
|
||||
}
|
||||
|
||||
ApiEndpoint() {
|
||||
return this.appConfig.getConfig("apiEndPoint");
|
||||
}
|
||||
|
||||
getCodeListItems(codelist: string[], codegroup?: string, dataFilter?: any, onlyBetweenValidFromAndTo: boolean = true): Observable<ICodeListItem[]> {
|
||||
var params = new HttpParams();
|
||||
params = params.append("cl", codelist.join(","));
|
||||
if (codegroup) params = params.append("g", codegroup);
|
||||
if (onlyBetweenValidFromAndTo) params = params.append("v", onlyBetweenValidFromAndTo);
|
||||
if (dataFilter) params = params.append("df", dataFilter);
|
||||
return this.httpClient.get<ICodeListItem>(`${this.ApiEndpoint()}/api/v1/codelistitems/`, { params: params });
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user