3
0

update generator, code with warnings

This commit is contained in:
Tit Petric
2018-07-06 10:56:26 +00:00
parent ab943146d3
commit b30a722a7b
20 changed files with 187 additions and 29 deletions
Executable → Regular
-2
View File
@@ -80,5 +80,3 @@ foreach (array("routes") as $type) {
file_put_contents($filename, $contents);
}
passthru("go fmt");
Executable
+2
View File
@@ -0,0 +1,2 @@
/usr/bin/env php _gen.php
go fmt
+3 -3
View File
@@ -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)
}
+15
View File
@@ -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"
+17 -2
View File
@@ -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{}
var _ ModuleAPI = &Module{}
+22 -3
View File
@@ -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
+20 -8
View File
@@ -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{}
}
+16 -1
View File
@@ -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)
})
}
}
+2
View File
@@ -1,5 +1,7 @@
package {package}
{load warning.tpl}
import (
"net/http"
+3 -1
View File
@@ -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(),
}
}
+2
View File
@@ -1,5 +1,7 @@
package {package}
{load warning.tpl}
import (
"net/http"
"github.com/go-chi/chi"
+2
View File
@@ -1,5 +1,7 @@
package {package}
{load warning.tpl}
import (
"github.com/go-chi/chi"
)
+3 -1
View File
@@ -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}
+14
View File
@@ -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.
*/
+15
View File
@@ -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"
+17 -2
View File
@@ -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{}
var _ TypesAPI = &Types{}
+17 -1
View File
@@ -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
+15 -3
View File
@@ -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{}
}
Executable → Regular
-2
View File
@@ -80,5 +80,3 @@ foreach (array("routes") as $type) {
file_put_contents($filename, $contents);
}
passthru("go fmt");
Executable
+2
View File
@@ -0,0 +1,2 @@
/usr/bin/env php _gen.php
go fmt