中化加油站项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
2.7 KiB

import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, throwError } from 'rxjs';
import { catchError, retry } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class BuildingBasicInfosService {
4 years ago
readonly c_get = "/Get";
readonly c_post = "/PostOrPut";
/**
*
*/
headers = {
"Content-Type": "application/json"
};
//获取单位信息的api
4 years ago
baseUrl = 'api/Services/3D/BuildingBasicInfo';
/**
* ()api
*/
4 years ago
markUrl = "api/Services/3D/Sandboxie";
constructor(
private http: HttpClient
) { }
/**
*
*/
getBuildingBasicInfos(name: string): Observable<string> {
4 years ago
return this.http.get<string>(this.baseUrl + this.c_get + '?name=' + name);
}
/**
*
* @param name
* @param data
*/
postBuildingBasicInfos(name: string, data: any): Observable<any> {
let params = {
name: name,
}
let instance = this;
return this.http.post<any>(this.baseUrl + this.c_post, `'${JSON.stringify(data)}'`, { instance.headers, params })
.pipe(
catchError((err) => this.handleError(err))
);
}
/**
*
* @param name
*/
getMarkData(name: string): Observable<string> {
// name = "bb";
let id = { "name": name };
4 years ago
return this.http.get<string>(this.markUrl + this.c_get, { params: id }).pipe( //'?name='
catchError((err) => this.handleError(err))
);
}
/**
*
* @param name
* @param data
*/
postMarkData(name: string, data: any): Observable<any> {
4 years ago
let params = {
name: name,
//content: JSON.stringify(data),
4 years ago
}
return this.http.post<any>(this.markUrl + this.c_post, JSON.stringify(data), { params })
.pipe(
catchError((err) => this.handleError(err))
);
}
private handleError(error: HttpErrorResponse) {
if (error.error instanceof ErrorEvent) {
// A client-side or network error occurred. Handle it accordingly.
console.error('An error occurred:', error.error.message);
} else {
// The backend returned an unsuccessful response code.
// The response body may contain clues as to what went wrong.
if (error.status == 404) {
console.log("404===" + error.error);
}
else {
console.error(
error + `Backend returned code ${error.status}, ` +
`body was: ${error.error}`);
}
}
// Return an observable with a user-facing error message.
return throwError(
error);
}
}
4 years ago
/**
*
*/
class HttpResult {
}