From f6a219fb3a4f3c845bfddda7e1333141bba372d5 Mon Sep 17 00:00:00 2001 From: CodyGuo Date: Sun, 4 Sep 2016 13:53:45 +0800 Subject: [PATCH 1/5] Fix to issue #270 --- apiapp.go | 1 + 1 file changed, 1 insertion(+) diff --git a/apiapp.go b/apiapp.go index 4d4e58a..27e538d 100644 --- a/apiapp.go +++ b/apiapp.go @@ -650,6 +650,7 @@ func checkEnv(appname string) (apppath, packpath string, err error) { for _, gpath := range gps { gsrcpath := path.Join(gpath, "src") if strings.HasPrefix(currpath, gsrcpath) { + packpath = strings.Replace(currpath[len(gsrcpath)+1:], string(path.Separator), "/", -1) return currpath, currpath[len(gsrcpath)+1:], nil } } From ed67ef47e6825c5bfeb089559bf42fa44d83c394 Mon Sep 17 00:00:00 2001 From: CodyGuo Date: Sun, 4 Sep 2016 20:45:11 +0800 Subject: [PATCH 2/5] Fix to issue #270 --- apiapp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apiapp.go b/apiapp.go index 27e538d..892719b 100644 --- a/apiapp.go +++ b/apiapp.go @@ -651,7 +651,7 @@ func checkEnv(appname string) (apppath, packpath string, err error) { gsrcpath := path.Join(gpath, "src") if strings.HasPrefix(currpath, gsrcpath) { packpath = strings.Replace(currpath[len(gsrcpath)+1:], string(path.Separator), "/", -1) - return currpath, currpath[len(gsrcpath)+1:], nil + return currpath, packpath, nil } } From ad34b7be2a3dbbaa1ab6d113cea86ad022ba89bf Mon Sep 17 00:00:00 2001 From: ZetaChow Date: Fri, 9 Sep 2016 15:20:59 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=EF=BC=8C=E4=BB=A5=E7=AC=A6=E5=90=88Lint?= =?UTF-8?q?=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- g_appcode.go | 8 +++++++- g_controllers.go | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/g_appcode.go b/g_appcode.go index 76d78ad..5d44663 100644 --- a/g_appcode.go +++ b/g_appcode.go @@ -1168,11 +1168,12 @@ import ( "github.com/astaxie/beego" ) -// oprations for {{ctrlName}} +// {{ctrlName}}Controller oprations for {{ctrlName}} type {{ctrlName}}Controller struct { beego.Controller } +// URLMapping ... func (c *{{ctrlName}}Controller) URLMapping() { c.Mapping("Post", c.Post) c.Mapping("GetOne", c.GetOne) @@ -1181,6 +1182,7 @@ func (c *{{ctrlName}}Controller) URLMapping() { c.Mapping("Delete", c.Delete) } +// Post ... // @Title Post // @Description create {{ctrlName}} // @Param body body models.{{ctrlName}} true "body for {{ctrlName}} content" @@ -1202,6 +1204,7 @@ func (c *{{ctrlName}}Controller) Post() { c.ServeJSON() } +// Get ... // @Title Get // @Description get {{ctrlName}} by id // @Param id path string true "The key for staticblock" @@ -1220,6 +1223,7 @@ func (c *{{ctrlName}}Controller) GetOne() { c.ServeJSON() } +// GetAll ... // @Title Get All // @Description get {{ctrlName}} // @Param query query string false "Filter. e.g. col1:v1,col2:v2 ..." @@ -1282,6 +1286,7 @@ func (c *{{ctrlName}}Controller) GetAll() { c.ServeJSON() } +// Update ... // @Title Update // @Description update the {{ctrlName}} // @Param id path string true "The id you want to update" @@ -1305,6 +1310,7 @@ func (c *{{ctrlName}}Controller) Put() { c.ServeJSON() } +// Delete ... // @Title Delete // @Description delete the {{ctrlName}} // @Param id path string true "The id you want to delete" diff --git a/g_controllers.go b/g_controllers.go index 79ed554..15ab0bd 100644 --- a/g_controllers.go +++ b/g_controllers.go @@ -82,11 +82,12 @@ import ( "github.com/astaxie/beego" ) -// operations for {{controllerName}} +// {{controllerName}}Controller operations for {{controllerName}} type {{controllerName}}Controller struct { beego.Controller } +// URLMapping ... func (c *{{controllerName}}Controller) URLMapping() { c.Mapping("Post", c.Post) c.Mapping("GetOne", c.GetOne) @@ -95,6 +96,7 @@ func (c *{{controllerName}}Controller) URLMapping() { c.Mapping("Delete", c.Delete) } +// Post ... // @Title Create // @Description create {{controllerName}} // @Param body body models.{{controllerName}} true "body for {{controllerName}} content" @@ -105,6 +107,7 @@ func (c *{{controllerName}}Controller) Post() { } +// GetOne ... // @Title GetOne // @Description get {{controllerName}} by id // @Param id path string true "The key for staticblock" @@ -115,6 +118,7 @@ func (c *{{controllerName}}Controller) GetOne() { } +// GetAll ... // @Title GetAll // @Description get {{controllerName}} // @Param query query string false "Filter. e.g. col1:v1,col2:v2 ..." @@ -130,6 +134,7 @@ func (c *{{controllerName}}Controller) GetAll() { } +// Update ... // @Title Update // @Description update the {{controllerName}} // @Param id path string true "The id you want to update" @@ -141,6 +146,7 @@ func (c *{{controllerName}}Controller) Put() { } +// Delete ... // @Title Delete // @Description delete the {{controllerName}} // @Param id path string true "The id you want to delete" @@ -164,11 +170,12 @@ import ( "github.com/astaxie/beego" ) -// oprations for {{controllerName}} +// {{controllerName}}Controller oprations for {{controllerName}} type {{controllerName}}Controller struct { beego.Controller } +// URLMapping ... func (c *{{controllerName}}Controller) URLMapping() { c.Mapping("Post", c.Post) c.Mapping("GetOne", c.GetOne) @@ -177,6 +184,7 @@ func (c *{{controllerName}}Controller) URLMapping() { c.Mapping("Delete", c.Delete) } +// Post ... // @Title Post // @Description create {{controllerName}} // @Param body body models.{{controllerName}} true "body for {{controllerName}} content" @@ -195,6 +203,7 @@ func (c *{{controllerName}}Controller) Post() { c.ServeJSON() } +// Get ... // @Title Get // @Description get {{controllerName}} by id // @Param id path string true "The key for staticblock" @@ -213,6 +222,7 @@ func (c *{{controllerName}}Controller) GetOne() { c.ServeJSON() } +// GetAll ... // @Title Get All // @Description get {{controllerName}} // @Param query query string false "Filter. e.g. col1:v1,col2:v2 ..." @@ -275,6 +285,7 @@ func (c *{{controllerName}}Controller) GetAll() { c.ServeJSON() } +// Update ... // @Title Update // @Description update the {{controllerName}} // @Param id path string true "The id you want to update" @@ -295,6 +306,7 @@ func (c *{{controllerName}}Controller) Put() { c.ServeJSON() } +// Delete ... // @Title Delete // @Description delete the {{controllerName}} // @Param id path string true "The id you want to delete" From 411aa430805140f9b56b5adbf71a295e189399d6 Mon Sep 17 00:00:00 2001 From: ZetaChow Date: Fri, 9 Sep 2016 15:27:36 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9PUT=E5=92=8CGet=20One=20?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- g_appcode.go | 8 ++++---- g_controllers.go | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/g_appcode.go b/g_appcode.go index 5d44663..9276360 100644 --- a/g_appcode.go +++ b/g_appcode.go @@ -1204,8 +1204,8 @@ func (c *{{ctrlName}}Controller) Post() { c.ServeJSON() } -// Get ... -// @Title Get +// GetOne ... +// @Title Get One // @Description get {{ctrlName}} by id // @Param id path string true "The key for staticblock" // @Success 200 {object} models.{{ctrlName}} @@ -1286,8 +1286,8 @@ func (c *{{ctrlName}}Controller) GetAll() { c.ServeJSON() } -// Update ... -// @Title Update +// Put ... +// @Title Put // @Description update the {{ctrlName}} // @Param id path string true "The id you want to update" // @Param body body models.{{ctrlName}} true "body for {{ctrlName}} content" diff --git a/g_controllers.go b/g_controllers.go index 15ab0bd..7c782b6 100644 --- a/g_controllers.go +++ b/g_controllers.go @@ -134,8 +134,8 @@ func (c *{{controllerName}}Controller) GetAll() { } -// Update ... -// @Title Update +// Put ... +// @Title Put // @Description update the {{controllerName}} // @Param id path string true "The id you want to update" // @Param body body models.{{controllerName}} true "body for {{controllerName}} content" @@ -203,8 +203,8 @@ func (c *{{controllerName}}Controller) Post() { c.ServeJSON() } -// Get ... -// @Title Get +// GetOne ... +// @Title Get One // @Description get {{controllerName}} by id // @Param id path string true "The key for staticblock" // @Success 200 {object} models.{{controllerName}} @@ -285,8 +285,8 @@ func (c *{{controllerName}}Controller) GetAll() { c.ServeJSON() } -// Update ... -// @Title Update +// Put ... +// @Title Put // @Description update the {{controllerName}} // @Param id path string true "The id you want to update" // @Param body body models.{{controllerName}} true "body for {{controllerName}} content" From 0d0bea81bf67f667ec45441e07a1f94a74a881a3 Mon Sep 17 00:00:00 2001 From: ZetaChow Date: Fri, 9 Sep 2016 15:38:44 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=8E=BB=E6=8E=89offset(int64)=E8=B5=8B0?= =?UTF-8?q?=E5=80=BC,=E5=8E=BB=E6=8E=89query=20(map[...]...)=E5=AE=9A?= =?UTF-8?q?=E4=B9=89,=E4=BB=A5=E7=AC=A6=E5=90=88Lint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- g_appcode.go | 4 ++-- g_controllers.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/g_appcode.go b/g_appcode.go index 9276360..4e90107 100644 --- a/g_appcode.go +++ b/g_appcode.go @@ -1239,9 +1239,9 @@ func (c *{{ctrlName}}Controller) GetAll() { var fields []string var sortby []string var order []string - var query map[string]string = make(map[string]string) + var query = make(map[string]string) var limit int64 = 10 - var offset int64 = 0 + var offset int64 // fields: col1,col2,entity.col3 if v := c.GetString("fields"); v != "" { diff --git a/g_controllers.go b/g_controllers.go index 7c782b6..9d0b0ae 100644 --- a/g_controllers.go +++ b/g_controllers.go @@ -238,9 +238,9 @@ func (c *{{controllerName}}Controller) GetAll() { var fields []string var sortby []string var order []string - var query map[string]string = make(map[string]string) + var query = make(map[string]string) var limit int64 = 10 - var offset int64 = 0 + var offset int64 // fields: col1,col2,entity.col3 if v := c.GetString("fields"); v != "" {