houyaf 3 anos atrás
pai
commit
0329fe8eaf

+ 8 - 8
pkg/api/controller/api_controller.go

@@ -12,17 +12,17 @@ type ApiController struct {
 }
 
 func (c *ApiController) BeforeActivation(b mvc.BeforeActivation) {
-    b.Handle("GET",         "/",                                             "GetList"        )
-    b.Handle("GET",         "/page",                                         "GetPage"        )
-    b.Handle("GET",         "/{apiId:int64}",                                 "GetById"        )
-    b.Handle("POST",         "/add",                                         "Create"        )
-    b.Handle("PUT",         "/update",                                         "Update"        )
-    b.Handle("PUT",         "/updateStatus/{apiId:int64}/{status:int64}",     "UpdateStatus"    )
-    b.Handle("DELETE",         "/{apiId:int64}",                                 "DeleteByID"    )
+    b.Handle("GET",         "/",                                             "GetList"       )
+    b.Handle("GET",         "/page",                                         "GetPage"       )
+    b.Handle("GET",         "/{apiId:int64}",                                "GetById"       )
+    b.Handle("POST",        "/add",                                          "Create"        )
+    b.Handle("PUT",         "/update",                                       "Update"        )
+    b.Handle("PUT",         "/updateStatus/{apiId:int64}/{status:int64}",    "UpdateStatus"  )
+    b.Handle("DELETE",      "/{apiId:int64}",                                "DeleteByID"    )
 }
 
 func (c *ApiController) GetList() *JsonResult {
-    params     := c.buildParams()
+    params    := c.buildParams()
     bizId     := c.Ctx.URLParamInt64Default("bizId", 0)
     if bizId > 0 {
         params["bizId"] = bizId

+ 3 - 3
pkg/system/controller/art_controller.go

@@ -51,8 +51,8 @@ func (c *ArtController) GetById(artId int64) *JsonResult {
 }
 
 func (c *ArtController) Create() *JsonResult {
-    ocId    := c.GetCurOcId()
-    userId  := c.GetCurUserId()
+    ocId   := c.GetCurOcId()
+    userId := c.GetCurUserId()
 
     art     := datamodel.Art{}
     if err := c.Ctx.ReadJSON(&art); err != nil {
@@ -86,7 +86,7 @@ func (c *ArtController) Update() *JsonResult {
 }
 
 func (c *ArtController) DeleteByID(artId int64) *JsonResult {
-    ocId := c.GetCurOcId()
+    ocId   := c.GetCurOcId()
     userId := c.GetCurUserId()
 
     m := make(map[string]interface{})

+ 6 - 16
pkg/system/controller/base.go

@@ -18,15 +18,6 @@ func init() {
     validate = validator.New()
 }
 
-func errorData(errs ...error) {
-    var s string
-    for _, err := range errs {
-        if err != nil {
-            s += err.Error() + "<br/>"
-        }
-    }
-}
-
 type Base struct {
     Ctx iris.Context
 }
@@ -138,7 +129,7 @@ func (b *Base) buildParams() map[string]interface{} {
     }
 
     params := make(map[string]interface{})
-    params["ocId"] = ocId
+    params["ocId"]   = ocId
     params["userId"] = userId
     groupId := b.Ctx.URLParamInt64Default("groupId", 0)
     if groupId > 0 {
@@ -146,16 +137,15 @@ func (b *Base) buildParams() map[string]interface{} {
     }
 
     limit := b.Ctx.URLParamIntDefault("limit", 0)
-    if limit <= 0 {
-        limit = 10
+    if limit > 0 {
+        params["limit"] = limit
     }
-    params["limit"] = limit
 
     page := b.Ctx.URLParamIntDefault("page", 0)
-    if page <= 0 {
-        page = 1
+    if page > 0 {
+        params["page"] = page
     }
-    params["page"] = page
+
     keywords := b.Ctx.URLParamDefault("keywords", "")
     if keywords != "" {
         params["keywords"] = keywords

+ 2 - 2
pkg/system/controller/task_controller.go

@@ -51,7 +51,7 @@ func (c *TaskController) GetById(taskId int64) *JsonResult {
 }
 
 func (c *TaskController) Create() *JsonResult {
-    ocId := c.GetCurOcId()
+    ocId   := c.GetCurOcId()
     userId := c.GetCurUserId()
 
     task := &datamodel.Task{}
@@ -69,7 +69,7 @@ func (c *TaskController) Create() *JsonResult {
 }
 
 func (c *TaskController) Update() *JsonResult {
-    ocId := c.GetCurOcId()
+    ocId   := c.GetCurOcId()
     userId := c.GetCurUserId()
 
     task := &datamodel.Task{}