fix: sorting method generation

This commit is contained in:
2025-03-12 16:08:36 +07:00
parent 51d8531792
commit 31c5c49589
3 changed files with 4 additions and 2 deletions

View File

@@ -58,3 +58,5 @@ const CountRawTemplate = `func (service *{{.ServiceName}}) Count() (int64, error
const SortedByOrderTemplate = `func (service *{{.ServiceName}}) SortedByOrder(fieldsSortOrder map[string]string) ([]*{{.EntityType}}, error) {
return utils.SortByOrder(fieldsSortOrder, {{.EntityType}}{})
}`
var implementedMethods = []string{CreateMethod, GetAllMethod, GetByIdMethod, UpdateMethod, DeleteMethod, CountMethod, SortedByOrderMethod}

View File

@@ -244,7 +244,7 @@ func ImplementCrudMethods(modelName string, serviceName string, file *dst.File,
EntityPlural: ToPlural(modelName),
}
for _, methodName := range []string{CreateMethod, GetAllMethod, GetByIdMethod, UpdateMethod, DeleteMethod, CountMethod} {
for _, methodName := range implementedMethods {
methodCode := GenerateCrudMethodCode(methodName, templateContext)
methodDecl, err := MethodCodeToDeclaration(methodCode)
fmt.Printf("%s\n", methodCode)