mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-12 03:33:33 +08:00
@@ -1016,9 +1016,8 @@ func (h *Handler) RemoveIngestionTasks(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Task ID is required")
|
||||
return
|
||||
}
|
||||
|
||||
ctx := c.Request.Context()
|
||||
if req.Email == nil && req.Status == nil {
|
||||
ctx := c.Request.Context()
|
||||
tasks, err := h.service.RemoveIngestionTasks(ctx, req.Tasks)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, handler.IngestionTaskErrorCode(err), err.Error())
|
||||
@@ -1027,7 +1026,7 @@ func (h *Handler) RemoveIngestionTasks(c *gin.Context) {
|
||||
|
||||
common.SuccessWithData(c, tasks, "Remove tasks successfully")
|
||||
} else {
|
||||
tasks, err := h.service.RemoveIngestionTasksByCondition(req.Tasks, req.Email, req.Status)
|
||||
tasks, err := h.service.RemoveIngestionTasksByCondition(ctx, req.Tasks, req.Email, req.Status)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, handler.IngestionTaskErrorCode(err), err.Error())
|
||||
return
|
||||
@@ -1048,9 +1047,8 @@ func (h *Handler) StopIngestionTasks(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Task ID is required")
|
||||
return
|
||||
}
|
||||
|
||||
ctx := c.Request.Context()
|
||||
if req.Email == nil && req.Status == nil {
|
||||
ctx := c.Request.Context()
|
||||
tasks, err := h.service.StopIngestionTasks(ctx, req.Tasks)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, handler.IngestionTaskErrorCode(err), err.Error())
|
||||
@@ -1066,7 +1064,7 @@ func (h *Handler) StopIngestionTasks(c *gin.Context) {
|
||||
|
||||
common.SuccessWithData(c, result, "Stop tasks successfully")
|
||||
} else {
|
||||
tasks, err := h.service.StopIngestionTasksByCondition(req.Tasks, req.Email, req.Status)
|
||||
tasks, err := h.service.StopIngestionTasksByCondition(ctx, req.Tasks, req.Email, req.Status)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, err.Error())
|
||||
return
|
||||
|
||||
@@ -30,7 +30,8 @@ import (
|
||||
|
||||
// ListRoles handle list roles
|
||||
func (h *Handler) ListRoles(c *gin.Context) {
|
||||
roles, err := h.service.ListRoles()
|
||||
ctx := c.Request.Context()
|
||||
roles, err := h.service.ListRoles(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -57,7 +58,8 @@ func (h *Handler) CreateRole(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
role, err := h.service.CreateRole(req.RoleName, req.Description)
|
||||
ctx := c.Request.Context()
|
||||
role, err := h.service.CreateRole(ctx, req.RoleName, req.Description)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -74,7 +76,8 @@ func (h *Handler) ShowRole(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
role, err := h.service.ShowRole(roleName)
|
||||
ctx := c.Request.Context()
|
||||
role, err := h.service.ShowRole(ctx, roleName)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -102,7 +105,8 @@ func (h *Handler) UpdateRole(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
role, err := h.service.UpdateRole(roleName, req.Description)
|
||||
ctx := c.Request.Context()
|
||||
role, err := h.service.UpdateRole(ctx, roleName, req.Description)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -119,7 +123,8 @@ func (h *Handler) DropRole(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
role, err := h.service.DropRole(roleName)
|
||||
ctx := c.Request.Context()
|
||||
role, err := h.service.DropRole(ctx, roleName)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeNotFound, "Role not found")
|
||||
return
|
||||
@@ -136,7 +141,8 @@ func (h *Handler) ShowRolePermission(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
permissions, err := h.service.ShowRolePermission(roleName)
|
||||
ctx := c.Request.Context()
|
||||
permissions, err := h.service.ShowRolePermission(ctx, roleName)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -165,7 +171,8 @@ func (h *Handler) GrantRolePermission(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.service.GrantRolePermission(roleName, req.Actions, req.Resource)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.GrantRolePermission(ctx, roleName, req.Actions, req.Resource)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -194,7 +201,8 @@ func (h *Handler) RevokeRolePermission(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.service.RevokeRolePermission(roleName, req.Actions, req.Resource)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.RevokeRolePermission(ctx, roleName, req.Actions, req.Resource)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -205,7 +213,8 @@ func (h *Handler) RevokeRolePermission(c *gin.Context) {
|
||||
|
||||
// ListResources handle list role resources
|
||||
func (h *Handler) ListResources(c *gin.Context) {
|
||||
resources, err := h.service.ListResources()
|
||||
ctx := c.Request.Context()
|
||||
resources, err := h.service.ListResources(ctx)
|
||||
if err != nil {
|
||||
if errors.Is(err, common.ErrUserNotFound) {
|
||||
common.ErrorWithCode(c, common.CodeNotFound, "Role not found")
|
||||
@@ -220,7 +229,8 @@ func (h *Handler) ListResources(c *gin.Context) {
|
||||
|
||||
// ListRolesWithPermission handle list roles with permission
|
||||
func (h *Handler) ListRolesWithPermission(c *gin.Context) {
|
||||
roles, err := h.service.ListRolesWithPermission()
|
||||
ctx := c.Request.Context()
|
||||
roles, err := h.service.ListRolesWithPermission(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -236,7 +246,8 @@ func (h *Handler) ShowRoleDefaultModels(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.service.ShowRoleDefaultModels(roleName)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.ShowRoleDefaultModels(ctx, roleName)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -261,7 +272,8 @@ func (h *Handler) SetRoleDefaultModel(c *gin.Context) {
|
||||
common.ResponseWithHttpCodeData(c, http.StatusBadRequest, common.CodeBadRequest, nil, "Invalid request body: "+err.Error())
|
||||
}
|
||||
|
||||
result, err := h.service.SetRoleDefaultModel(roleName, request.ModelID, request.ModelType)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.SetRoleDefaultModel(ctx, roleName, request.ModelID, request.ModelType)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -286,7 +298,8 @@ func (h *Handler) ResetRoleDefaultModel(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.service.ResetRoleDefaultModel(roleName, request.ModelType)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.ResetRoleDefaultModel(ctx, roleName, request.ModelType)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -304,7 +317,8 @@ func (h *Handler) ListModelProviders(c *gin.Context) {
|
||||
// convert keywords to small case
|
||||
keywords = strings.ToLower(keywords)
|
||||
|
||||
result, err := h.service.ListModelProviders()
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.ListModelProviders(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -325,8 +339,8 @@ func (h *Handler) AddModelProvider(c *gin.Context) {
|
||||
}
|
||||
|
||||
userID := c.GetString("user_id")
|
||||
|
||||
result, err := h.service.AddModelProvider(req.ProviderName, userID)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.AddModelProvider(ctx, req.ProviderName, userID)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -362,8 +376,8 @@ func (h *Handler) DeleteModelProvider(c *gin.Context) {
|
||||
}
|
||||
|
||||
userID := c.GetString("user_id")
|
||||
|
||||
result, err := h.service.DeleteModelProviders(userID, req.ProviderNames)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.DeleteModelProviders(ctx, userID, req.ProviderNames)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -414,8 +428,8 @@ func (h *Handler) ListModelInstances(c *gin.Context) {
|
||||
}
|
||||
|
||||
userID := c.GetString("user_id")
|
||||
|
||||
result, err := h.service.ListModelInstances(userID, providerName)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.ListModelInstances(ctx, userID, providerName)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -436,8 +450,8 @@ func (h *Handler) ShowProviderInstance(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
userID := c.GetString("user_id")
|
||||
|
||||
result, err := h.service.ShowProviderInstance(userID, providerName, instanceName)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.ShowProviderInstance(ctx, userID, providerName, instanceName)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -458,8 +472,8 @@ func (h *Handler) ShowProviderInstanceBalance(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
userID := c.GetString("user_id")
|
||||
|
||||
result, err := h.service.ShowProviderInstanceBalance(userID, providerName, instanceName)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.ShowProviderInstanceBalance(ctx, userID, providerName, instanceName)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -480,8 +494,8 @@ func (h *Handler) CheckInstanceConnection(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
userID := c.GetString("user_id")
|
||||
|
||||
result, err := h.service.CheckInstanceConnection(userID, providerName, instanceName)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.CheckInstanceConnection(ctx, userID, providerName, instanceName)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -510,8 +524,8 @@ func (h *Handler) CheckProviderConnection(c *gin.Context) {
|
||||
}
|
||||
|
||||
userID := c.GetString("user_id")
|
||||
|
||||
result, err := h.service.CheckProviderConnection(userID, providerName, req.Region, req.APIKey, req.BaseURL)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.CheckProviderConnection(ctx, userID, providerName, req.Region, req.APIKey, req.BaseURL)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -549,8 +563,8 @@ func (h *Handler) AlterProviderInstance(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeUnauthorized, "Unauthorized")
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.service.AlterProviderInstance(userID, providerName, instanceName, req.InstanceName, req.APIKey)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.AlterProviderInstance(ctx, userID, providerName, instanceName, req.InstanceName, req.APIKey)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -577,8 +591,8 @@ func (h *Handler) AddModelInstance(c *gin.Context) {
|
||||
}
|
||||
|
||||
userID := c.GetString("user_id")
|
||||
|
||||
result, err := h.service.AddModelInstance(userID, providerName, req.InstanceName)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.AddModelInstance(ctx, userID, providerName, req.InstanceName)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -605,8 +619,8 @@ func (h *Handler) DeleteModelInstance(c *gin.Context) {
|
||||
}
|
||||
|
||||
userID := c.GetString("user_id")
|
||||
|
||||
result, err := h.service.DeleteModelInstances(userID, providerName, req.InstanceNames)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.DeleteModelInstances(ctx, userID, providerName, req.InstanceNames)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -629,8 +643,8 @@ func (h *Handler) ListInstanceModels(c *gin.Context) {
|
||||
}
|
||||
|
||||
userID := c.GetString("user_id")
|
||||
|
||||
result, err := h.service.ListInstanceModels(userID, providerName, instanceName)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.ListInstanceModels(ctx, userID, providerName, instanceName)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -673,8 +687,8 @@ func (h *Handler) EnableOrDisableModel(c *gin.Context) {
|
||||
}
|
||||
|
||||
userID := c.GetString("user_id")
|
||||
|
||||
result, err := h.service.EnableOrDisableModel(userID, providerName, instanceName, modelName, modelID, req.Status)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.EnableOrDisableModel(ctx, userID, providerName, instanceName, modelName, modelID, req.Status)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -707,8 +721,8 @@ func (h *Handler) AddModels(c *gin.Context) {
|
||||
}
|
||||
|
||||
userID := c.GetString("user_id")
|
||||
|
||||
result, err := h.service.AddModels(userID, providerName, instanceName, req.ModelNames)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.AddModels(ctx, userID, providerName, instanceName, req.ModelNames)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -741,8 +755,8 @@ func (h *Handler) DeleteModels(c *gin.Context) {
|
||||
}
|
||||
|
||||
userID := c.GetString("user_id")
|
||||
|
||||
result, err := h.service.DeleteModels(userID, providerName, instanceName, req.ModelNames)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.DeleteModels(ctx, userID, providerName, instanceName, req.ModelNames)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -753,7 +767,8 @@ func (h *Handler) DeleteModels(c *gin.Context) {
|
||||
|
||||
// GetSystemFingerprint handle get system fingerprint
|
||||
func (h *Handler) GetSystemFingerprint(c *gin.Context) {
|
||||
fingerprint, err := h.service.GetSystemFingerprint()
|
||||
ctx := c.Request.Context()
|
||||
fingerprint, err := h.service.GetSystemFingerprint(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -774,8 +789,9 @@ func (h *Handler) SetSystemLicense(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
err := h.service.SetSystemLicense(req.License)
|
||||
err := h.service.SetSystemLicense(ctx, req.License)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -794,7 +810,9 @@ func (h *Handler) ShowSystemLicense(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
systemLicense, err := h.service.ShowSystemLicense(checkFlag)
|
||||
ctx := c.Request.Context()
|
||||
|
||||
systemLicense, err := h.service.ShowSystemLicense(ctx, checkFlag)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -815,7 +833,8 @@ func (h *Handler) UpdateSystemLicenseConfig(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
result, err := h.service.UpdateSystemLicenseConfig(req.TimeRecordSaveInterval, req.TimeRecordTaskDuration)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.UpdateSystemLicenseConfig(ctx, req.TimeRecordSaveInterval, req.TimeRecordTaskDuration)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -834,8 +853,9 @@ func (h *Handler) SetSoftFingerprint(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
err := h.service.SetSoftFingerprint(req.SoftFingerprint)
|
||||
err := h.service.SetSoftFingerprint(ctx, req.SoftFingerprint)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -845,7 +865,9 @@ func (h *Handler) SetSoftFingerprint(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *Handler) ShowSoftFingerprint(c *gin.Context) {
|
||||
softFingerprint, err := h.service.GetSoftFingerprint()
|
||||
ctx := c.Request.Context()
|
||||
|
||||
softFingerprint, err := h.service.GetSoftFingerprint(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -855,7 +877,9 @@ func (h *Handler) ShowSoftFingerprint(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *Handler) DeleteSoftFingerprint(c *gin.Context) {
|
||||
err := h.service.DeleteSoftFingerprint()
|
||||
ctx := c.Request.Context()
|
||||
|
||||
err := h.service.DeleteSoftFingerprint(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -877,7 +901,9 @@ func (h *Handler) ShowUserActivity(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
userActivity, err := h.service.ShowUserActivity(req.Email, req.Days)
|
||||
ctx := c.Request.Context()
|
||||
|
||||
userActivity, err := h.service.ShowUserActivity(ctx, req.Email, req.Days)
|
||||
if err != nil {
|
||||
if errors.Is(err, common.ErrUserNotFound) {
|
||||
common.ErrorWithCode(c, common.CodeNotFound, "User not found")
|
||||
@@ -907,8 +933,9 @@ func (h *Handler) ShowUserDatasetSummary(c *gin.Context) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
userDatasetSummary, err := h.service.ShowUserDatasetSummary(username, req.Dataset)
|
||||
userDatasetSummary, err := h.service.ShowUserDatasetSummary(ctx, username, req.Dataset)
|
||||
if err != nil {
|
||||
if errors.Is(err, common.ErrUserNotFound) {
|
||||
common.ErrorWithCode(c, common.CodeNotFound, "User not found")
|
||||
@@ -950,7 +977,9 @@ func (h *Handler) ShowUserStorage(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
userStorage, err := h.service.ShowUserStorage(username)
|
||||
ctx := c.Request.Context()
|
||||
|
||||
userStorage, err := h.service.ShowUserStorage(ctx, username)
|
||||
if err != nil {
|
||||
if errors.Is(err, common.ErrUserNotFound) {
|
||||
common.ErrorWithCode(c, common.CodeNotFound, "User not found")
|
||||
@@ -992,7 +1021,9 @@ func (h *Handler) ShowUserIndex(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
userIndex, err := h.service.ShowUserIndex(username)
|
||||
ctx := c.Request.Context()
|
||||
|
||||
userIndex, err := h.service.ShowUserIndex(ctx, username)
|
||||
if err != nil {
|
||||
if errors.Is(err, common.ErrUserNotFound) {
|
||||
common.ErrorWithCode(c, common.CodeNotFound, "User not found")
|
||||
@@ -1022,8 +1053,9 @@ func (h *Handler) UpdateUserRole(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Role name is required")
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
result, err := h.service.UpdateUserRole(username, req.RoleName)
|
||||
result, err := h.service.UpdateUserRole(ctx, username, req.RoleName)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1039,7 +1071,9 @@ func (h *Handler) ShowUserPermission(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
permissions, err := h.service.ShowUserPermission(username)
|
||||
ctx := c.Request.Context()
|
||||
|
||||
permissions, err := h.service.ShowUserPermission(ctx, username)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1054,8 +1088,9 @@ func (h *Handler) ListUserDatasets(c *gin.Context) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
datasets, err := h.service.ListUserDatasets(username)
|
||||
datasets, err := h.service.ListUserDatasets(ctx, username)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1070,8 +1105,9 @@ func (h *Handler) ListUserAgents(c *gin.Context) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
agents, err := h.service.ListUserAgents(username)
|
||||
agents, err := h.service.ListUserAgents(ctx, username)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1086,8 +1122,9 @@ func (h *Handler) ListUserChats(c *gin.Context) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
chats, err := h.service.ListUserChats(username)
|
||||
chats, err := h.service.ListUserChats(ctx, username)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1102,8 +1139,9 @@ func (h *Handler) ListUserSearches(c *gin.Context) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
searches, err := h.service.ListUserSearches(username)
|
||||
searches, err := h.service.ListUserSearches(ctx, username)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1118,8 +1156,9 @@ func (h *Handler) ListUserModels(c *gin.Context) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
models, err := h.service.ListUserModels(username)
|
||||
models, err := h.service.ListUserModels(ctx, username)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1134,8 +1173,9 @@ func (h *Handler) ListUserFiles(c *gin.Context) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
files, err := h.service.ListUserFiles(username)
|
||||
files, err := h.service.ListUserFiles(ctx, username)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1150,8 +1190,9 @@ func (h *Handler) ListUserProviders(c *gin.Context) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
providers, err := h.service.ListUserProviders(username)
|
||||
providers, err := h.service.ListUserProviders(ctx, username)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1178,8 +1219,9 @@ func (h *Handler) ListUserProviderInstances(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Provider name is required")
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
instances, err := h.service.ListUserProviderInstances(userName, providerName)
|
||||
instances, err := h.service.ListUserProviderInstances(ctx, userName, providerName)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1212,8 +1254,9 @@ func (h *Handler) ListUserProviderInstanceModels(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Instance name is required")
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
models, err := h.service.ListUserProviderInstanceModels(userName, providerName, instanceName)
|
||||
models, err := h.service.ListUserProviderInstanceModels(ctx, userName, providerName, instanceName)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1234,8 +1277,9 @@ func (h *Handler) ListUserDefaultModels(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Username is required")
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
models, err := h.service.ListUserDefaultModels(userName)
|
||||
models, err := h.service.ListUserDefaultModels(ctx, userName)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1246,7 +1290,9 @@ func (h *Handler) ListUserDefaultModels(c *gin.Context) {
|
||||
|
||||
// ShowUsersSummary handle show users summary
|
||||
func (h *Handler) ShowUsersSummary(c *gin.Context) {
|
||||
usersSummary, err := h.service.ShowUsersSummary()
|
||||
ctx := c.Request.Context()
|
||||
|
||||
usersSummary, err := h.service.ShowUsersSummary(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1268,7 +1314,9 @@ func (h *Handler) ShowUsersActivity(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
usersActivity, err := h.service.ShowUsersActivity(req.Days, req.Window)
|
||||
ctx := c.Request.Context()
|
||||
|
||||
usersActivity, err := h.service.ShowUsersActivity(ctx, req.Days, req.Window)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1311,8 +1359,9 @@ func (h *Handler) ListUsersReports(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
usersReports, err := h.service.ListUsersReports(pageIndex, pageSize, req.Status, req.Plan, req.Days)
|
||||
usersReports, err := h.service.ListUsersReports(ctx, pageIndex, pageSize, req.Status, req.Plan, req.Days)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1351,8 +1400,9 @@ func (h *Handler) ListUsersStorage(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Top must be an integer")
|
||||
}
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
usersStorage, err := h.service.ListUsersStorage(pageIndex, pageSize, top)
|
||||
usersStorage, err := h.service.ListUsersStorage(ctx, pageIndex, pageSize, top)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1391,8 +1441,9 @@ func (h *Handler) ListUsersDocuments(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Top must be an integer")
|
||||
}
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
usersDocuments, err := h.service.ListUsersDocuments(pageIndex, pageSize, top)
|
||||
usersDocuments, err := h.service.ListUsersDocuments(ctx, pageIndex, pageSize, top)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1431,8 +1482,9 @@ func (h *Handler) ListUsersIndex(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Top must be an integer")
|
||||
}
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
usersIndex, err := h.service.ListUsersIndex(pageIndex, pageSize, top)
|
||||
usersIndex, err := h.service.ListUsersIndex(ctx, pageIndex, pageSize, top)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1483,8 +1535,9 @@ func (h *Handler) ListUsersQuota(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Top must be an integer")
|
||||
}
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
usersQuota, err := h.service.ListUsersQuota(pageIndex, pageSize, top, request.QuotaThreshold, request.Plan, request.Days)
|
||||
usersQuota, err := h.service.ListUsersQuota(ctx, pageIndex, pageSize, top, request.QuotaThreshold, request.Plan, request.Days)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1495,7 +1548,8 @@ func (h *Handler) ListUsersQuota(c *gin.Context) {
|
||||
|
||||
// ShowUsersPlanSummary handle show users plan summary
|
||||
func (h *Handler) ShowUsersPlanSummary(c *gin.Context) {
|
||||
usersPlanSummary, err := h.service.ShowUsersPlanSummary()
|
||||
ctx := c.Request.Context()
|
||||
usersPlanSummary, err := h.service.ShowUsersPlanSummary(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1516,7 +1570,8 @@ func (h *Handler) ShowUsersPlan(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
usersPlanQuota, err := h.service.ShowUsersPlanQuota(quota)
|
||||
ctx := c.Request.Context()
|
||||
usersPlanQuota, err := h.service.ShowUsersPlanQuota(ctx, quota)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1527,7 +1582,8 @@ func (h *Handler) ShowUsersPlan(c *gin.Context) {
|
||||
|
||||
// ShowUsersQuotaSummary handle show users quota summary
|
||||
func (h *Handler) ShowUsersQuotaSummary(c *gin.Context) {
|
||||
usersQuotaSummary, err := h.service.ShowUsersQuotaSummary()
|
||||
ctx := c.Request.Context()
|
||||
usersQuotaSummary, err := h.service.ShowUsersQuotaSummary(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1538,7 +1594,8 @@ func (h *Handler) ShowUsersQuotaSummary(c *gin.Context) {
|
||||
|
||||
// ShowIngestionTasksSummary handle show ingestion tasks summary
|
||||
func (h *Handler) ShowIngestionTasksSummary(c *gin.Context) {
|
||||
ingestionTasksSummary, err := h.service.ShowIngestionTasksSummary()
|
||||
ctx := c.Request.Context()
|
||||
ingestionTasksSummary, err := h.service.ShowIngestionTasksSummary(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1549,7 +1606,8 @@ func (h *Handler) ShowIngestionTasksSummary(c *gin.Context) {
|
||||
|
||||
// ShowDataSummary handle show data summary
|
||||
func (h *Handler) ShowDataSummary(c *gin.Context) {
|
||||
dataSummary, err := h.service.ShowDataSummary()
|
||||
ctx := c.Request.Context()
|
||||
dataSummary, err := h.service.ShowDataSummary(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1560,7 +1618,8 @@ func (h *Handler) ShowDataSummary(c *gin.Context) {
|
||||
|
||||
// ShowDataOrphan handle show data orphan
|
||||
func (h *Handler) ShowDataOrphan(c *gin.Context) {
|
||||
dataOrphan, err := h.service.ShowDataOrphan()
|
||||
ctx := c.Request.Context()
|
||||
dataOrphan, err := h.service.ShowDataOrphan(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1571,7 +1630,8 @@ func (h *Handler) ShowDataOrphan(c *gin.Context) {
|
||||
|
||||
// ShowDataStorage handle show data storage
|
||||
func (h *Handler) ShowDataStorage(c *gin.Context) {
|
||||
dataStorage, err := h.service.ShowDataStorage()
|
||||
ctx := c.Request.Context()
|
||||
dataStorage, err := h.service.ShowDataStorage(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1582,7 +1642,8 @@ func (h *Handler) ShowDataStorage(c *gin.Context) {
|
||||
|
||||
// ShowDataIndex handle show data index
|
||||
func (h *Handler) ShowDataIndex(c *gin.Context) {
|
||||
dataIndex, err := h.service.ShowDataIndex()
|
||||
ctx := c.Request.Context()
|
||||
dataIndex, err := h.service.ShowDataIndex(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1603,7 +1664,8 @@ func (h *Handler) PurgeOrphanData(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
result, err := h.service.PurgeOrphanData(request.Preview)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.PurgeOrphanData(ctx, request.Preview)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1628,8 +1690,8 @@ func (h *Handler) PurgeUserData(c *gin.Context) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.service.PurgeUserData(username, request.Preview)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.PurgeUserData(ctx, username, request.Preview)
|
||||
if err != nil {
|
||||
if errors.Is(err, common.ErrUserNotFound) {
|
||||
common.ErrorWithCode(c, common.CodeNotFound, "User not found")
|
||||
@@ -1657,8 +1719,8 @@ func (h *Handler) PurgeUsersData(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.service.PurgeUsersData(request.Preview, request.Days, request.Plan, request.UserStatus)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.PurgeUsersData(ctx, request.Preview, request.Days, request.Plan, request.UserStatus)
|
||||
if err != nil {
|
||||
if errors.Is(err, common.ErrUserNotFound) {
|
||||
common.ErrorWithCode(c, common.CodeNotFound, "User not found")
|
||||
@@ -1736,7 +1798,8 @@ func (h *Handler) ListUserAPIKeys(c *gin.Context) {
|
||||
|
||||
// DownloadSensitiveWords handle download sensitive words
|
||||
func (h *Handler) DownloadSensitiveWords(c *gin.Context) {
|
||||
result, err := h.service.DownloadSensitiveWords()
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.DownloadSensitiveWords(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1764,7 +1827,8 @@ func (h *Handler) UploadSensitiveWords(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
file := files[0]
|
||||
result, err := h.service.UploadSensitiveWords(file)
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.UploadSensitiveWords(ctx, file)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1795,8 +1859,9 @@ func (h *Handler) BindVerificationEmail(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Email, host, username, and password are required")
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
result, err := h.service.BindVerificationEmail(request.Email, request.Host, request.Port, request.Username, request.Password, request.UseTLS, request.UseSSL)
|
||||
result, err := h.service.BindVerificationEmail(ctx, request.Email, request.Host, request.Port, request.Username, request.Password, request.UseTLS, request.UseSSL)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1807,7 +1872,8 @@ func (h *Handler) BindVerificationEmail(c *gin.Context) {
|
||||
|
||||
// ShowVerificationEmail handle show verification email
|
||||
func (h *Handler) ShowVerificationEmail(c *gin.Context) {
|
||||
result, err := h.service.ShowVerificationEmail()
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.ShowVerificationEmail(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1818,7 +1884,8 @@ func (h *Handler) ShowVerificationEmail(c *gin.Context) {
|
||||
|
||||
// ShowWhiteList handle show white list
|
||||
func (h *Handler) ShowWhiteList(c *gin.Context) {
|
||||
result, err := h.service.ShowWhiteList()
|
||||
ctx := c.Request.Context()
|
||||
result, err := h.service.ShowWhiteList(ctx)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1842,8 +1909,9 @@ func (h *Handler) AddWhiteList(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Email is required")
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
result, err := h.service.AddWhiteList(request.Email)
|
||||
result, err := h.service.AddWhiteList(ctx, request.Email)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1870,8 +1938,9 @@ func (h *Handler) BatchAddWhiteList(c *gin.Context) {
|
||||
common.ResponseWithCodeData(c, common.CodeArgumentError, nil, "Only one file is allowed")
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
file := files[0]
|
||||
result, err := h.service.BatchAddWhiteList(file)
|
||||
result, err := h.service.BatchAddWhiteList(ctx, file)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1893,8 +1962,9 @@ func (h *Handler) UpdateWhiteList(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Email is required")
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
result, err := h.service.UpdateWhiteList(id, request.Email)
|
||||
result, err := h.service.UpdateWhiteList(ctx, id, request.Email)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1911,8 +1981,9 @@ func (h *Handler) DeleteWhiteList(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Invalid id")
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
result, err := h.service.DeleteWhiteList(id)
|
||||
result, err := h.service.DeleteWhiteList(ctx, id)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1936,8 +2007,9 @@ func (h *Handler) BatchDeleteWhiteList(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Ids are required")
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
result, err := h.service.BatchDeleteWhiteList(request.Ids)
|
||||
result, err := h.service.BatchDeleteWhiteList(ctx, request.Ids)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
@@ -1994,8 +2066,9 @@ func (h *Handler) GetTokenUsersStats(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Invalid top")
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
stats, err := h.service.GetTokenUsersStats(fromDate, toDate, top)
|
||||
stats, err := h.service.GetTokenUsersStats(ctx, fromDate, toDate, top)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeDataError, err.Error())
|
||||
return
|
||||
@@ -2012,8 +2085,9 @@ func (h *Handler) GetTokenStatsSummary(c *gin.Context) {
|
||||
if len(toDate) == 10 {
|
||||
toDate += " 23:59:59"
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
stats, err := h.service.GetTokenStatsSummary(fromDate, toDate)
|
||||
stats, err := h.service.GetTokenStatsSummary(ctx, fromDate, toDate)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeDataError, err.Error())
|
||||
return
|
||||
|
||||
@@ -1038,7 +1038,7 @@ func (s *Service) ListServices(ctx context.Context) ([]ServiceStatus, error) {
|
||||
messageQueueStatus := messageQueueImpl.CheckStatus()
|
||||
results = append(results, newServiceStatus("message_queue", messageQueueImpl.Type(), messageQueueStatus, time.Now(), ""))
|
||||
|
||||
results = append(results, s.GetEEServicesStatus()...)
|
||||
results = append(results, s.GetEEServicesStatus(ctx)...)
|
||||
|
||||
serverList := GlobalServerStore.ListInfos()
|
||||
for _, serverStatus := range serverList {
|
||||
|
||||
@@ -34,7 +34,7 @@ func UpdateServer(serverName string, status *common.BaseMessage) (common.ErrorCo
|
||||
// Role management methods
|
||||
|
||||
// ListRoles list all roles
|
||||
func (s *Service) ListRoles() ([]map[string]interface{}, error) {
|
||||
func (s *Service) ListRoles(ctx context.Context) ([]map[string]interface{}, error) {
|
||||
result := []map[string]interface{}{
|
||||
{
|
||||
"command": "list_roles",
|
||||
@@ -46,7 +46,7 @@ func (s *Service) ListRoles() ([]map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// CreateRole create a new role
|
||||
func (s *Service) CreateRole(roleName, description string) (map[string]interface{}, error) {
|
||||
func (s *Service) CreateRole(ctx context.Context, roleName, description string) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "create_role",
|
||||
"role_name": roleName,
|
||||
@@ -58,7 +58,7 @@ func (s *Service) CreateRole(roleName, description string) (map[string]interface
|
||||
}
|
||||
|
||||
// ShowRole show role details
|
||||
func (s *Service) ShowRole(roleName string) (map[string]interface{}, error) {
|
||||
func (s *Service) ShowRole(ctx context.Context, roleName string) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "show_role",
|
||||
"role_name": roleName,
|
||||
@@ -70,7 +70,7 @@ func (s *Service) ShowRole(roleName string) (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// UpdateRole update role
|
||||
func (s *Service) UpdateRole(roleName, description string) (map[string]interface{}, error) {
|
||||
func (s *Service) UpdateRole(ctx context.Context, roleName, description string) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "update_role",
|
||||
"role_name": roleName,
|
||||
@@ -82,7 +82,7 @@ func (s *Service) UpdateRole(roleName, description string) (map[string]interface
|
||||
}
|
||||
|
||||
// DropRole drop role
|
||||
func (s *Service) DropRole(roleName string) (map[string]interface{}, error) {
|
||||
func (s *Service) DropRole(ctx context.Context, roleName string) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "drop_role",
|
||||
"role_name": roleName,
|
||||
@@ -93,7 +93,7 @@ func (s *Service) DropRole(roleName string) (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// ShowRolePermission get role permissions
|
||||
func (s *Service) ShowRolePermission(roleName string) (map[string]interface{}, error) {
|
||||
func (s *Service) ShowRolePermission(ctx context.Context, roleName string) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "show_role_permission",
|
||||
"role_name": roleName,
|
||||
@@ -104,7 +104,7 @@ func (s *Service) ShowRolePermission(roleName string) (map[string]interface{}, e
|
||||
}
|
||||
|
||||
// GrantRolePermission grant permission to role
|
||||
func (s *Service) GrantRolePermission(roleName string, actions []string, resource string) (map[string]interface{}, error) {
|
||||
func (s *Service) GrantRolePermission(ctx context.Context, roleName string, actions []string, resource string) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "grant_role_permission",
|
||||
"role_name": roleName,
|
||||
@@ -117,7 +117,7 @@ func (s *Service) GrantRolePermission(roleName string, actions []string, resourc
|
||||
}
|
||||
|
||||
// RevokeRolePermission revoke permission from role
|
||||
func (s *Service) RevokeRolePermission(roleName string, actions []string, resource string) (map[string]interface{}, error) {
|
||||
func (s *Service) RevokeRolePermission(ctx context.Context, roleName string, actions []string, resource string) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "revoke_role_permission",
|
||||
"role_name": roleName,
|
||||
@@ -130,7 +130,7 @@ func (s *Service) RevokeRolePermission(roleName string, actions []string, resour
|
||||
}
|
||||
|
||||
// ListResources list role resources
|
||||
func (s *Service) ListResources() (map[string]interface{}, error) {
|
||||
func (s *Service) ListResources(ctx context.Context) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "list_resources",
|
||||
"error": "'list resources for role' is not supported",
|
||||
@@ -140,7 +140,7 @@ func (s *Service) ListResources() (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// ListRolesWithPermission list roles with permission
|
||||
func (s *Service) ListRolesWithPermission() ([]map[string]interface{}, error) {
|
||||
func (s *Service) ListRolesWithPermission(ctx context.Context) ([]map[string]interface{}, error) {
|
||||
return []map[string]interface{}{
|
||||
{
|
||||
"command": "list_roles_with_permission",
|
||||
@@ -149,7 +149,7 @@ func (s *Service) ListRolesWithPermission() ([]map[string]interface{}, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) ShowRoleDefaultModels(roleName string) ([]map[string]interface{}, error) {
|
||||
func (s *Service) ShowRoleDefaultModels(ctx context.Context, roleName string) ([]map[string]interface{}, error) {
|
||||
return []map[string]interface{}{
|
||||
{
|
||||
"command": "show_role_default_models",
|
||||
@@ -160,7 +160,7 @@ func (s *Service) ShowRoleDefaultModels(roleName string) ([]map[string]interface
|
||||
}
|
||||
|
||||
// SetRoleDefaultModel set role default model
|
||||
func (s *Service) SetRoleDefaultModel(roleName, modelID, modelType string) (map[string]interface{}, error) {
|
||||
func (s *Service) SetRoleDefaultModel(ctx context.Context, roleName, modelID, modelType string) (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
"command": "set_role_default_model",
|
||||
"role_name": roleName,
|
||||
@@ -171,7 +171,7 @@ func (s *Service) SetRoleDefaultModel(roleName, modelID, modelType string) (map[
|
||||
}
|
||||
|
||||
// ResetRoleDefaultModel reset role default model
|
||||
func (s *Service) ResetRoleDefaultModel(roleName, modelType string) (map[string]interface{}, error) {
|
||||
func (s *Service) ResetRoleDefaultModel(ctx context.Context, roleName, modelType string) (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
"command": "reset_role_default_model",
|
||||
"role_name": roleName,
|
||||
@@ -181,7 +181,7 @@ func (s *Service) ResetRoleDefaultModel(roleName, modelType string) (map[string]
|
||||
}
|
||||
|
||||
// ListModelProviders list model providers
|
||||
func (s *Service) ListModelProviders() ([]map[string]interface{}, error) {
|
||||
func (s *Service) ListModelProviders(ctx context.Context) ([]map[string]interface{}, error) {
|
||||
return []map[string]interface{}{
|
||||
{
|
||||
"command": "list_model_providers",
|
||||
@@ -191,7 +191,7 @@ func (s *Service) ListModelProviders() ([]map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// AddModelProvider Add model provider
|
||||
func (s *Service) AddModelProvider(userID, providerName string) (map[string]interface{}, error) {
|
||||
func (s *Service) AddModelProvider(ctx context.Context, userID, providerName string) (map[string]interface{}, error) {
|
||||
|
||||
return map[string]interface{}{
|
||||
"command": "add_model_provider",
|
||||
@@ -202,7 +202,7 @@ func (s *Service) AddModelProvider(userID, providerName string) (map[string]inte
|
||||
}
|
||||
|
||||
// DeleteModelProviders delete model providers
|
||||
func (s *Service) DeleteModelProviders(userID string, providerNames []string) (map[string]interface{}, error) {
|
||||
func (s *Service) DeleteModelProviders(ctx context.Context, userID string, providerNames []string) (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
"command": "delete_model_providers",
|
||||
"user_id": userID,
|
||||
@@ -212,7 +212,7 @@ func (s *Service) DeleteModelProviders(userID string, providerNames []string) (m
|
||||
}
|
||||
|
||||
// ListModelInstances list model instances
|
||||
func (s *Service) ListModelInstances(userID, providerName string) ([]map[string]interface{}, error) {
|
||||
func (s *Service) ListModelInstances(ctx context.Context, userID, providerName string) ([]map[string]interface{}, error) {
|
||||
|
||||
return []map[string]interface{}{
|
||||
{
|
||||
@@ -225,7 +225,7 @@ func (s *Service) ListModelInstances(userID, providerName string) ([]map[string]
|
||||
}
|
||||
|
||||
// ShowProviderInstance show provider instance
|
||||
func (s *Service) ShowProviderInstance(userID, providerName, instanceName string) (map[string]interface{}, error) {
|
||||
func (s *Service) ShowProviderInstance(ctx context.Context, userID, providerName, instanceName string) (map[string]interface{}, error) {
|
||||
|
||||
return map[string]interface{}{
|
||||
"command": "show_provider_instance",
|
||||
@@ -237,7 +237,7 @@ func (s *Service) ShowProviderInstance(userID, providerName, instanceName string
|
||||
}
|
||||
|
||||
// ShowProviderInstanceBalance show provider instance balance
|
||||
func (s *Service) ShowProviderInstanceBalance(userID, providerName, instanceName string) (map[string]interface{}, error) {
|
||||
func (s *Service) ShowProviderInstanceBalance(ctx context.Context, userID, providerName, instanceName string) (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
"command": "show_provider_instance_balance",
|
||||
"user_id": userID,
|
||||
@@ -248,7 +248,7 @@ func (s *Service) ShowProviderInstanceBalance(userID, providerName, instanceName
|
||||
}
|
||||
|
||||
// CheckInstanceConnection check instance connection
|
||||
func (s *Service) CheckInstanceConnection(userID, providerName, instanceName string) (map[string]interface{}, error) {
|
||||
func (s *Service) CheckInstanceConnection(ctx context.Context, userID, providerName, instanceName string) (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
"command": "check_instance_connection",
|
||||
"user_id": userID,
|
||||
@@ -259,7 +259,7 @@ func (s *Service) CheckInstanceConnection(userID, providerName, instanceName str
|
||||
}
|
||||
|
||||
// CheckProviderConnection check provider connection
|
||||
func (s *Service) CheckProviderConnection(userID, providerName, region, apiKey, baseURL string) (map[string]interface{}, error) {
|
||||
func (s *Service) CheckProviderConnection(ctx context.Context, userID, providerName, region, apiKey, baseURL string) (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
"command": "check_provider_connection",
|
||||
"user_id": userID,
|
||||
@@ -271,7 +271,7 @@ func (s *Service) CheckProviderConnection(userID, providerName, region, apiKey,
|
||||
}
|
||||
|
||||
// AlterProviderInstance alter provider instance
|
||||
func (s *Service) AlterProviderInstance(userID, providerName, instanceName, newInstanceName, newAPIKey string) (map[string]interface{}, error) {
|
||||
func (s *Service) AlterProviderInstance(ctx context.Context, userID, providerName, instanceName, newInstanceName, newAPIKey string) (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
"command": "alter_provider_instance",
|
||||
"user_id": userID,
|
||||
@@ -284,7 +284,7 @@ func (s *Service) AlterProviderInstance(userID, providerName, instanceName, newI
|
||||
}
|
||||
|
||||
// AddModelInstance Add model instance
|
||||
func (s *Service) AddModelInstance(userID, providerName, instanceName string) (map[string]interface{}, error) {
|
||||
func (s *Service) AddModelInstance(ctx context.Context, userID, providerName, instanceName string) (map[string]interface{}, error) {
|
||||
|
||||
return map[string]interface{}{
|
||||
"command": "add_model_instance",
|
||||
@@ -296,7 +296,7 @@ func (s *Service) AddModelInstance(userID, providerName, instanceName string) (m
|
||||
}
|
||||
|
||||
// DeleteModelInstances delete model instances
|
||||
func (s *Service) DeleteModelInstances(userID, providerName string, instances []string) (map[string]interface{}, error) {
|
||||
func (s *Service) DeleteModelInstances(ctx context.Context, userID, providerName string, instances []string) (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
"command": "delete_model_instances",
|
||||
"user_id": userID,
|
||||
@@ -307,7 +307,7 @@ func (s *Service) DeleteModelInstances(userID, providerName string, instances []
|
||||
}
|
||||
|
||||
// ListInstanceModels list models for instance
|
||||
func (s *Service) ListInstanceModels(userID, providerName, instanceName string) ([]map[string]interface{}, error) {
|
||||
func (s *Service) ListInstanceModels(ctx context.Context, userID, providerName, instanceName string) ([]map[string]interface{}, error) {
|
||||
return []map[string]interface{}{
|
||||
{
|
||||
"command": "list_instance_models",
|
||||
@@ -319,7 +319,7 @@ func (s *Service) ListInstanceModels(userID, providerName, instanceName string)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) EnableOrDisableModel(userID, providerName, instanceName, modelName, modelID, status string) (map[string]interface{}, error) {
|
||||
func (s *Service) EnableOrDisableModel(ctx context.Context, userID, providerName, instanceName, modelName, modelID, status string) (map[string]interface{}, error) {
|
||||
|
||||
return map[string]interface{}{
|
||||
"command": "enable_or_disable_model",
|
||||
@@ -336,7 +336,7 @@ func (s *Service) EnableOrDisableModel(userID, providerName, instanceName, model
|
||||
// AddModel Add model
|
||||
|
||||
// AddModels Add models
|
||||
func (s *Service) AddModels(userID, providerName, instanceName string, modelNames []string) (map[string]interface{}, error) {
|
||||
func (s *Service) AddModels(ctx context.Context, userID, providerName, instanceName string, modelNames []string) (map[string]interface{}, error) {
|
||||
|
||||
return map[string]interface{}{
|
||||
"command": "add_model",
|
||||
@@ -349,7 +349,7 @@ func (s *Service) AddModels(userID, providerName, instanceName string, modelName
|
||||
}
|
||||
|
||||
// DeleteModels delete models
|
||||
func (s *Service) DeleteModels(userID, providerName, instanceName string, models []string) (map[string]interface{}, error) {
|
||||
func (s *Service) DeleteModels(ctx context.Context, userID, providerName, instanceName string, models []string) (map[string]interface{}, error) {
|
||||
return map[string]interface{}{
|
||||
"command": "delete_models",
|
||||
"user_id": userID,
|
||||
@@ -360,7 +360,7 @@ func (s *Service) DeleteModels(userID, providerName, instanceName string, models
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) GetSystemFingerprint() (map[string]interface{}, error) {
|
||||
func (s *Service) GetSystemFingerprint(ctx context.Context) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "get_system_fingerprint",
|
||||
"error": "'get system fingerprint' is not supported",
|
||||
@@ -369,11 +369,11 @@ func (s *Service) GetSystemFingerprint() (map[string]interface{}, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *Service) SetSystemLicense(license string) error {
|
||||
func (s *Service) SetSystemLicense(ctx context.Context, license string) error {
|
||||
return errors.New("'set system license' is not supported")
|
||||
}
|
||||
|
||||
func (s *Service) ShowSystemLicense(check bool) (map[string]interface{}, error) {
|
||||
func (s *Service) ShowSystemLicense(ctx context.Context, check bool) (map[string]interface{}, error) {
|
||||
var result map[string]interface{}
|
||||
if check {
|
||||
result = map[string]interface{}{
|
||||
@@ -391,7 +391,7 @@ func (s *Service) ShowSystemLicense(check bool) (map[string]interface{}, error)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *Service) UpdateSystemLicenseConfig(timeRecordSaveInterval, timeRecordTaskDuration int64) (map[string]interface{}, error) {
|
||||
func (s *Service) UpdateSystemLicenseConfig(ctx context.Context, timeRecordSaveInterval, timeRecordTaskDuration int64) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "update_system_license_config",
|
||||
"time_record_save_interval": timeRecordSaveInterval,
|
||||
@@ -402,11 +402,11 @@ func (s *Service) UpdateSystemLicenseConfig(timeRecordSaveInterval, timeRecordTa
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *Service) SetSoftFingerprint(softFingerprint string) error {
|
||||
func (s *Service) SetSoftFingerprint(ctx context.Context, softFingerprint string) error {
|
||||
return errors.New("set soft fingerprint is not supported")
|
||||
}
|
||||
|
||||
func (s *Service) GetSoftFingerprint() (map[string]interface{}, error) {
|
||||
func (s *Service) GetSoftFingerprint(ctx context.Context) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "show_soft_fingerprint",
|
||||
"error": "'show soft fingerprint' is not supported",
|
||||
@@ -415,12 +415,12 @@ func (s *Service) GetSoftFingerprint() (map[string]interface{}, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *Service) DeleteSoftFingerprint() error {
|
||||
func (s *Service) DeleteSoftFingerprint(ctx context.Context) error {
|
||||
return errors.New("delete soft fingerprint is not supported")
|
||||
}
|
||||
|
||||
// ShowUserActivity show user activity for enterprise edition
|
||||
func (s *Service) ShowUserActivity(email string, days int) (map[string]interface{}, error) {
|
||||
func (s *Service) ShowUserActivity(ctx context.Context, email string, days int) (map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -439,7 +439,7 @@ func (s *Service) ShowUserActivity(email string, days int) (map[string]interface
|
||||
}
|
||||
|
||||
// ShowUserDatasetSummary show user dataset summary for enterprise edition
|
||||
func (s *Service) ShowUserDatasetSummary(email, dataset string) (map[string]interface{}, error) {
|
||||
func (s *Service) ShowUserDatasetSummary(ctx context.Context, email, dataset string) (map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -476,7 +476,7 @@ func (s *Service) ShowUserSummary(ctx context.Context, email string) (map[string
|
||||
}
|
||||
|
||||
// ShowUserStorage show user storage for enterprise edition
|
||||
func (s *Service) ShowUserStorage(email string) (map[string]interface{}, error) {
|
||||
func (s *Service) ShowUserStorage(ctx context.Context, email string) (map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -512,7 +512,7 @@ func (s *Service) ShowUserQuota(ctx context.Context, email string) (map[string]i
|
||||
}
|
||||
|
||||
// ShowUserIndex show user index for enterprise edition
|
||||
func (s *Service) ShowUserIndex(email string) (map[string]interface{}, error) {
|
||||
func (s *Service) ShowUserIndex(ctx context.Context, email string) (map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -530,7 +530,7 @@ func (s *Service) ShowUserIndex(email string) (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// UpdateUserRole update user role
|
||||
func (s *Service) UpdateUserRole(email, roleName string) (map[string]interface{}, error) {
|
||||
func (s *Service) UpdateUserRole(ctx context.Context, email, roleName string) (map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -550,7 +550,7 @@ func (s *Service) UpdateUserRole(email, roleName string) (map[string]interface{}
|
||||
}
|
||||
|
||||
// ShowUserPermission show user permissions for enterprise edition
|
||||
func (s *Service) ShowUserPermission(email string) (map[string]interface{}, error) {
|
||||
func (s *Service) ShowUserPermission(ctx context.Context, email string) (map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -569,7 +569,7 @@ func (s *Service) ShowUserPermission(email string) (map[string]interface{}, erro
|
||||
}
|
||||
|
||||
// ListUserDatasets show user datasets for enterprise edition
|
||||
func (s *Service) ListUserDatasets(email string) ([]map[string]interface{}, error) {
|
||||
func (s *Service) ListUserDatasets(ctx context.Context, email string) ([]map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -590,7 +590,7 @@ func (s *Service) ListUserDatasets(email string) ([]map[string]interface{}, erro
|
||||
}
|
||||
|
||||
// ListUserAgents show user agents for enterprise edition
|
||||
func (s *Service) ListUserAgents(email string) ([]map[string]interface{}, error) {
|
||||
func (s *Service) ListUserAgents(ctx context.Context, email string) ([]map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -611,7 +611,7 @@ func (s *Service) ListUserAgents(email string) ([]map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// ListUserChats show user chats for enterprise edition
|
||||
func (s *Service) ListUserChats(email string) ([]map[string]interface{}, error) {
|
||||
func (s *Service) ListUserChats(ctx context.Context, email string) ([]map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -632,7 +632,7 @@ func (s *Service) ListUserChats(email string) ([]map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// ListUserSearches show user searches for enterprise edition
|
||||
func (s *Service) ListUserSearches(email string) ([]map[string]interface{}, error) {
|
||||
func (s *Service) ListUserSearches(ctx context.Context, email string) ([]map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -653,7 +653,7 @@ func (s *Service) ListUserSearches(email string) ([]map[string]interface{}, erro
|
||||
}
|
||||
|
||||
// ListUserModels show user models for enterprise edition
|
||||
func (s *Service) ListUserModels(email string) ([]map[string]interface{}, error) {
|
||||
func (s *Service) ListUserModels(ctx context.Context, email string) ([]map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -674,7 +674,7 @@ func (s *Service) ListUserModels(email string) ([]map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// ListUserFiles show user files for enterprise edition
|
||||
func (s *Service) ListUserFiles(email string) ([]map[string]interface{}, error) {
|
||||
func (s *Service) ListUserFiles(ctx context.Context, email string) ([]map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -695,7 +695,7 @@ func (s *Service) ListUserFiles(email string) ([]map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// ListUserProviders show user providers for enterprise edition
|
||||
func (s *Service) ListUserProviders(email string) ([]map[string]interface{}, error) {
|
||||
func (s *Service) ListUserProviders(ctx context.Context, email string) ([]map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -716,7 +716,7 @@ func (s *Service) ListUserProviders(email string) ([]map[string]interface{}, err
|
||||
}
|
||||
|
||||
// ListUserProviderInstances show user provider instances for enterprise edition
|
||||
func (s *Service) ListUserProviderInstances(email, providerName string) ([]map[string]interface{}, error) {
|
||||
func (s *Service) ListUserProviderInstances(ctx context.Context, email, providerName string) ([]map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -738,7 +738,7 @@ func (s *Service) ListUserProviderInstances(email, providerName string) ([]map[s
|
||||
}
|
||||
|
||||
// ListUserProviderInstanceModels show user provider instance models for enterprise edition
|
||||
func (s *Service) ListUserProviderInstanceModels(email, providerName, instanceName string) ([]map[string]interface{}, error) {
|
||||
func (s *Service) ListUserProviderInstanceModels(ctx context.Context, email, providerName, instanceName string) ([]map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -761,7 +761,7 @@ func (s *Service) ListUserProviderInstanceModels(email, providerName, instanceNa
|
||||
}
|
||||
|
||||
// ListUserDefaultModels show user default models for enterprise edition
|
||||
func (s *Service) ListUserDefaultModels(email string) ([]map[string]interface{}, error) {
|
||||
func (s *Service) ListUserDefaultModels(ctx context.Context, email string) ([]map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -782,7 +782,7 @@ func (s *Service) ListUserDefaultModels(email string) ([]map[string]interface{},
|
||||
}
|
||||
|
||||
// ShowUsersSummary show users summary for enterprise edition
|
||||
func (s *Service) ShowUsersSummary() (map[string]interface{}, error) {
|
||||
func (s *Service) ShowUsersSummary(ctx context.Context) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "show_users_summary",
|
||||
"error": "'show users summary' is not supported",
|
||||
@@ -792,7 +792,7 @@ func (s *Service) ShowUsersSummary() (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// ShowUsersActivity show users activity for enterprise edition
|
||||
func (s *Service) ShowUsersActivity(days, windows *int) (map[string]interface{}, error) {
|
||||
func (s *Service) ShowUsersActivity(ctx context.Context, days, windows *int) (map[string]interface{}, error) {
|
||||
daysInt := 0
|
||||
if days != nil {
|
||||
daysInt = *days
|
||||
@@ -835,7 +835,7 @@ func (s *Service) ListUsersEE(ctx context.Context, pageIndex, pageSize int, name
|
||||
}
|
||||
|
||||
// ListUsersReports list users reports for enterprise edition
|
||||
func (s *Service) ListUsersReports(pageIndex, pageSize int, status, plan *string, days *int) (map[string]interface{}, error) {
|
||||
func (s *Service) ListUsersReports(ctx context.Context, pageIndex, pageSize int, status, plan *string, days *int) (map[string]interface{}, error) {
|
||||
|
||||
statusStr := "all"
|
||||
if status != nil {
|
||||
@@ -864,7 +864,7 @@ func (s *Service) ListUsersReports(pageIndex, pageSize int, status, plan *string
|
||||
}
|
||||
|
||||
// ListUsersStorage list users storage for enterprise edition
|
||||
func (s *Service) ListUsersStorage(pageIndex, pageSize, top int) (map[string]interface{}, error) {
|
||||
func (s *Service) ListUsersStorage(ctx context.Context, pageIndex, pageSize, top int) (map[string]interface{}, error) {
|
||||
|
||||
result := map[string]interface{}{
|
||||
"page_index": pageIndex,
|
||||
@@ -878,7 +878,7 @@ func (s *Service) ListUsersStorage(pageIndex, pageSize, top int) (map[string]int
|
||||
}
|
||||
|
||||
// ListUsersDocuments list users documents for enterprise edition
|
||||
func (s *Service) ListUsersDocuments(pageIndex, pageSize, top int) (map[string]interface{}, error) {
|
||||
func (s *Service) ListUsersDocuments(ctx context.Context, pageIndex, pageSize, top int) (map[string]interface{}, error) {
|
||||
|
||||
result := map[string]interface{}{
|
||||
"page_index": pageIndex,
|
||||
@@ -892,7 +892,7 @@ func (s *Service) ListUsersDocuments(pageIndex, pageSize, top int) (map[string]i
|
||||
}
|
||||
|
||||
// ListUsersIndex list users index for enterprise edition
|
||||
func (s *Service) ListUsersIndex(pageIndex, pageSize, top int) (map[string]interface{}, error) {
|
||||
func (s *Service) ListUsersIndex(ctx context.Context, pageIndex, pageSize, top int) (map[string]interface{}, error) {
|
||||
|
||||
result := map[string]interface{}{
|
||||
"page_index": pageIndex,
|
||||
@@ -906,7 +906,7 @@ func (s *Service) ListUsersIndex(pageIndex, pageSize, top int) (map[string]inter
|
||||
}
|
||||
|
||||
// ListUsersQuota list users quota for enterprise edition
|
||||
func (s *Service) ListUsersQuota(pageIndex, pageSize, top int, quotaThreshold *int, plan *string, days *int) (map[string]interface{}, error) {
|
||||
func (s *Service) ListUsersQuota(ctx context.Context, pageIndex, pageSize, top int, quotaThreshold *int, plan *string, days *int) (map[string]interface{}, error) {
|
||||
|
||||
quotaThresholdInt := 0
|
||||
if quotaThreshold != nil {
|
||||
@@ -936,7 +936,7 @@ func (s *Service) ListUsersQuota(pageIndex, pageSize, top int, quotaThreshold *i
|
||||
}
|
||||
|
||||
// ShowUsersPlanSummary show users plan summary for enterprise edition
|
||||
func (s *Service) ShowUsersPlanSummary() (map[string]interface{}, error) {
|
||||
func (s *Service) ShowUsersPlanSummary(ctx context.Context) (map[string]interface{}, error) {
|
||||
|
||||
result := map[string]interface{}{
|
||||
"command": "show_users_plan_summary",
|
||||
@@ -947,7 +947,7 @@ func (s *Service) ShowUsersPlanSummary() (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// ShowUsersPlanQuota show users plan quota for enterprise edition
|
||||
func (s *Service) ShowUsersPlanQuota(quota int) (map[string]interface{}, error) {
|
||||
func (s *Service) ShowUsersPlanQuota(ctx context.Context, quota int) (map[string]interface{}, error) {
|
||||
|
||||
result := map[string]interface{}{
|
||||
"quota": quota,
|
||||
@@ -959,7 +959,7 @@ func (s *Service) ShowUsersPlanQuota(quota int) (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// ShowUsersQuotaSummary show users quota summary for enterprise edition
|
||||
func (s *Service) ShowUsersQuotaSummary() (map[string]interface{}, error) {
|
||||
func (s *Service) ShowUsersQuotaSummary(ctx context.Context) (map[string]interface{}, error) {
|
||||
|
||||
result := map[string]interface{}{
|
||||
"command": "show_users_quota_summary",
|
||||
@@ -970,7 +970,7 @@ func (s *Service) ShowUsersQuotaSummary() (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// ShowIngestionTasksSummary show ingestion tasks summary for enterprise edition
|
||||
func (s *Service) ShowIngestionTasksSummary() (map[string]interface{}, error) {
|
||||
func (s *Service) ShowIngestionTasksSummary(ctx context.Context) (map[string]interface{}, error) {
|
||||
|
||||
result := map[string]interface{}{
|
||||
"command": "show_ingestion_tasks_summary",
|
||||
@@ -981,7 +981,7 @@ func (s *Service) ShowIngestionTasksSummary() (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// ShowDataSummary show data summary for enterprise edition
|
||||
func (s *Service) ShowDataSummary() (map[string]interface{}, error) {
|
||||
func (s *Service) ShowDataSummary(ctx context.Context) (map[string]interface{}, error) {
|
||||
|
||||
result := map[string]interface{}{
|
||||
"command": "show_data_summary",
|
||||
@@ -992,7 +992,7 @@ func (s *Service) ShowDataSummary() (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// ShowDataOrphan show data orphan for enterprise edition
|
||||
func (s *Service) ShowDataOrphan() (map[string]interface{}, error) {
|
||||
func (s *Service) ShowDataOrphan(ctx context.Context) (map[string]interface{}, error) {
|
||||
|
||||
result := map[string]interface{}{
|
||||
"command": "show_data_orphan",
|
||||
@@ -1003,7 +1003,7 @@ func (s *Service) ShowDataOrphan() (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// ShowDataStorage show data storage for enterprise edition
|
||||
func (s *Service) ShowDataStorage() (map[string]interface{}, error) {
|
||||
func (s *Service) ShowDataStorage(ctx context.Context) (map[string]interface{}, error) {
|
||||
|
||||
result := map[string]interface{}{
|
||||
"command": "show_data_storage",
|
||||
@@ -1014,7 +1014,7 @@ func (s *Service) ShowDataStorage() (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// ShowDataIndex show data index for enterprise edition
|
||||
func (s *Service) ShowDataIndex() (map[string]interface{}, error) {
|
||||
func (s *Service) ShowDataIndex(ctx context.Context) (map[string]interface{}, error) {
|
||||
|
||||
result := map[string]interface{}{
|
||||
"command": "show_data_index",
|
||||
@@ -1025,7 +1025,7 @@ func (s *Service) ShowDataIndex() (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// PurgeOrphanData purge orphan data for enterprise edition
|
||||
func (s *Service) PurgeOrphanData(preview bool) (map[string]interface{}, error) {
|
||||
func (s *Service) PurgeOrphanData(ctx context.Context, preview bool) (map[string]interface{}, error) {
|
||||
|
||||
result := map[string]interface{}{
|
||||
"command": "purge_orphan_data",
|
||||
@@ -1037,7 +1037,7 @@ func (s *Service) PurgeOrphanData(preview bool) (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// PurgeUserData purge user data for enterprise edition
|
||||
func (s *Service) PurgeUserData(email string, preview bool) (map[string]interface{}, error) {
|
||||
func (s *Service) PurgeUserData(ctx context.Context, email string, preview bool) (map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
var user entity.User
|
||||
err := dao.DB.Where("email = ?", email).First(&user).Error
|
||||
@@ -1056,7 +1056,7 @@ func (s *Service) PurgeUserData(email string, preview bool) (map[string]interfac
|
||||
}
|
||||
|
||||
// PurgeUsersData purge users data for enterprise edition
|
||||
func (s *Service) PurgeUsersData(preview bool, days int, userPlan *string, userActivity *string) (map[string]interface{}, error) {
|
||||
func (s *Service) PurgeUsersData(ctx context.Context, preview bool, days int, userPlan *string, userActivity *string) (map[string]interface{}, error) {
|
||||
|
||||
plan := "all"
|
||||
activity := "all"
|
||||
@@ -1157,7 +1157,7 @@ func (s *Service) ListIngestionTasksByCondition(ctx context.Context, email, stat
|
||||
return []map[string]interface{}{element}, nil
|
||||
}
|
||||
|
||||
func (s *Service) StopIngestionTasksByCondition(tasks []string, email, status *string) ([]map[string]interface{}, error) {
|
||||
func (s *Service) StopIngestionTasksByCondition(ctx context.Context, tasks []string, email, status *string) ([]map[string]interface{}, error) {
|
||||
|
||||
if email == nil && status == nil {
|
||||
return nil, fmt.Errorf("email or status are required")
|
||||
@@ -1179,7 +1179,7 @@ func (s *Service) StopIngestionTasksByCondition(tasks []string, email, status *s
|
||||
return []map[string]interface{}{element}, nil
|
||||
}
|
||||
|
||||
func (s *Service) RemoveIngestionTasksByCondition(tasks []string, email, status *string) ([]map[string]interface{}, error) {
|
||||
func (s *Service) RemoveIngestionTasksByCondition(ctx context.Context, tasks []string, email, status *string) ([]map[string]interface{}, error) {
|
||||
|
||||
if email == nil && status == nil {
|
||||
return nil, fmt.Errorf("email or status are required")
|
||||
@@ -1206,7 +1206,7 @@ func CheckLicense() (common.ErrorCode, string) {
|
||||
}
|
||||
|
||||
// DownloadSensitiveWords download sensitive words
|
||||
func (s *Service) DownloadSensitiveWords() ([]map[string]interface{}, error) {
|
||||
func (s *Service) DownloadSensitiveWords(ctx context.Context) ([]map[string]interface{}, error) {
|
||||
result := []map[string]interface{}{
|
||||
{
|
||||
"command": "download_sensitive_words",
|
||||
@@ -1217,7 +1217,7 @@ func (s *Service) DownloadSensitiveWords() ([]map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// UploadSensitiveWords upload sensitive words
|
||||
func (s *Service) UploadSensitiveWords(file *multipart.FileHeader) ([]map[string]interface{}, error) {
|
||||
func (s *Service) UploadSensitiveWords(ctx context.Context, file *multipart.FileHeader) ([]map[string]interface{}, error) {
|
||||
result := []map[string]interface{}{
|
||||
{
|
||||
"command": "upload_sensitive_words",
|
||||
@@ -1229,7 +1229,7 @@ func (s *Service) UploadSensitiveWords(file *multipart.FileHeader) ([]map[string
|
||||
}
|
||||
|
||||
// BindVerificationEmail bind verification email
|
||||
func (s *Service) BindVerificationEmail(email, host string, port int, username, password string, useTLS, useSSL bool) (map[string]interface{}, error) {
|
||||
func (s *Service) BindVerificationEmail(ctx context.Context, email, host string, port int, username, password string, useTLS, useSSL bool) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "bind_verification_email",
|
||||
"email": email,
|
||||
@@ -1245,7 +1245,7 @@ func (s *Service) BindVerificationEmail(email, host string, port int, username,
|
||||
}
|
||||
|
||||
// ShowVerificationEmail show verification email
|
||||
func (s *Service) ShowVerificationEmail() (map[string]interface{}, error) {
|
||||
func (s *Service) ShowVerificationEmail(ctx context.Context) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "show_verification_email",
|
||||
"error": "'Show verification email' is not supported",
|
||||
@@ -1254,7 +1254,7 @@ func (s *Service) ShowVerificationEmail() (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// ShowWhiteList show white list
|
||||
func (s *Service) ShowWhiteList() ([]map[string]interface{}, error) {
|
||||
func (s *Service) ShowWhiteList(ctx context.Context) ([]map[string]interface{}, error) {
|
||||
result := []map[string]interface{}{
|
||||
{
|
||||
"command": "show_white_list",
|
||||
@@ -1265,7 +1265,7 @@ func (s *Service) ShowWhiteList() ([]map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// AddWhiteList add white list
|
||||
func (s *Service) AddWhiteList(email string) (map[string]interface{}, error) {
|
||||
func (s *Service) AddWhiteList(ctx context.Context, email string) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "add_white_list",
|
||||
"email": email,
|
||||
@@ -1275,7 +1275,7 @@ func (s *Service) AddWhiteList(email string) (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// BatchAddWhiteList batch add white list
|
||||
func (s *Service) BatchAddWhiteList(file *multipart.FileHeader) (map[string]interface{}, error) {
|
||||
func (s *Service) BatchAddWhiteList(ctx context.Context, file *multipart.FileHeader) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "batch_add_white_list",
|
||||
"filename": file.Filename,
|
||||
@@ -1285,7 +1285,7 @@ func (s *Service) BatchAddWhiteList(file *multipart.FileHeader) (map[string]inte
|
||||
}
|
||||
|
||||
// UpdateWhiteList update white list
|
||||
func (s *Service) UpdateWhiteList(id, email string) (map[string]interface{}, error) {
|
||||
func (s *Service) UpdateWhiteList(ctx context.Context, id, email string) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "update_white_list",
|
||||
"id": id,
|
||||
@@ -1296,7 +1296,7 @@ func (s *Service) UpdateWhiteList(id, email string) (map[string]interface{}, err
|
||||
}
|
||||
|
||||
// DeleteWhiteList delete white list
|
||||
func (s *Service) DeleteWhiteList(id int) (map[string]interface{}, error) {
|
||||
func (s *Service) DeleteWhiteList(ctx context.Context, id int) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "delete_white_list",
|
||||
"id": id,
|
||||
@@ -1306,7 +1306,7 @@ func (s *Service) DeleteWhiteList(id int) (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// BatchDeleteWhiteList batch delete white list
|
||||
func (s *Service) BatchDeleteWhiteList(ids []int) (map[string]interface{}, error) {
|
||||
func (s *Service) BatchDeleteWhiteList(ctx context.Context, ids []int) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "batch_delete_white_list",
|
||||
"ids": ids,
|
||||
@@ -1331,7 +1331,7 @@ func (s *Service) GetTokenStats(ctx context.Context, userName, fromDate, toDate,
|
||||
}
|
||||
|
||||
// GetTokenUsersStats returns API token statistics for all users.
|
||||
func (s *Service) GetTokenUsersStats(fromDate, toDate string, top int) ([]map[string]interface{}, error) {
|
||||
func (s *Service) GetTokenUsersStats(ctx context.Context, fromDate, toDate string, top int) ([]map[string]interface{}, error) {
|
||||
result := []map[string]interface{}{
|
||||
{
|
||||
"command": "get_token_users_stats",
|
||||
@@ -1345,7 +1345,7 @@ func (s *Service) GetTokenUsersStats(fromDate, toDate string, top int) ([]map[st
|
||||
}
|
||||
|
||||
// GetTokenStatsSummary returns API token statistics summary for all users.
|
||||
func (s *Service) GetTokenStatsSummary(fromDate, toDate string) (map[string]interface{}, error) {
|
||||
func (s *Service) GetTokenStatsSummary(ctx context.Context, fromDate, toDate string) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "get_token_stats_summary",
|
||||
"from_date": fromDate,
|
||||
@@ -1369,6 +1369,6 @@ func (s *Service) ListLogs(ctx context.Context, userName string, days int) ([]ma
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *Service) GetEEServicesStatus() []ServiceStatus {
|
||||
func (s *Service) GetEEServicesStatus(ctx context.Context) []ServiceStatus {
|
||||
return []ServiceStatus{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user