260324:2133 Refactor correspondence & rfa
This commit is contained in:
@@ -10,6 +10,10 @@ export class SearchQueryDto {
|
||||
@IsOptional()
|
||||
type?: string; // กรองประเภท: 'rfa', 'correspondence', 'drawing'
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
status?: string; // กรองสถานะ: 'DRAFT', 'SUBOWN', 'CLBOWN', 'CANCELLED', ...
|
||||
|
||||
@IsInt()
|
||||
@Type(() => Number)
|
||||
@IsOptional()
|
||||
|
||||
@@ -108,7 +108,7 @@ export class SearchService implements OnModuleInit {
|
||||
* ค้นหาเอกสาร (Full-text Search)
|
||||
*/
|
||||
async search(queryDto: SearchQueryDto) {
|
||||
const { q, type, projectId, page = 1, limit = 20 } = queryDto;
|
||||
const { q, type, status, projectId, page = 1, limit = 20 } = queryDto;
|
||||
const from = (page - 1) * limit;
|
||||
|
||||
// Early fallback if Elasticsearch is not available
|
||||
@@ -135,6 +135,7 @@ export class SearchService implements OnModuleInit {
|
||||
// 2. Filter logic
|
||||
const filterQueries: Record<string, unknown>[] = [];
|
||||
if (type) filterQueries.push({ term: { type } });
|
||||
if (status) filterQueries.push({ term: { status } });
|
||||
if (projectId) filterQueries.push({ term: { projectId } });
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user