diff --git a/README.md b/README.md index 32704f6..cec1a69 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## Install ```shell -go install git.gogacoder.ru/NTO/crudgen/cmd/crudgen@1.0.11 +go install git.gogacoder.ru/NTO/crudgen/cmd/crudgen@1.0.12 ``` ## Run diff --git a/internal/raw_templates.go b/internal/raw_templates.go index 5df1f7a..a04cd42 100644 --- a/internal/raw_templates.go +++ b/internal/raw_templates.go @@ -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} diff --git a/internal/writer.go b/internal/writer.go index 7ce8cad..3fe4a9f 100644 --- a/internal/writer.go +++ b/internal/writer.go @@ -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)