houyaf 3 年之前
父节点
当前提交
1d51f3f5f9
共有 1 个文件被更改,包括 10 次插入5 次删除
  1. 10 5
      web/controllers/role_controller.go

+ 10 - 5
web/controllers/role_controller.go

@@ -25,8 +25,9 @@ func (c *RoleController) GetByList() *JsonResult {
 	data, err := c.Service.GetByList(params)
 	if err != nil {
 		return ResultErr(err.Error(), nil)
+	} else {
+		return ResultOk("获取成功", data)
 	}
-	return ResultOk("获取成功", data)
 }
 
 func (c *RoleController) GetByPage() *JsonResult {
@@ -34,24 +35,27 @@ func (c *RoleController) GetByPage() *JsonResult {
 	data, err := c.Service.GetByPage(params)
 	if err != nil {
 		return ResultErr(err.Error(), nil)
+	} else {
+		return ResultOk("获取成功", data)
 	}
-	return ResultOk("获取成功", data)
 }
 
 func (c *RoleController) GetById(roleId int64) *JsonResult {
 	data, err := c.Service.GetById(roleId)
 	if err != nil {
 		return ResultErr(err.Error(), nil)
+	} else {
+		return ResultOk("获取成功", data)
 	}
-	return ResultOk("获取成功", data)
 }
 
 func (c *RoleController) Create() *JsonResult {
 	role := &datamodels.Role{}
-	err := c.Ctx.ReadJSON(role)
+	err  := c.Ctx.ReadJSON(role)
 	if err != nil {
 		return ResultErr("读取数据失败", nil)
 	}
+	
 	err = c.Service.Create(role)
 	if err != nil {
 		return ResultErr(err.Error(), nil)
@@ -65,6 +69,7 @@ func (c *RoleController) Update() *JsonResult {
 	if err := c.Ctx.ReadJSON(role); err != nil {
 		return ResultErr("读取数据失败", nil)
 	}
+	
 	err := c.Service.Update(role)
 	if err != nil {
 		return ResultErr(err.Error(), nil)
@@ -76,7 +81,7 @@ func (c *RoleController) Update() *JsonResult {
 func (c *RoleController) DeleteById(roleId int64) *JsonResult {
 	userId := c.GetCurUserId()
 	
-	var m  = make(map[string]interface{})
+	m  := make(map[string]interface{})
 	m["roleId"]    = roleId
 	m["deletedBy"] = userId
 	err := c.Service.Delete(m)