houyaf vor 3 Jahren
Ursprung
Commit
b10b838a7d

+ 6 - 8
web/controllers/app_cat_controller.go

@@ -52,13 +52,12 @@ func (c *AppCatController) Create() *JsonResult {
     userId := c.GetCurUserId()
     appCat := datamodels.AppCat{}
     appCat.CreatedBy = userId
-    err := c.Ctx.ReadJSON(&appCat)
-    if err != nil {
+    
+    if err := c.Ctx.ReadJSON(&appCat); err != nil {
         return ResultErr("读取数据失败", nil)
     }
     
-    err = c.Service.Create(&appCat)
-    if err != nil {
+    if err := c.Service.Create(&appCat); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
         return ResultOk("新增成功", nil)
@@ -73,8 +72,7 @@ func (c *AppCatController) Update() *JsonResult {
     }
     
     appCat.UpdatedBy = userId
-    err := c.Service.Update(&appCat)
-    if err != nil {
+    if err := c.Service.Update(&appCat); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
         return ResultOk("更新成功", nil)
@@ -88,8 +86,8 @@ func (c *AppCatController) DeleteByID(appCatId int64) *JsonResult {
     m["ocId"]      = ocId
     m["appCatId"]  = appCatId
     m["deletedBy"] = userId
-    err := c.Service.Delete(m)
-    if err != nil {
+    
+    if err := c.Service.Delete(m); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
         return ResultOk("删除成功", nil)

+ 5 - 7
web/controllers/app_controller.go

@@ -57,9 +57,8 @@ func (c *AppController) Create() *JsonResult {
 	if err != nil {
 		return ResultErr("读取数据失败", nil)
 	}
-
-	err = c.Service.Create(&app)
-	if err != nil {
+	
+	if err = c.Service.Create(&app); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("新增成功", nil)
@@ -74,8 +73,7 @@ func (c *AppController) Update() *JsonResult {
 	}
 
 	app.UpdatedBy = userId
-	err := c.Service.Update(&app)
-	if err != nil {
+	if err := c.Service.Update(&app); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("更新成功", nil)
@@ -90,8 +88,8 @@ func (c *AppController) DeleteByID(appId int64) *JsonResult {
 	m["ocId"] = ocId
 	m["appId"] = appId
 	m["deletedBy"] = userId
-	err := c.Service.Delete(m)
-	if err != nil {
+	
+	if err := c.Service.Delete(m); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("删除成功", nil)

+ 8 - 9
web/controllers/app_permit_controller.go

@@ -45,13 +45,13 @@ func (c *AppPermitController) Create() *JsonResult {
 	userId    := c.GetCurUserId()
 	appPermit := datamodels.AppPermit{}
 	appPermit.CreatedBy = userId
-	err := c.Ctx.ReadJSON(&appPermit)
-	if err != nil {
+	
+	if err := c.Ctx.ReadJSON(&appPermit); err != nil {
 		return ResultErr("读取数据失败", nil)
 	}
 	
-	err = c.Service.Create(&appPermit)
-	if err != nil {
+	
+	if err := c.Service.Create(&appPermit); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("新增成功", nil)
@@ -64,10 +64,9 @@ func (c *AppPermitController) Update() *JsonResult {
 	if err := c.Ctx.ReadJSON(&appPermit); err != nil {
 		return ResultErr("读取数据失败", nil)
 	}
-	
 	appPermit.UpdatedBy = userId
-	err := c.Service.Update(&appPermit)
-	if err != nil {
+	
+	if err := c.Service.Update(&appPermit); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("更新成功", nil)
@@ -81,8 +80,8 @@ func (c *AppPermitController) DeleteByID(appId, roleId, permitId int64) *JsonRes
 	m["roleId"]    = roleId
 	m["permitId"]  = permitId
 	m["deletedBy"] = userId
-	err := c.Service.Delete(m)
-	if err != nil {
+	
+	if err := c.Service.Delete(m); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("删除成功", nil)

+ 4 - 4
web/controllers/company_profile_controller.go

@@ -30,13 +30,13 @@ func (c *CompanyProfileController) Update() *JsonResult {
     ocId := c.GetCurOcId()
     
     cmp  := &datamodels.Company{OcId :ocId}
-    err  := c.Ctx.ReadJSON(cmp)
-    if err != nil {
+    
+    if err := c.Ctx.ReadJSON(cmp); err != nil {
         return ResultErr(err.Error(), nil)
     }
     
-    err = c.Service.Update(cmp)
-    if err != nil {
+    
+    if err := c.Service.Update(cmp); err != nil {
         return ResultErr("更新失败", nil)
     }
     

+ 5 - 7
web/controllers/ent_cat_controller.go

@@ -57,9 +57,8 @@ func (c *EntCatController) Create() *JsonResult {
 	if err := c.Ctx.ReadJSON(&entCat); err != nil {
 		return ResultErr("读取数据失败", nil)
 	}
-
-	err := c.Service.Create(&entCat)
-	if err != nil {
+	
+	if err := c.Service.Create(&entCat); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("新增成功", nil)
@@ -74,8 +73,7 @@ func (c *EntCatController) Update() *JsonResult {
 	}
 
 	entCat.UpdatedBy = userId
-	err := c.Service.Update(&entCat)
-	if err != nil {
+	if err := c.Service.Update(&entCat); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("更新成功", nil)
@@ -87,8 +85,8 @@ func (c *EntCatController) DeleteByID(entCatId int64) *JsonResult {
 	m := make(map[string]interface{})
 	m["entCatId"]  = entCatId
 	m["deletedBy"] = userId
-	err := c.Service.Delete(m)
-	if err != nil {
+	
+	if err := c.Service.Delete(m); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("删除成功", nil)

+ 4 - 6
web/controllers/group_cat_controller.go

@@ -61,8 +61,7 @@ func (c *GroupCatController) Create() *JsonResult {
     
     groupCat.OcId = ocId
     groupCat.CreatedBy = userId
-    err := c.Service.Create(&groupCat)
-    if err != nil {
+    if err := c.Service.Create(&groupCat); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
         return ResultOk("新增成功", nil)
@@ -79,8 +78,7 @@ func (c *GroupCatController) Update() *JsonResult {
     
     groupCat.OcId = ocId
     groupCat.UpdatedBy = userId
-    err := c.Service.Update(&groupCat)
-    if err != nil {
+    if err := c.Service.Update(&groupCat); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
         return ResultOk("更新成功", nil)
@@ -95,8 +93,8 @@ func (c *GroupCatController) DeleteByID(groupCatId int64) *JsonResult {
     m["ocId"]       = ocId
     m["groupCatId"] = groupCatId
     m["deletedBy"]  = userId
-    err := c.Service.Delete(m)
-    if err != nil {
+    
+    if err := c.Service.Delete(m); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
         return ResultOk("删除成功", nil)

+ 9 - 9
web/controllers/group_controller.go

@@ -44,15 +44,14 @@ func (c *GroupController) Create() *JsonResult {
     ocId    := c.GetCurOcId()
     userId  := c.GetCurUserId()
     group   := datamodels.Group{}
-    err := c.Ctx.ReadJSON(&group)
-    if err != nil {
+    
+    if err := c.Ctx.ReadJSON(&group); err != nil {
         return ResultErr("读取数据失败", nil)
     }
     
     group.OcId = ocId
     group.CreatedBy = userId
-    err = c.Service.Create(&group)
-    if err != nil {
+    if err := c.Service.Create(&group); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
         return ResultOk("新增成功", nil)
@@ -63,14 +62,15 @@ func (c *GroupController) Update(groupId int64) *JsonResult {
     ocId   := c.GetCurOcId()
     userId := c.GetCurUserId()
     group  := datamodels.Group{}
+    
     if err := c.Ctx.ReadJSON(&group); err != nil {
         return ResultErr("读取数据失败", nil)
     }
     
     group.OcId      = ocId
     group.UpdatedBy = userId
-    err := c.Service.Update(&group)
-    if err != nil {
+    
+    if err := c.Service.Update(&group); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
         return ResultOk("更新成功", nil)
@@ -81,12 +81,12 @@ func (c *GroupController) DeleteById(groupId int64) *JsonResult {
     ocId   := c.GetCurOcId()
     userId := c.GetCurUserId()
     
-    m  := make(map[string]interface{})
+    m := make(map[string]interface{})
     m["ocId"]      = ocId
     m["groupId"]   = groupId
     m["deletedBy"] = userId
-    err := c.Service.Delete(m)
-    if err != nil {
+    
+    if err := c.Service.Delete(m); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
         return ResultOk("删除成功", nil)

+ 13 - 14
web/controllers/model_controller.go

@@ -51,15 +51,15 @@ func (c *ModelController) GetById(modelId int64) *JsonResult {
 
 func (c *ModelController) Create() *JsonResult {
 	userId := c.GetCurUserId()
-	model  := datamodels.Model{}
-	model.CreatedBy = userId
-	err := c.Ctx.ReadJSON(&model)
-	if err != nil {
+	mod := datamodels.Model{}
+	mod.CreatedBy = userId
+	
+	if err := c.Ctx.ReadJSON(&mod); err != nil {
 		return ResultErr("读取数据失败", nil)
 	}
 
-	err = c.Service.Create(&model)
-	if err != nil {
+	
+	if err := c.Service.Create(&mod); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("新增成功", nil)
@@ -68,14 +68,13 @@ func (c *ModelController) Create() *JsonResult {
 
 func (c *ModelController) Update() *JsonResult {
 	userId := c.GetCurUserId()
-	model  := datamodels.Model{}
-	if err := c.Ctx.ReadJSON(&model); err != nil {
+	mod  := datamodels.Model{}
+	if err := c.Ctx.ReadJSON(&mod); err != nil {
 		return ResultErr("读取数据失败", nil)
 	}
-
-	model.UpdatedBy = userId
-	err := c.Service.Update(&model)
-	if err != nil {
+	
+	mod.UpdatedBy = userId
+	if err := c.Service.Update(&mod); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("更新成功", nil)
@@ -87,8 +86,8 @@ func (c *ModelController) DeleteByID(modelId int64) *JsonResult {
 	m := make(map[string]interface{})
 	m["modelId"]   = modelId
 	m["deletedBy"] = userId
-	err := c.Service.Delete(m)
-	if err != nil {
+	
+	if err := c.Service.Delete(m); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("删除成功", nil)

+ 10 - 10
web/controllers/object_attr_controller.go

@@ -12,8 +12,8 @@ type ObjectAttrController struct {
 }
 
 func (c *ObjectAttrController) BeforeActivation(b mvc.BeforeActivation) {
-	b.Handle("GET",     "/",                                                "GetList" )
-	b.Handle("GET",     "/page",                                            "GetPage" )
+	b.Handle("GET",     "/",                                                "GetList"   )
+	b.Handle("GET",     "/page",                                            "GetPage"   )
 	b.Handle("GET",     "/{modelId:int64}/{objectId:int64}/{attrId:int64}", "GetById"   )
 	b.Handle("POST",    "/add",                                             "Create"    )
 	b.Handle("PUT",     "/update",                                          "Update"    )
@@ -51,15 +51,15 @@ func (c *ObjectAttrController) GetById(modelId, objectId, attrId int64) *JsonRes
 
 func (c *ObjectAttrController) Create() *JsonResult {
 	userId := c.GetCurUserId()
+	
 	attr   := datamodels.ObjectAttr{}
 	attr.CreatedBy = userId
-	err := c.Ctx.ReadJSON(&attr)
-	if err != nil {
+	if err := c.Ctx.ReadJSON(&attr); err != nil {
 		return ResultErr("读取数据失败", nil)
 	}
 
-	err = c.Service.Create(&attr)
-	if err != nil {
+	
+	if err := c.Service.Create(&attr); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("新增成功", nil)
@@ -74,8 +74,8 @@ func (c *ObjectAttrController) Update() *JsonResult {
 	}
 
 	attr.UpdatedBy = userId
-	err := c.Service.Update(&attr)
-	if err != nil {
+	
+	if err := c.Service.Update(&attr); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("更新成功", nil)
@@ -89,8 +89,8 @@ func (c *ObjectAttrController) DeleteByID(modelId, objectId, attrId int64) *Json
 	m["objectId"]  = objectId
 	m["attrId"]    = attrId
 	m["deletedBy"] = userId
-	err := c.Service.Delete(m)
-	if err != nil {
+	
+	if err := c.Service.Delete(m); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("删除成功", nil)

+ 7 - 9
web/controllers/object_controller.go

@@ -12,8 +12,8 @@ type ObjectController struct {
 }
 
 func (c *ObjectController) BeforeActivation(b mvc.BeforeActivation) {
-	b.Handle("GET",         "/",                                 "GetList" )
-	b.Handle("GET",         "/page",                             "GetPage" )
+	b.Handle("GET",         "/",                                 "GetList"   )
+	b.Handle("GET",         "/page",                             "GetPage"   )
 	b.Handle("GET",         "/{modelId:int64}/{objectId:int64}", "GetById"   )
 	b.Handle("POST",        "/add",                              "Create"    )
 	b.Handle("PUT",         "/update",                           "Update"    )
@@ -68,9 +68,8 @@ func (c *ObjectController) Create() *JsonResult {
 	if err != nil {
 		return ResultErr("读取数据失败", nil)
 	}
-
-	err = c.Service.CreateObjectData(&objectData)
-	if err != nil {
+	
+	if err = c.Service.CreateObjectData(&objectData); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("新增成功", nil)
@@ -85,8 +84,7 @@ func (c *ObjectController) Update() *JsonResult {
 	}
 
 	objectData.UpdatedBy = userId
-	err := c.Service.UpdateObjectData(&objectData)
-	if err != nil {
+	if err := c.Service.UpdateObjectData(&objectData); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("更新成功", nil)
@@ -99,8 +97,8 @@ func (c *ObjectController) DeleteByID(modelId, objectId int64) *JsonResult {
 	m["modelId"]   = modelId
 	m["objectId"]  = objectId
 	m["deletedBy"] = userId
-	err := c.Service.Delete(m)
-	if err != nil {
+	
+	if err := c.Service.Delete(m); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("删除成功", nil)

+ 7 - 9
web/controllers/partner_cat_controller.go

@@ -53,13 +53,12 @@ func (c *PartnerCatController) Create() *JsonResult {
 	userId     := c.GetCurUserId()
 	partnerCat := datamodels.PartnerCat{}
 	partnerCat.CreatedBy = userId
-	err := c.Ctx.ReadJSON(&partnerCat)
-	if err != nil {
+	
+	if err := c.Ctx.ReadJSON(&partnerCat); err != nil {
 		return ResultErr("读取数据失败", nil)
 	}
-
-	err = c.Service.Create(&partnerCat)
-	if err != nil {
+	
+	if err := c.Service.Create(&partnerCat); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("新增成功", nil)
@@ -74,8 +73,7 @@ func (c *PartnerCatController) Update() *JsonResult {
 	}
 
 	partnerCat.UpdatedBy = userId
-	err := c.Service.Update(&partnerCat)
-	if err != nil {
+	if err := c.Service.Update(&partnerCat); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("更新成功", nil)
@@ -87,8 +85,8 @@ func (c *PartnerCatController) DeleteByID(partnerCatId int64) *JsonResult {
 	m := make(map[string]interface{})
 	m["partnerCatId"] = partnerCatId
 	m["deletedBy"] = userId
-	err := c.Service.Delete(m)
-	if err != nil {
+	
+	if err := c.Service.Delete(m); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("删除成功", nil)

+ 7 - 9
web/controllers/position_controller.go

@@ -52,17 +52,16 @@ func (c *PositionController) GetById(positionId int64) *JsonResult {
 func (c *PositionController) Create() *JsonResult {
 	ocId     := c.GetCurOcId()
 	userId   := c.GetCurUserId()
+	
 	position := datamodels.Position{}
 	position.OcId = ocId
 	position.CreatedBy = userId
-	err := c.Ctx.ReadJSON(&position)
-	if err != nil {
+	if err := c.Ctx.ReadJSON(&position); err != nil {
 		return ResultErr("读取数据失败", nil)
 	}
 	
 	position.OcId = ocId
-	err = c.Service.Create(&position)
-	if err != nil {
+	if err := c.Service.Create(&position); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("新增成功", nil)
@@ -77,10 +76,9 @@ func (c *PositionController) Update() *JsonResult {
 		return ResultErr("读取数据失败", nil)
 	}
 	
-	position.OcId = ocId
+	position.OcId      = ocId
 	position.UpdatedBy = userId
-	err := c.Service.Update(&position)
-	if err != nil {
+	if err := c.Service.Update(&position); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("更新成功", nil)
@@ -90,12 +88,12 @@ func (c *PositionController) Update() *JsonResult {
 func (c *PositionController) DeleteByID(positionId int64) *JsonResult {
 	ocId   := c.GetCurOcId()
 	userId := c.GetCurUserId()
+	
 	m := make(map[string]interface{})
 	m["ocId"]      = ocId
 	m["positionId"]= positionId
 	m["deletedBy"] = userId
-	err := c.Service.Delete(m)
-	if err != nil {
+	if err := c.Service.Delete(m); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("删除成功", nil)

+ 13 - 15
web/controllers/role_controller.go

@@ -12,12 +12,12 @@ type RoleController struct {
 }
 
 func (c *RoleController) BeforeActivation(b mvc.BeforeActivation) {
-	b.Handle("GET",         "/",                "GetList"       )
-	b.Handle("GET",         "/page",            "GetPage"       )
-	b.Handle("GET",         "/{roleId:int64}",  "GetById"       )
-	b.Handle("POST",        "/add",             "Create"        )
-	b.Handle("PUT",         "/update",          "Update"        )
-	b.Handle("DELETE",      "/{roleId:int64}",  "DeleteById"    )
+	b.Handle("GET",         "/",                    "GetList"       )
+	b.Handle("GET",         "/page",                "GetPage"       )
+	b.Handle("GET",         "/{roleId:int64}",      "GetById"       )
+	b.Handle("POST",        "/add",                 "Create"        )
+	b.Handle("PUT",         "/update",              "Update"        )
+	b.Handle("DELETE",      "/{roleId:int64}",      "DeleteById"    )
 }
 
 func (c *RoleController) GetList() *JsonResult {
@@ -51,13 +51,12 @@ func (c *RoleController) GetById(roleId int64) *JsonResult {
 
 func (c *RoleController) Create() *JsonResult {
 	role := &datamodels.Role{}
-	err  := c.Ctx.ReadJSON(role)
-	if err != nil {
+	
+	if err := c.Ctx.ReadJSON(role); err != nil {
 		return ResultErr("读取数据失败", nil)
 	}
 	
-	err = c.Service.Create(role)
-	if err != nil {
+	if err := c.Service.Create(role); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("新增成功", nil)
@@ -65,13 +64,12 @@ func (c *RoleController) Create() *JsonResult {
 }
 
 func (c *RoleController) Update() *JsonResult {
-	role   := &datamodels.Role{}
+	role := &datamodels.Role{}
 	if err := c.Ctx.ReadJSON(role); err != nil {
 		return ResultErr("读取数据失败", nil)
 	}
 	
-	err := c.Service.Update(role)
-	if err != nil {
+	if err := c.Service.Update(role); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("更新成功", nil)
@@ -80,11 +78,11 @@ func (c *RoleController) Update() *JsonResult {
 
 func (c *RoleController) DeleteById(roleId int64) *JsonResult {
 	userId := c.GetCurUserId()
+	
 	m := make(map[string]interface{})
 	m["roleId"]    = roleId
 	m["deletedBy"] = userId
-	err := c.Service.Delete(m)
-	if err != nil {
+	if err := c.Service.Delete(m); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("删除成功", nil)

+ 8 - 8
web/controllers/task_cat_controller.go

@@ -52,16 +52,16 @@ func (c *TaskCatController) GetById(taskCatId int64) *JsonResult {
 func (c *TaskCatController) Create() *JsonResult {
 	ocId    := c.GetCurOcId()
 	userId  := c.GetCurUserId()
+	
 	taskCat := datamodels.TaskCat{}
-	err := c.Ctx.ReadJSON(&taskCat)
-	if err != nil {
+	if err := c.Ctx.ReadJSON(&taskCat); err != nil {
 		return ResultErr("读取数据失败", nil)
 	}
 
 	taskCat.OcId      = ocId
 	taskCat.CreatedBy = userId
-	err = c.Service.Create(&taskCat)
-	if err != nil {
+	
+	if err := c.Service.Create(&taskCat); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("新增成功", nil)
@@ -71,6 +71,7 @@ func (c *TaskCatController) Create() *JsonResult {
 func (c *TaskCatController) Update() *JsonResult {
 	ocId    := c.GetCurOcId()
 	userId  := c.GetCurUserId()
+	
 	taskCat := datamodels.TaskCat{}
 	if err  := c.Ctx.ReadJSON(&taskCat); err != nil {
 		return ResultErr("读取数据失败", nil)
@@ -78,8 +79,8 @@ func (c *TaskCatController) Update() *JsonResult {
 
 	taskCat.OcId      = ocId
 	taskCat.UpdatedBy = userId
-	err := c.Service.Update(&taskCat)
-	if err != nil {
+	
+	if err := c.Service.Update(&taskCat); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("更新成功", nil)
@@ -94,8 +95,7 @@ func (c *TaskCatController) DeleteByID(taskCatId int64) *JsonResult {
 	m["ocId"]      = ocId
 	m["taskCatId"] = taskCatId
 	m["deletedBy"] = userId
-	err := c.Service.Delete(m)
-	if err != nil {
+	if err := c.Service.Delete(m); err != nil {
 		return ResultErr(err.Error(), nil)
 	} else {
 		return ResultOk("删除成功", nil)

+ 16 - 16
web/controllers/user_controller.go

@@ -61,15 +61,15 @@ func (c *UserController) GetById(groupId, accountId int64)*JsonResult {
 func (c *UserController) Create() *JsonResult {
     ocId     := c.GetCurOcId()
     ocTypeId := c.GetOcTypeId()
+    
     user     := &viewmodels.UserInfo{}
-    err := c.Ctx.ReadJSON(user)
-    if err != nil {
+    if err := c.Ctx.ReadJSON(user); err != nil {
         return ResultErr("读取数据失败", nil)
     }
     
     user.OcId = ocId
-    err = c.Service.Create(ocTypeId, user)
-    if err != nil {
+    
+    if err := c.Service.Create(ocTypeId, user); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
         return ResultOk("新增成功", nil)
@@ -78,12 +78,12 @@ func (c *UserController) Create() *JsonResult {
 
 func (c *UserController) Update() *JsonResult {
     user := &viewmodels.UserInfo{}
-    err  := c.Ctx.ReadJSON(user)
-    if err != nil {
+    
+    if err := c.Ctx.ReadJSON(user); err != nil {
         return ResultErr("读取数据失败", nil)
     }
-    err = c.Service.Update(user)
-    if err != nil {
+    
+    if err := c.Service.Update(user); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
         return ResultOk("更新成功", nil)
@@ -93,8 +93,8 @@ func (c *UserController) Update() *JsonResult {
 func (c *UserController) UpdatePassword(psw string)*JsonResult{
     ocId   := c.GetCurOcId()
     userId := c.GetCurUserId()
-    err    := c.Service.UpdatePassword(ocId, userId, psw)
-    if err != nil {
+    
+    if err := c.Service.UpdatePassword(ocId, userId, psw); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
         return ResultOk("密码更新成功", nil)
@@ -103,8 +103,8 @@ func (c *UserController) UpdatePassword(psw string)*JsonResult{
 
 func (c *UserController) ResetPassword(userId int64)*JsonResult{
     ocId := c.GetCurOcId()
-    err  := c.Service.ResetPassword(ocId, userId)
-    if err != nil {
+    
+    if err := c.Service.ResetPassword(ocId, userId); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
         return ResultOk("密码重置成功", nil)
@@ -113,8 +113,8 @@ func (c *UserController) ResetPassword(userId int64)*JsonResult{
 
 func (c *UserController) UpdateStatus(userId, status int64)*JsonResult{
     ocId := c.GetCurOcId()
-    err  := c.Service.ChangeStatus(ocId, userId, status)
-    if err != nil {
+    
+    if err := c.Service.ChangeStatus(ocId, userId, status); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
         return ResultOk("状态变更成功", nil)
@@ -129,8 +129,8 @@ func (c *UserController) DeleteById(accountId int64)*JsonResult {
     m["ocId"]      = ocId
     m["accountId"] = accountId
     m["deletedBy"] = userId
-    err := c.Service.Delete(m)
-    if err != nil {
+    
+    if err := c.Service.Delete(m); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
         return ResultOk("删除成功", nil)