提交
This commit is contained in:
@@ -170,6 +170,7 @@ func CreateUserHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
httpx.Fail(w, 1006, err.Error())
|
||||
return
|
||||
}
|
||||
svcCtx.EventLog.Write(r.Context(), "user.create", "", ctxOperator(r), "user", req.Username, "创建用户 "+req.Username, nil)
|
||||
httpx.OkMessage(w, "创建成功", nil)
|
||||
}
|
||||
}
|
||||
@@ -185,6 +186,7 @@ func UpdateUserHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
httpx.Fail(w, 1007, err.Error())
|
||||
return
|
||||
}
|
||||
svcCtx.EventLog.Write(r.Context(), "user.update", "", ctxOperator(r), "user", req.Username, "更新用户 "+req.Username, nil)
|
||||
httpx.OkMessage(w, "更新成功", nil)
|
||||
}
|
||||
}
|
||||
@@ -195,6 +197,7 @@ func DeleteUserHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
httpx.Fail(w, 1008, err.Error())
|
||||
return
|
||||
}
|
||||
svcCtx.EventLog.Write(r.Context(), "user.delete", "", ctxOperator(r), "user", strconv.Itoa(pathId(r)), "删除用户 id="+strconv.Itoa(pathId(r)), nil)
|
||||
httpx.OkMessage(w, "删除成功", nil)
|
||||
}
|
||||
}
|
||||
@@ -220,7 +223,8 @@ func ChangePasswordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
|
||||
func ListRolesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
data, err := logic.New(svcCtx).ListRoles(r.Context())
|
||||
keyword := strings.TrimSpace(r.URL.Query().Get("keyword"))
|
||||
data, err := logic.New(svcCtx).ListRoles(r.Context(), keyword)
|
||||
if err != nil {
|
||||
httpx.Fail(w, 1009, err.Error())
|
||||
return
|
||||
@@ -240,6 +244,7 @@ func CreateRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
httpx.Fail(w, 1010, err.Error())
|
||||
return
|
||||
}
|
||||
svcCtx.EventLog.Write(r.Context(), "role.create", "", ctxOperator(r), "role", req.Code, "创建角色 "+req.Name, nil)
|
||||
httpx.OkMessage(w, "创建成功", nil)
|
||||
}
|
||||
}
|
||||
@@ -255,6 +260,7 @@ func UpdateRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
httpx.Fail(w, 1011, err.Error())
|
||||
return
|
||||
}
|
||||
svcCtx.EventLog.Write(r.Context(), "role.update", "", ctxOperator(r), "role", req.Code, "更新角色 "+req.Name, nil)
|
||||
httpx.OkMessage(w, "更新成功", nil)
|
||||
}
|
||||
}
|
||||
@@ -265,6 +271,7 @@ func DeleteRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
httpx.Fail(w, 1012, err.Error())
|
||||
return
|
||||
}
|
||||
svcCtx.EventLog.Write(r.Context(), "role.delete", "", ctxOperator(r), "role", strconv.Itoa(pathId(r)), "删除角色 id="+strconv.Itoa(pathId(r)), nil)
|
||||
httpx.OkMessage(w, "删除成功", nil)
|
||||
}
|
||||
}
|
||||
@@ -293,6 +300,7 @@ func CreatePermissionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
httpx.Fail(w, 1014, err.Error())
|
||||
return
|
||||
}
|
||||
svcCtx.EventLog.Write(r.Context(), "rbac.permission.create", "", ctxOperator(r), "permission", req.Code, "创建权限 "+req.Name, nil)
|
||||
httpx.OkMessage(w, "创建成功", nil)
|
||||
}
|
||||
}
|
||||
@@ -308,6 +316,7 @@ func UpdatePermissionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
httpx.Fail(w, 1015, err.Error())
|
||||
return
|
||||
}
|
||||
svcCtx.EventLog.Write(r.Context(), "rbac.permission.update", "", ctxOperator(r), "permission", req.Code, "更新权限 "+req.Name, nil)
|
||||
httpx.OkMessage(w, "更新成功", nil)
|
||||
}
|
||||
}
|
||||
@@ -318,6 +327,7 @@ func DeletePermissionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
httpx.Fail(w, 1016, err.Error())
|
||||
return
|
||||
}
|
||||
svcCtx.EventLog.Write(r.Context(), "rbac.permission.delete", "", ctxOperator(r), "permission", strconv.Itoa(pathId(r)), "删除权限 id="+strconv.Itoa(pathId(r)), nil)
|
||||
httpx.OkMessage(w, "删除成功", nil)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user