|
@@ -1,7 +1,21 @@
|
|
|
import { BaseFilter } from '../../core/dto/base.filter';
|
|
import { BaseFilter } from '../../core/dto/base.filter';
|
|
|
import { ApiProperty } from '@nestjs/swagger';
|
|
import { ApiProperty } from '@nestjs/swagger';
|
|
|
|
|
+import { IsOptional } from 'class-validator';
|
|
|
|
|
+import { Like } from 'typeorm';
|
|
|
|
|
|
|
|
export class SearchCategoryFilter extends BaseFilter {
|
|
export class SearchCategoryFilter extends BaseFilter {
|
|
|
@ApiProperty()
|
|
@ApiProperty()
|
|
|
order = ['+order', '-createdTime'];
|
|
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;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|