From 6f1ab8e489e791734a2c63550b63ad1cb74b4f57 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Wed, 04 Jul 2018 17:19:29 +0800 Subject: [PATCH] 设备页面bug 修复 --- src/app/business/services/util/example.service.ts | 31 ++++++++++++++++++++++++------- 1 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/app/business/services/util/example.service.ts b/src/app/business/services/util/example.service.ts index e1427dd..fdcb472 100644 --- a/src/app/business/services/util/example.service.ts +++ b/src/app/business/services/util/example.service.ts @@ -8,16 +8,31 @@ return this.conditions; } - public addCondition(condition: string, colName:string, ...values: any[]){ + private addCondition(condition: string, colName: string, ...values: any[]) { const split = Criteria.CONDITION_SPLIT; // '||' - this.conditions.push(condition+split + colName + split + values.join(split)); + let conditionStr = condition + split + colName; + if (!!values && values.length > 0) { + conditionStr += split + values.join(split); + } + this.conditions.push(conditionStr); } - public andLike(col: { name: string, value: any}): Criteria{ + public andCondition(condition: string) { + this.addCondition('andCondition', condition); + } + public andLike(col: { name: string, value: any}): Criteria { this.addCondition('andLike', col.name, col.value); return this; } - public andEqualTo(col: { name: string, value: any}): Criteria{ + public andEqualTo(col: { name: string, value: any}): Criteria { this.addCondition('andEqualTo', col.name, col.value); + return this; + } + public andNotEqualTo(col: { name: string, value: any}): Criteria { + this.addCondition('andNotEqualTo', col.name, col.value); + return this; + } + public andGreaterThanOrEqualTo(col: { name: string, value: any}): Criteria { + this.addCondition('andGreaterThanOrEqualTo', col.name, col.value); return this; } } @@ -27,17 +42,19 @@ private static OR_SPLIT = 'or|'; private static CRITERIA_SPLIT = '|||'; private criterion: Criteria[] = []; - + public clear(): void { + this.criterion = []; + } public getSqlParam(): string { let whereSql = ''; - for (const cri of this.criterion){ + for (const cri of this.criterion) { const conditions = cri.getConditions(); whereSql += ExampleService.OR_SPLIT + conditions.join(ExampleService.CRITERIA_SPLIT); } return encodeURI(whereSql); } constructor() { } - public or() { + public or(): Criteria { const cri = new Criteria(); this.criterion.push(cri); return cri; -- Gitblit v1.8.0