From db5bf3bae094d8ae2cc66e68c2a48f5332f651f6 Mon Sep 17 00:00:00 2001 From: opbnq-q Date: Sun, 16 Mar 2025 11:07:20 +0700 Subject: [PATCH] fix: sorting --- generation/templates/service.tmpl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/generation/templates/service.tmpl b/generation/templates/service.tmpl index 513d77e..96ab790 100644 --- a/generation/templates/service.tmpl +++ b/generation/templates/service.tmpl @@ -33,7 +33,17 @@ export default class {{.ModelName}}Service implements IService<{{.ModelName}}> { return await SearchByAllTextFields(input) as {{ .ModelName }}[] } - async sort(options: SortOptions<{{ .ModelName }}>) { - return await SortedByOrder(Object.entries(options).map(item => ({Name: item[0], Order: item[1]}))) as {{ .ModelName }}[] - } + async sort(options: SortOptions) { + return (await SortedByOrder( + Object.entries(options).map((item) => { + if (item[1] !== 'NONE') { + return ({ + Name: item[0], + Order: item[1], + }) + } + }).filter(item => !!item) + )) as Task[]; + } +} } \ No newline at end of file