Files
blog-frontEnd/src/app/utils/dataUtil.ts
2021-03-12 16:11:09 +08:00

28 lines
957 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {Observable, of} from 'rxjs';
import {PageList} from '../class/HttpReqAndResp';
/**
* 判断 一个Page<any>[] 中是否存在一条已查询的数据
*
* @param pageNum 页码
* @param pageSize 单页数量
* @param pageList 源数据
* @return 未查到null 查到:该条数据
*/
export function exist<T>(pageNum: number, pageSize: number, pageList: PageList<any>[]): Observable<PageList<T>> | null {
if (pageList === undefined || pageList == null || pageList.length === 0) {
return null;
}
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < pageList.length; i++) {
// eslint-disable-next-line eqeqeq
if (pageList[i].pageNum == pageNum && pageList[i].pageSize == pageSize) {
const ob: Observable<PageList<T>> = new Observable(o => {
o.next(pageList[i]);
o.complete();
});
}
}
return null;
}