houyaf %!s(int64=3) %!d(string=hai) anos
pai
achega
ae3d5ee6cb
Modificáronse 2 ficheiros con 17 adicións e 16 borrados
  1. 8 7
      web/controllers/app_controller.go
  2. 9 9
      web/controllers/ent_cat_controller.go

+ 8 - 7
web/controllers/app_controller.go

@@ -12,12 +12,12 @@ type AppController struct {
 }
 
 func (c *AppController) BeforeActivation(b mvc.BeforeActivation) {
-	b.Handle("GET",         "/",                "GetList"   )
-	b.Handle("GET",         "/page",            "GetPage"   )
-	b.Handle("GET",         "/{appId:int64}",   "GetById"   )
-	b.Handle("POST",        "/add",             "Create"    )
-	b.Handle("PUT",         "/update",          "Update"    )
-	b.Handle("DELETE",      "/{appId:int64}",   "DeleteByID")
+	b.Handle("GET",         "/",                    "GetList"   )
+	b.Handle("GET",         "/page",                "GetPage"   )
+	b.Handle("GET",         "/{appId:int64}",       "GetById"   )
+	b.Handle("POST",        "/add",                 "Create"    )
+	b.Handle("PUT",         "/update",              "Update"    )
+	b.Handle("DELETE",      "/{appId:int64}",       "DeleteByID")
 }
 
 func (c *AppController) GetList() *JsonResult {
@@ -25,8 +25,9 @@ func (c *AppController) GetList() *JsonResult {
 	data, err := c.Service.GetList(params)
 	if err != nil {
 		return ResultErr(err.Error(), nil)
+	} else {
+		return ResultOk("获取成功", data)
 	}
-	return ResultOk("获取成功", data)
 }
 
 func (c *AppController) GetPage() *JsonResult {

+ 9 - 9
web/controllers/ent_cat_controller.go

@@ -12,12 +12,12 @@ type EntCatController struct {
 }
 
 func (c *EntCatController) BeforeActivation(b mvc.BeforeActivation) {
-	b.Handle("GET",         "/",                    "GetList"   )
-	b.Handle("GET",         "/page",                "GetPage"   )
-	b.Handle("GET",         "/{entCatId:int64}",    "GetById"   )
-	b.Handle("POST",        "/add",                 "Create"    )
-	b.Handle("PUT",         "/update",              "Update"    )
-	b.Handle("DELETE",      "/{entCatId:int64}",    "DeleteByID")
+	b.Handle("GET",         "/",                        "GetList"   )
+	b.Handle("GET",         "/page",                    "GetPage"   )
+	b.Handle("GET",         "/{entCatId:int64}",        "GetById"   )
+	b.Handle("POST",        "/add",                     "Create"    )
+	b.Handle("PUT",         "/update",                  "Update"    )
+	b.Handle("DELETE",      "/{entCatId:int64}",        "DeleteByID")
 }
 
 func (c *EntCatController) GetList() *JsonResult {
@@ -53,12 +53,12 @@ func (c *EntCatController) Create() *JsonResult {
 	userId := c.GetCurUserId()
 	entCat := datamodels.EntCat{}
 	entCat.CreatedBy = userId
-	err := c.Ctx.ReadJSON(&entCat)
-	if err != nil {
+	
+	if err := c.Ctx.ReadJSON(&entCat); err != nil {
 		return ResultErr("读取数据失败", nil)
 	}
 
-	err = c.Service.Create(&entCat)
+	err := c.Service.Create(&entCat)
 	if err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {