AW-803 Add CodeListItem + service.
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good

This commit is contained in:
Peter (extern) 2020-01-21 14:52:36 +01:00
parent 3dca804acd
commit e8845a092a
2 changed files with 54 additions and 0 deletions

View 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() {
}
}

View 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 });
}
}