|
|
|
@ -8,52 +8,35 @@ import { catchError, retry } from 'rxjs/operators';
|
|
|
|
|
}) |
|
|
|
|
export class BuildingBasicInfosService { |
|
|
|
|
|
|
|
|
|
readonly c_get = "/Get"; |
|
|
|
|
readonly c_post = "/PostOrPut"; |
|
|
|
|
constructor( |
|
|
|
|
private http: HttpClient |
|
|
|
|
) { } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 通用消息头 |
|
|
|
|
* 单位信息的api [获取/保存] |
|
|
|
|
*/ |
|
|
|
|
headers = { |
|
|
|
|
"Content-Type": "application/json" |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
//获取单位信息的api
|
|
|
|
|
baseUrl = 'api/Services/3D/BuildingBasicInfo'; |
|
|
|
|
readonly api_buildingInfo = 'api/Services/3D/BuildingBasicInfo'; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 事态标绘(电子沙盘)的api |
|
|
|
|
* 事态标绘(电子沙盘)的api [获取/保存] |
|
|
|
|
*/ |
|
|
|
|
markUrl = "api/Services/3D/Sandboxie"; |
|
|
|
|
|
|
|
|
|
readonly api_sandBox = "api/Services/3D/Sandboxie"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor( |
|
|
|
|
private http: HttpClient |
|
|
|
|
) { } |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取三维信息 |
|
|
|
|
*/ |
|
|
|
|
getBuildingBasicInfos(name: string): Observable<string> { |
|
|
|
|
return this.http.get<string>(this.baseUrl + this.c_get + '?name=' + name); |
|
|
|
|
return this.getInfos(this.api_buildingInfo, 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)) |
|
|
|
|
); |
|
|
|
|
postBuildingBasicInfos(name: string, data: object): Observable<any> { |
|
|
|
|
return this.postInfos(this.api_buildingInfo, name, data); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -61,29 +44,69 @@ export class BuildingBasicInfosService {
|
|
|
|
|
* @param name
|
|
|
|
|
*/ |
|
|
|
|
getMarkData(name: string): Observable<string> { |
|
|
|
|
// name = "bb";
|
|
|
|
|
return this.getInfos(this.api_sandBox, name); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 推送事态标绘的信息 |
|
|
|
|
* @param name
|
|
|
|
|
* @param data
|
|
|
|
|
*/ |
|
|
|
|
postMarkData(name: string, data: object): Observable<any> { |
|
|
|
|
return this.postInfos(this.api_sandBox, name, data); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//#region 通用封装,新增api时调用即可,不需关心具体组装规则。若修改规则,只需修改此通用封装
|
|
|
|
|
/** |
|
|
|
|
* get类api所需的固定内容 |
|
|
|
|
*/ |
|
|
|
|
readonly c_get = "/Get"; |
|
|
|
|
/** |
|
|
|
|
* post类api所需的固定内容 |
|
|
|
|
*/ |
|
|
|
|
readonly c_post = "/PostOrPut"; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 通用消息头 |
|
|
|
|
*/ |
|
|
|
|
readonly headers = { |
|
|
|
|
"Content-Type": "application/json" |
|
|
|
|
}; |
|
|
|
|
/** |
|
|
|
|
* 通用get 类api的封装 |
|
|
|
|
* @param api
|
|
|
|
|
* @param name
|
|
|
|
|
*/ |
|
|
|
|
getInfos(api: string, name: string) { |
|
|
|
|
let id = { "name": name }; |
|
|
|
|
return this.http.get<string>(this.markUrl + this.c_get, { params: id }).pipe( //'?name='
|
|
|
|
|
|
|
|
|
|
return this.http.get<string>(api + this.c_get, { params: id }).pipe( |
|
|
|
|
catchError((err) => this.handleError(err)) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 推送事态标绘的信息 |
|
|
|
|
* 通用post 类api的封装 |
|
|
|
|
* @param api
|
|
|
|
|
* @param name
|
|
|
|
|
* @param data
|
|
|
|
|
*/ |
|
|
|
|
postMarkData(name: string, data: any): Observable<any> { |
|
|
|
|
postInfos(api: string, name: string, data: object) { |
|
|
|
|
let params = { |
|
|
|
|
name: name, |
|
|
|
|
//content: JSON.stringify(data),
|
|
|
|
|
} |
|
|
|
|
return this.http.post<any>(this.markUrl + this.c_post, JSON.stringify(data), { params }) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
let headers = this.headers; |
|
|
|
|
|
|
|
|
|
return this.http.post<any>(api + this.c_post, `'${JSON.stringify(data)}'`, { headers, params }) |
|
|
|
|
.pipe( |
|
|
|
|
catchError((err) => this.handleError(err)) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
//#region 错误捕捉
|
|
|
|
|
|
|
|
|
|
private handleError(error: HttpErrorResponse) { |
|
|
|
|
if (error.error instanceof ErrorEvent) { |
|
|
|
@ -106,11 +129,5 @@ export class BuildingBasicInfosService {
|
|
|
|
|
return throwError( |
|
|
|
|
error); |
|
|
|
|
} |
|
|
|
|
//#endregion
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 服务器返回的结果 |
|
|
|
|
*/ |
|
|
|
|
class HttpResult { |
|
|
|
|
|
|
|
|
|
} |