| import { _HttpClient } from '@delon/theme'; | 
| import { environment } from 'environments/environment'; | 
| import { Injectable } from '@angular/core'; | 
| import { ResultBean, PageBean } from '@business/entity/grid'; | 
| import { Observable } from 'rxjs/Observable'; | 
| import { ExampleService } from '@business/services/util/example.service'; | 
| import { Device } from '@business/entity/data'; | 
|   | 
| @Injectable() | 
| export class DeviceService { | 
|   private urls = { | 
|     list: environment.SERVER_BASH_URL + 'device/page-list', | 
|     save: environment.SERVER_BASH_URL + 'device/add-or-modify', | 
|     delete: environment.SERVER_BASH_URL + 'device/delete-by-ids' | 
|   }; | 
|   public getListUrl () { | 
|     return this.urls.list; | 
|   } | 
|   public getSqlParams(queryText: string) { | 
|     const example = new ExampleService(); | 
|     if (queryText != null && queryText !== '') { | 
|       example.or().andLike({name: 'name', value: '%' + queryText + '%'}); | 
|       example.or().andLike({name: 'mac', value: '%' + queryText + '%'}); | 
|     } | 
|     return example.getSqlParam(); | 
|   } | 
|   constructor(private http: _HttpClient) { } | 
|   delete(...ids: number[]): Observable< ResultBean<any> > { | 
|       return this.http.post(this.urls.delete, ids); | 
|   } | 
|   public save(data: Device): Observable<any> { | 
|     return this.http.post(this.urls.save, data); | 
|   } | 
|   public getPageByExample(page: PageBean, example: ExampleService): Observable<PageBean> { | 
|     let orderByClause = ''; | 
|     const _queryParams = !!example ? example.getSqlParam() : ''; | 
|     if (!!page) { | 
|        if ( page.getOrderByClause != null && page.getOrderByClause instanceof Function) { | 
|           orderByClause = page.getOrderByClause(); | 
|           } | 
|     } else { | 
|           page =  {pageIndex: 0, pageSize: 20}; | 
|     } | 
|     const param: PageBean = {pageSize: page.pageSize, pageIndex: page.pageIndex,  | 
|         queryParams: _queryParams, orderByClause: orderByClause}; | 
|         return this.http.get(this.urls.list, param); | 
|  } | 
| } |