diff --git a/internal/raw_templates.go b/internal/raw_templates.go index 64503f6..5df1f7a 100644 --- a/internal/raw_templates.go +++ b/internal/raw_templates.go @@ -54,3 +54,7 @@ const CountRawTemplate = `func (service *{{.ServiceName}}) Count() (int64, error amount, err := dal.{{.EntityType}}.Count() return amount, err }` + +const SortedByOrderTemplate = `func (service *{{.ServiceName}}) SortedByOrder(fieldsSortOrder map[string]string) ([]*{{.EntityType}}, error) { + return utils.SortByOrder(fieldsSortOrder, {{.EntityType}}{}) +}` diff --git a/internal/templates.go b/internal/templates.go index cc56197..c7a15c5 100644 --- a/internal/templates.go +++ b/internal/templates.go @@ -22,12 +22,14 @@ const GetByIdMethod = "GetById" const UpdateMethod = "Update" const DeleteMethod = "Delete" const CountMethod = "Count" +const SortedByOrderMethod = "SortedByOrder" var RawTemplates = map[string]string{ - CreateMethod: CreateRawTemplate, - GetAllMethod: GetAllRawTemplate, - GetByIdMethod: GetByIdRawTemplate, - UpdateMethod: UpdateRawTemplate, - DeleteMethod: DeleteRawTemplate, - CountMethod: CountRawTemplate, + CreateMethod: CreateRawTemplate, + GetAllMethod: GetAllRawTemplate, + GetByIdMethod: GetByIdRawTemplate, + UpdateMethod: UpdateRawTemplate, + DeleteMethod: DeleteRawTemplate, + CountMethod: CountRawTemplate, + SortedByOrderMethod: SortedByOrderTemplate, }