Commit b30a722a authored by Tit Petric's avatar Tit Petric
Browse files

update generator, code with warnings

parent ab943146
......@@ -80,5 +80,3 @@ foreach (array("routes") as $type) {
file_put_contents($filename, $contents);
}
passthru("go fmt");
\ No newline at end of file
/usr/bin/env php _gen.php
go fmt
\ No newline at end of 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)
}
......
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"
......
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{}
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
......
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{}
}
......
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
}
package {package}
{load warning.tpl}
import (
"net/http"
......
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(),
}
}
......
package {package}
{load warning.tpl}
import (
"net/http"
"github.com/go-chi/chi"
......
package {package}
{load warning.tpl}
import (
"github.com/go-chi/chi"
)
......
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}
......
/*
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
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"
......
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{}
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
......
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{}
}
......
......@@ -80,5 +80,3 @@ foreach (array("routes") as $type) {
file_put_contents($filename, $contents);
}
passthru("go fmt");
\ No newline at end of file
/usr/bin/env php _gen.php
go fmt
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment