diff --git a/crm/_gen.php b/crm/_gen.php old mode 100755 new mode 100644 index 0e8bf795f..07cab9f81 --- a/crm/_gen.php +++ b/crm/_gen.php @@ -80,5 +80,3 @@ foreach (array("routes") as $type) { file_put_contents($filename, $contents); } - -passthru("go fmt"); \ No newline at end of file diff --git a/crm/_gen.sh b/crm/_gen.sh new file mode 100755 index 000000000..37c7c1cdd --- /dev/null +++ b/crm/_gen.sh @@ -0,0 +1,2 @@ +/usr/bin/env php _gen.php +go fmt \ No newline at end of file diff --git a/crm/module.go b/crm/module.go index 4aa04fd2e..56dfb8aa0 100644 --- a/crm/module.go +++ b/crm/module.go @@ -14,7 +14,7 @@ func (*Module) List(r *moduleListRequest) (interface{}, error) { } if r.id > 0 { - m := Module{}.new() + m := Module{}.New() return m, db.Get(m, "select * from crm_module id=?", r.id) } @@ -29,7 +29,7 @@ func (*Module) Edit(r *moduleEditRequest) (interface{}, error) { return nil, err } - m := Module{}.new() + m := Module{}.New() m.SetID(r.id).SetName(r.name) if m.GetID() > 0 { return m, db.Replace("crm_module", m) @@ -45,7 +45,7 @@ func (*Module) ContentList(r *moduleContentListRequest) (interface{}, error) { } if r.id > 0 { - m := ModuleContentRow{}.new() + m := ModuleContentRow{}.New() return m, db.Get(m, "select * from crm_module id=?", r.id) } diff --git a/crm/module.handlers.go b/crm/module.handlers.go index 3d7132381..b6b0f038c 100644 --- a/crm/module.handlers.go +++ b/crm/module.handlers.go @@ -1,5 +1,20 @@ package crm +/* + Hello! This file is auto-generated from `docs/src/spec.json`. + + For development: + In order to update the generated files, edit this file under the location, + add your struct fields, imports, API definitions and whatever you want, and: + + 1. run [spec](https://github.com/titpetric/spec) in the same folder, + 2. run `./_gen.php` in this folder. + + You may edit `module.go`, `module.util.go` or `module_test.go` to + implement your API calls, helper functions and tests. The file `module.go` + is only generated the first time, and will not be overwritten if it exists. +*/ + import ( "net/http" diff --git a/crm/module.interfaces.go b/crm/module.interfaces.go index 294c8a57f..dc966f21e 100644 --- a/crm/module.interfaces.go +++ b/crm/module.interfaces.go @@ -1,5 +1,20 @@ package crm +/* + Hello! This file is auto-generated from `docs/src/spec.json`. + + For development: + In order to update the generated files, edit this file under the location, + add your struct fields, imports, API definitions and whatever you want, and: + + 1. run [spec](https://github.com/titpetric/spec) in the same folder, + 2. run `./_gen.php` in this folder. + + You may edit `module.go`, `module.util.go` or `module_test.go` to + implement your API calls, helper functions and tests. The file `module.go` + is only generated the first time, and will not be overwritten if it exists. +*/ + import ( "net/http" ) @@ -11,7 +26,7 @@ type ModuleHandlers struct { func (ModuleHandlers) new() *ModuleHandlers { return &ModuleHandlers{ - Module{}.new(), + Module{}.New(), } } @@ -35,4 +50,4 @@ type ModuleHandlersAPI interface { // Compile time check to see if we implement the interfaces var _ ModuleHandlersAPI = &ModuleHandlers{} -var _ ModuleAPI = &Module{} \ No newline at end of file +var _ ModuleAPI = &Module{} diff --git a/crm/module.request.go b/crm/module.request.go index ef16865ec..808d87083 100644 --- a/crm/module.request.go +++ b/crm/module.request.go @@ -1,8 +1,23 @@ package crm +/* + Hello! This file is auto-generated from `docs/src/spec.json`. + + For development: + In order to update the generated files, edit this file under the location, + add your struct fields, imports, API definitions and whatever you want, and: + + 1. run [spec](https://github.com/titpetric/spec) in the same folder, + 2. run `./_gen.php` in this folder. + + You may edit `module.go`, `module.util.go` or `module_test.go` to + implement your API calls, helper functions and tests. The file `module.go` + is only generated the first time, and will not be overwritten if it exists. +*/ + import ( - "net/http" "github.com/go-chi/chi" + "net/http" ) var _ = chi.URLParam @@ -33,9 +48,10 @@ func (m *moduleListRequest) Fill(r *http.Request) error { } var _ RequestFiller = moduleListRequest{}.new() + // Module edit request parameters type moduleEditRequest struct { - id uint64 + id uint64 name string } @@ -62,6 +78,7 @@ func (m *moduleEditRequest) Fill(r *http.Request) error { } var _ RequestFiller = moduleEditRequest{}.new() + // Module content/list request parameters type moduleContentListRequest struct { id uint64 @@ -88,9 +105,10 @@ func (m *moduleContentListRequest) Fill(r *http.Request) error { } var _ RequestFiller = moduleContentListRequest{}.new() + // Module content/edit request parameters type moduleContentEditRequest struct { - id uint64 + id uint64 payload string } @@ -117,6 +135,7 @@ func (m *moduleContentEditRequest) Fill(r *http.Request) error { } var _ RequestFiller = moduleContentEditRequest{}.new() + // Module content/delete request parameters type moduleContentDeleteRequest struct { id uint64 diff --git a/crm/module.structs.go b/crm/module.structs.go index 5c31fd50b..79f6ce656 100644 --- a/crm/module.structs.go +++ b/crm/module.structs.go @@ -1,5 +1,19 @@ package crm +/* + Hello! This file is auto-generated from `docs/src/spec.json`. + + For development: + In order to update the generated files, edit this file under the location, + add your struct fields, imports, API definitions and whatever you want, and: + + 1. run [spec](https://github.com/titpetric/spec) in the same folder, + 2. run `./_gen.php` in this folder. + + You may edit `module.go`, `module.util.go` or `module_test.go` to + implement your API calls, helper functions and tests. The file `module.go` + is only generated the first time, and will not be overwritten if it exists. +*/ import ( "github.com/jmoiron/sqlx/types" @@ -8,29 +22,27 @@ import ( type ( // Modules Module struct { - ID uint64 + ID uint64 Name string changed []string } - // Modules ModuleContentRow struct { - ID uint64 `db:"id"` - ModuleID uint64 `db:"module_id"` - Fields types.JSONText `db:"address"` + ID uint64 `db:"id"` + ModuleID uint64 `db:"module_id"` + Fields types.JSONText `db:"address"` changed []string } - ) /* Constructors */ -func (Module) new() *Module { +func (Module) New() *Module { return &Module{} } -func (ModuleContentRow) new() *ModuleContentRow { +func (ModuleContentRow) New() *ModuleContentRow { return &ModuleContentRow{} } diff --git a/crm/routes.go b/crm/routes.go index 09a210202..43fe272ce 100644 --- a/crm/routes.go +++ b/crm/routes.go @@ -1,5 +1,20 @@ package crm +/* + Hello! This file is auto-generated from `docs/src/spec.json`. + + For development: + In order to update the generated files, edit this file under the location, + add your struct fields, imports, API definitions and whatever you want, and: + + 1. run [spec](https://github.com/titpetric/spec) in the same folder, + 2. run `./_gen.php` in this folder. + + You may edit `.go`, `.util.go` or `_test.go` to + implement your API calls, helper functions and tests. The file `.go` + is only generated the first time, and will not be overwritten if it exists. +*/ + import ( "github.com/go-chi/chi" ) @@ -18,4 +33,4 @@ func MountRoutes(r chi.Router) { r.Get("/list", types.List) r.Get("/type/{id}", types.Type) }) -} \ No newline at end of file +} diff --git a/crm/templates/http_handlers.tpl b/crm/templates/http_handlers.tpl index 29fdf4c11..4cb5d854d 100644 --- a/crm/templates/http_handlers.tpl +++ b/crm/templates/http_handlers.tpl @@ -1,5 +1,7 @@ package {package} +{load warning.tpl} + import ( "net/http" diff --git a/crm/templates/http_interfaces.tpl b/crm/templates/http_interfaces.tpl index 36eb9cc63..f23cd14f1 100644 --- a/crm/templates/http_interfaces.tpl +++ b/crm/templates/http_interfaces.tpl @@ -1,5 +1,7 @@ package {package} +{load warning.tpl} + import ( "net/http" ) @@ -11,7 +13,7 @@ type {name}Handlers struct { func ({name}Handlers) new() *{name}Handlers { return &{name}Handlers{ - {name}{}.new(), + {name}{}.New(), } } diff --git a/crm/templates/http_request.tpl b/crm/templates/http_request.tpl index 911832e9c..789625ff5 100644 --- a/crm/templates/http_request.tpl +++ b/crm/templates/http_request.tpl @@ -1,5 +1,7 @@ package {package} +{load warning.tpl} + import ( "net/http" "github.com/go-chi/chi" diff --git a/crm/templates/http_routes.tpl b/crm/templates/http_routes.tpl index 116c30ba7..e39d9ddfd 100644 --- a/crm/templates/http_routes.tpl +++ b/crm/templates/http_routes.tpl @@ -1,5 +1,7 @@ package {package} +{load warning.tpl} + import ( "github.com/go-chi/chi" ) diff --git a/crm/templates/http_structs.tpl b/crm/templates/http_structs.tpl index 86d679e6c..f095b9180 100644 --- a/crm/templates/http_structs.tpl +++ b/crm/templates/http_structs.tpl @@ -1,5 +1,7 @@ package {package} +{load warning.tpl} + {if !empty($imports)} import ( {foreach ($imports as $import)} @@ -29,7 +31,7 @@ type ({foreach $structs as $struct} /* Constructors */ {foreach $structs as $struct} -func ({struct.name}) new() *{struct.name} { +func ({struct.name}) New() *{struct.name} { return &{struct.name}{} } {/foreach} diff --git a/crm/templates/warning.tpl b/crm/templates/warning.tpl new file mode 100644 index 000000000..87be0f8f1 --- /dev/null +++ b/crm/templates/warning.tpl @@ -0,0 +1,14 @@ +/* + Hello! This file is auto-generated from `docs/src/spec.json`. + + For development: + In order to update the generated files, edit this file under the location, + add your struct fields, imports, API definitions and whatever you want, and: + + 1. run [spec](https://github.com/titpetric/spec) in the same folder, + 2. run `./_gen.php` in this folder. + + You may edit `{name|strtolower}.go`, `{name|strtolower}.util.go` or `{name|strtolower}_test.go` to + implement your API calls, helper functions and tests. The file `{name|strtolower}.go` + is only generated the first time, and will not be overwritten if it exists. +*/ \ No newline at end of file diff --git a/crm/types.handlers.go b/crm/types.handlers.go index 989eccc7c..21faf459a 100644 --- a/crm/types.handlers.go +++ b/crm/types.handlers.go @@ -1,5 +1,20 @@ package crm +/* + Hello! This file is auto-generated from `docs/src/spec.json`. + + For development: + In order to update the generated files, edit this file under the location, + add your struct fields, imports, API definitions and whatever you want, and: + + 1. run [spec](https://github.com/titpetric/spec) in the same folder, + 2. run `./_gen.php` in this folder. + + You may edit `types.go`, `types.util.go` or `types_test.go` to + implement your API calls, helper functions and tests. The file `types.go` + is only generated the first time, and will not be overwritten if it exists. +*/ + import ( "net/http" diff --git a/crm/types.interfaces.go b/crm/types.interfaces.go index af158414d..2a226d870 100644 --- a/crm/types.interfaces.go +++ b/crm/types.interfaces.go @@ -1,5 +1,20 @@ package crm +/* + Hello! This file is auto-generated from `docs/src/spec.json`. + + For development: + In order to update the generated files, edit this file under the location, + add your struct fields, imports, API definitions and whatever you want, and: + + 1. run [spec](https://github.com/titpetric/spec) in the same folder, + 2. run `./_gen.php` in this folder. + + You may edit `types.go`, `types.util.go` or `types_test.go` to + implement your API calls, helper functions and tests. The file `types.go` + is only generated the first time, and will not be overwritten if it exists. +*/ + import ( "net/http" ) @@ -11,7 +26,7 @@ type TypesHandlers struct { func (TypesHandlers) new() *TypesHandlers { return &TypesHandlers{ - Types{}.new(), + Types{}.New(), } } @@ -29,4 +44,4 @@ type TypesHandlersAPI interface { // Compile time check to see if we implement the interfaces var _ TypesHandlersAPI = &TypesHandlers{} -var _ TypesAPI = &Types{} \ No newline at end of file +var _ TypesAPI = &Types{} diff --git a/crm/types.request.go b/crm/types.request.go index 2748223eb..74b5574c3 100644 --- a/crm/types.request.go +++ b/crm/types.request.go @@ -1,8 +1,23 @@ package crm +/* + Hello! This file is auto-generated from `docs/src/spec.json`. + + For development: + In order to update the generated files, edit this file under the location, + add your struct fields, imports, API definitions and whatever you want, and: + + 1. run [spec](https://github.com/titpetric/spec) in the same folder, + 2. run `./_gen.php` in this folder. + + You may edit `types.go`, `types.util.go` or `types_test.go` to + implement your API calls, helper functions and tests. The file `types.go` + is only generated the first time, and will not be overwritten if it exists. +*/ + import ( - "net/http" "github.com/go-chi/chi" + "net/http" ) var _ = chi.URLParam @@ -30,6 +45,7 @@ func (t *typesListRequest) Fill(r *http.Request) error { } var _ RequestFiller = typesListRequest{}.new() + // Types type request parameters type typesTypeRequest struct { id string diff --git a/crm/types.structs.go b/crm/types.structs.go index 6a3f7d900..c8c02803d 100644 --- a/crm/types.structs.go +++ b/crm/types.structs.go @@ -1,17 +1,29 @@ package crm +/* + Hello! This file is auto-generated from `docs/src/spec.json`. + + For development: + In order to update the generated files, edit this file under the location, + add your struct fields, imports, API definitions and whatever you want, and: + + 1. run [spec](https://github.com/titpetric/spec) in the same folder, + 2. run `./_gen.php` in this folder. + + You may edit `types.go`, `types.util.go` or `types_test.go` to + implement your API calls, helper functions and tests. The file `types.go` + is only generated the first time, and will not be overwritten if it exists. +*/ type ( // Types Types struct { - changed []string } - ) /* Constructors */ -func (Types) new() *Types { +func (Types) New() *Types { return &Types{} } diff --git a/sam/_gen.php b/sam/_gen.php old mode 100755 new mode 100644 index 0e8bf795f..07cab9f81 --- a/sam/_gen.php +++ b/sam/_gen.php @@ -80,5 +80,3 @@ foreach (array("routes") as $type) { file_put_contents($filename, $contents); } - -passthru("go fmt"); \ No newline at end of file diff --git a/sam/_gen.sh b/sam/_gen.sh new file mode 100755 index 000000000..37c7c1cdd --- /dev/null +++ b/sam/_gen.sh @@ -0,0 +1,2 @@ +/usr/bin/env php _gen.php +go fmt \ No newline at end of file