feat: Support multiple vector database selection, add InMemory and Qdrant adapters, introduce admin dashboard

This commit is contained in:
shiyu
2025-05-31 21:00:48 +08:00
parent b2bacc54a9
commit 44d2616fd4
51 changed files with 5498 additions and 1214 deletions

View File

@@ -72,6 +72,12 @@ public class DatabaseInitializer(
await EnsureConfigExistsAsync(key, value);
}
// 确保向量数据库配置存在
if (!await configService.ExistsAsync("VectorDb:Type"))
{
await configService.SetConfigAsync("VectorDb:Type", "InMemory", "向量数据库类型");
}
// 初始化管理员角色和用户
await InitializeAdminRoleAndUserAsync();
@@ -128,6 +134,22 @@ public class DatabaseInitializer(
await context.SaveChangesAsync();
}
// 检查并创建用户角色
var userRole = await context.Roles.FirstOrDefaultAsync(r => r.Name == "User");
if (userRole == null)
{
logger.LogInformation("创建用户角色");
userRole = new Role
{
Name = "User",
Description = "普通用户角色",
CreatedAt = DateTime.UtcNow,
UpdatedAt = DateTime.UtcNow
};
await context.Roles.AddAsync(userRole);
await context.SaveChangesAsync();
}
logger.LogInformation("请注意,第一个注册的用户将自动成为管理员");
}
}