feat: add query name filter to items
parent
55e89426d9
commit
8cfc003261
|
@ -23,6 +23,7 @@ export class BaseFilterDto implements BaseFilterEntity {
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
limit = 10;
|
limit = 10;
|
||||||
|
|
||||||
|
@ApiProperty({ type: String, required: false })
|
||||||
q: string;
|
q: string;
|
||||||
|
|
||||||
@ApiProperty({ type: ['string'], required: false })
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
|
|
@ -84,6 +84,12 @@ export class IndexItemManager extends BaseIndexManager<ItemEntity> {
|
||||||
setQueryFilter(
|
setQueryFilter(
|
||||||
queryBuilder: SelectQueryBuilder<ItemEntity>,
|
queryBuilder: SelectQueryBuilder<ItemEntity>,
|
||||||
): SelectQueryBuilder<ItemEntity> {
|
): SelectQueryBuilder<ItemEntity> {
|
||||||
|
if (this.filterParam.q) {
|
||||||
|
queryBuilder.andWhere(
|
||||||
|
`${this.tableName}.name ILIKE '%${this.filterParam.q}%'`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.filterParam.tenant_ids?.length) {
|
if (this.filterParam.tenant_ids?.length) {
|
||||||
queryBuilder.andWhere(`${this.tableName}.tenant_id In (:...tenantIds)`, {
|
queryBuilder.andWhere(`${this.tableName}.tenant_id In (:...tenantIds)`, {
|
||||||
tenantIds: this.filterParam.tenant_ids,
|
tenantIds: this.filterParam.tenant_ids,
|
||||||
|
|
Loading…
Reference in New Issue