| | |
| | | return this.conditions; |
| | | } |
| | | |
| | | public addCondition(condition: string, colName:string, ...values: any[]){ |
| | | public addCondition(condition: string, colName: string, ...values: any[]) { |
| | | const split = Criteria.CONDITION_SPLIT; // '||' |
| | | this.conditions.push(condition+split + colName + split + values.join(split)); |
| | | this.conditions.push(condition + split + colName + split + values.join(split)); |
| | | } |
| | | public andLike(col: { name: string, value: any}): Criteria{ |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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); |
| | | } |