app-define.service.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { HttpClient, HttpParams } from '@angular/common/http';
  2. import { Injectable } from '@angular/core';
  3. import { Observable } from 'rxjs';
  4. import { Message } from '../pojo/Message';
  5. import { ParamDefine } from '../pojo/ParamDefine';
  6. const app_hierarchy = '/apps/hierarchy';
  7. @Injectable({
  8. providedIn: 'root'
  9. })
  10. export class AppDefineService {
  11. constructor(private http: HttpClient) {}
  12. public getAppParamsDefine(app: string | undefined | null): Observable<Message<ParamDefine[]>> {
  13. if (app === null || app === undefined) {
  14. console.log('getAppParamsDefine app can not null');
  15. }
  16. const paramDefineUri = `/apps/${app}/params`;
  17. return this.http.get<Message<ParamDefine[]>>(paramDefineUri);
  18. }
  19. public getAppDefine(app: string | undefined | null): Observable<Message<any>> {
  20. if (app === null || app === undefined) {
  21. console.log('getAppDefine app can not null');
  22. }
  23. return this.http.get<Message<any>>(`/apps/${app}/define`);
  24. }
  25. public getAppHierarchy(): Observable<Message<any>> {
  26. let httpParams = new HttpParams().append('lang', 'zh-CN');
  27. const options = { params: httpParams };
  28. return this.http.get<Message<any>>(app_hierarchy, options);
  29. }
  30. }