new song sync
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
import { ODataService, ODataQuery } from "odata-v4-ng";
|
||||
import { Observable } from "rxjs";
|
||||
import { map, tap } from "rxjs/operators";
|
||||
import { base } from "./urls";
|
||||
import { Song } from 'src/app/models/song.model';
|
||||
import { ODataService, ODataQuery } from 'odata-v4-ng';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
import { base } from './urls';
|
||||
|
||||
export class OdataService {
|
||||
private url: string;
|
||||
constructor(private odataService: ODataService, private entity: string) {
|
||||
this.url = base + "/odata/";
|
||||
this.url = base + '/odata/';
|
||||
}
|
||||
|
||||
public list<TResponse>(properties: string[]): Observable<TResponse[]> {
|
||||
public list$<TResponse>(properties: string[]): Observable<TResponse[]> {
|
||||
const query = new ODataQuery(this.odataService, this.url)
|
||||
.entitySet(this.entity)
|
||||
.select(properties);
|
||||
@@ -18,7 +19,7 @@ export class OdataService {
|
||||
return get;
|
||||
}
|
||||
|
||||
public get<TResponse>(
|
||||
public get$<TResponse>(
|
||||
id: number,
|
||||
properties: string[]
|
||||
): Observable<TResponse> {
|
||||
@@ -31,15 +32,30 @@ export class OdataService {
|
||||
return get;
|
||||
}
|
||||
|
||||
public patch(id: number, control: string, value: any): Observable<boolean> {
|
||||
public patch$(id: number, control: string, value: any): Observable<boolean> {
|
||||
const valueSet = { [control]: value };
|
||||
const query = new ODataQuery(this.odataService, this.url)
|
||||
.entitySet(this.entity)
|
||||
.entityKey(id);
|
||||
const get = query.patch(valueSet).pipe(
|
||||
map(() => true)
|
||||
);
|
||||
const get = query.patch(valueSet).pipe(map(() => true));
|
||||
|
||||
return get;
|
||||
}
|
||||
|
||||
public post$<TResponse>(values: any): Observable<TResponse> {
|
||||
const querry = new ODataQuery(this.odataService, this.url);
|
||||
const post = querry
|
||||
.entitySet(this.entity)
|
||||
.post(values)
|
||||
.pipe(
|
||||
tap(_ => console.log(_)),
|
||||
map(_ => {
|
||||
const mapped = _.toEntity<TResponse>();
|
||||
return mapped;
|
||||
}),
|
||||
tap(_ => console.log(_))
|
||||
);
|
||||
|
||||
return post;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user