This commit is contained in:
ilhamtahir committed 2024-12-25 10:27:14 +08:00
1 parent 081b3a303d
commit 60df57ceb2
1 file changed
+14
+14
View File
@@ -1,7 +1,21 @@
import { BaseFilter } from '../../core/dto/base.filter';
import { ApiProperty } from '@nestjs/swagger';
import { IsOptional } from 'class-validator';
import { Like } from 'typeorm';
export class SearchCategoryFilter extends BaseFilter {
@ApiProperty()
order = ['+order', '-createdTime'];
@ApiProperty({ required: false, description: '分类名称检索', example: '猫' })
@IsOptional()
name?: string;
getConditions(): Record<string, any> {
const conditions: Record<string, any> = {};
if (this.name) {
conditions.name = Like(`%${this.name}%`); // 假设使用模糊查询
}
return conditions;
}
}