Commit 6288f46b authored by youxiaoji's avatar youxiaoji

* [数据库更新为MYSQL]

* [修改数据化SQL]
+ [增加oauth2.0供应商信息初始化数据]
parent 19aa1f99
......@@ -84,7 +84,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.3.0</version>
</dependency>
<!-- Spring AI Core -->
<dependency>
<groupId>org.springframework.ai</groupId>
......
......@@ -4,10 +4,10 @@ spring:
# 数据源配置
datasource:
url: jdbc:h2:mem:hiagent;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
driver-class-name: org.h2.Driver
username: sa
password:
url: jdbc:mysql://192.168.219.129:3306/hiagent?useUnicode=true&characterEncoding=utf-8&useSSL=false
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: 123456Aa?
hikari:
maximum-pool-size: 10
minimum-idle: 2
......
-- 插入默认数据
-- 插入默认用户数据
MERGE INTO sys_user (id, username, password, email, nickname, status, role) VALUES
('user-001', 'admin', '$2a$10$N.zmdr9k7uOCQb0bta/OauRxaOKSr.QhqyD2R5FKvMQjmHoLkm5Sy', 'admin@hiagent.com', 'Admin', 'active', 'admin');
# INSERT INTO sys_user (id, username, password, email, nickname, status, role) VALUES
# ('user-001', 'admin', '$2a$10$N.zmdr9k7uOCQb0bta/OauRxaOKSr.QhqyD2R5FKvMQjmHoLkm5Sy', 'admin@hiagent.com', 'Admin', 'active', 'admin');
#
# -- 插入默认LLM配置数据
# INSERT INTO llm_config (id, name, description, provider, model_name, api_key, base_url, temperature, max_tokens, top_p, enabled, owner) VALUES
# ('deepseek-default', 'deepseek-default', 'DeepSeek默认配置', 'deepseek', 'deepseek-chat', '', 'https://api.deepseek.com', 0.7, 4096, 0.9, true, 'user-001'),
# ('openai-default', 'openai-default', 'OpenAI默认配置', 'openai', 'gpt-3.5-turbo', '', 'https://api.openai.com/v1', 0.7, 4096, 0.9, false, 'user-001'),
# ('ollama-default', 'ollama-default', 'Ollama默认配置', 'ollama', 'llama2', '', 'http://localhost:11434', 0.7, 4096, 0.9, true, 'user-001'),
# ('hisense-default', 'hisense-default', 'Hisense默认配置', 'hisense', 'gpt-4-1', '', 'http://openai-proxy-v2-jt-higpt.cloudprd.hisense.com', 0.7, 4096, 0.9, true, 'user-001');
#
# -- 插入默认Agent数据
# INSERT INTO agent (id, name, description, status, default_model, owner, system_prompt, enable_re_act, history_length, enable_rag, rag_collection_id, rag_top_k, rag_score_threshold, tools) VALUES
# ('agent-1', '客服助手', '处理客户咨询的AI助手', 'active', 'deepseek-default', 'user-001', '你是一个专业的客服助手,请用友好和专业的态度回答客户的问题。', 1, 15, 1, 'customer-service-kb', 5, 0.8, '["search", "orderQuery", "refundProcessing"]'),
# ('agent-2', '技术支持', '提供技术支持服务的AI助手', 'active', 'openai-default', 'user-001', '你是一个技术专家,请帮助用户解决技术问题。', 1, 15, 1, 'technical-support-kb', 5, 0.8, '["search", "calculator", "technicalDocumentationRetrieval", "technicalCodeExplanation"]'),
# ('agent-3', '数据分析员', '专业的数据分析AI助手', 'active', 'deepseek-default', 'user-001', '你是一个数据分析专家,擅长处理和分析各种数据。', 0, 15, 1, 'data-analysis-kb', 5, 0.8, '["calculator", "chartGeneration", "statisticalCalculation"]'),
# ('agent-4', '内容创作助手', '帮助撰写各类文案的AI助手', 'active', 'hisense-default', 'user-001', '你是一个创意写作专家,能够帮助用户创作各种类型的文案。', 0, 15, 1, 'content-creation-kb', 5, 0.8, '["search", "writingStyleReference", "documentTemplate"]'),
# ('agent-5', '学习导师', '个性化学习指导AI助手', 'active', 'hisense-default', 'user-001', '你是一个教育专家,能够根据用户需求提供个性化的学习建议。', 1, 15, 1, 'learning-mentor-kb', 5, 0.8, '["search", "studyPlanGeneration", "courseMaterialRetrieval"]');
-- 插入默认LLM配置数据
MERGE INTO llm_config (id, name, description, provider, model_name, api_key, base_url, temperature, max_tokens, top_p, enabled, owner) VALUES
('deepseek-default', 'deepseek-default', 'DeepSeek默认配置', 'deepseek', 'deepseek-chat', '', 'https://api.deepseek.com', 0.7, 4096, 0.9, true, 'user-001'),
('openai-default', 'openai-default', 'OpenAI默认配置', 'openai', 'gpt-3.5-turbo', '', 'https://api.openai.com/v1', 0.7, 4096, 0.9, false, 'user-001'),
('ollama-default', 'ollama-default', 'Ollama默认配置', 'ollama', 'llama2', '', 'http://localhost:11434', 0.7, 4096, 0.9, true, 'user-001'),
('hisense-default', 'hisense-default', 'Hisense默认配置', 'hisense', 'gpt-4-1', '', 'http://openai-proxy-v2-jt-higpt.cloudprd.hisense.com', 0.7, 4096, 0.9, true, 'user-001');
-- 插入默认Agent数据
MERGE INTO agent (id, name, description, status, default_model, owner, system_prompt, enable_re_act, history_length, enable_rag, rag_collection_id, rag_top_k, rag_score_threshold, tools) VALUES
('agent-1', '客服助手', '处理客户咨询的AI助手', 'active', 'deepseek-default', 'user-001', '你是一个专业的客服助手,请用友好和专业的态度回答客户的问题。', 1, 15, 1, 'customer-service-kb', 5, 0.8, '["search", "orderQuery", "refundProcessing"]'),
('agent-2', '技术支持', '提供技术支持服务的AI助手', 'active', 'openai-default', 'user-001', '你是一个技术专家,请帮助用户解决技术问题。', 1, 15, 1, 'technical-support-kb', 5, 0.8, '["search", "calculator", "technicalDocumentationRetrieval", "technicalCodeExplanation"]'),
('agent-3', '数据分析员', '专业的数据分析AI助手', 'active', 'deepseek-default', 'user-001', '你是一个数据分析专家,擅长处理和分析各种数据。', 0, 15, 1, 'data-analysis-kb', 5, 0.8, '["calculator", "chartGeneration", "statisticalCalculation"]'),
('agent-4', '内容创作助手', '帮助撰写各类文案的AI助手', 'active', 'hisense-default', 'user-001', '你是一个创意写作专家,能够帮助用户创作各种类型的文案。', 0, 15, 1, 'content-creation-kb', 5, 0.8, '["search", "writingStyleReference", "documentTemplate"]'),
('agent-5', '学习导师', '个性化学习指导AI助手', 'active', 'hisense-default', 'user-001', '你是一个教育专家,能够根据用户需求提供个性化的学习建议。', 1, 15, 1, 'learning-mentor-kb', 5, 0.8, '["search", "studyPlanGeneration", "courseMaterialRetrieval"]');
-- 插入默认工具数据
MERGE INTO tool (id, name, display_name, description, category, status, timeout, http_method) VALUES
('tool-1', 'search', '搜索工具', '进行网络搜索查询', 'API', 'active', 30000, 'GET'),
('tool-2', 'calculator', '计算器', '进行数学计算', 'FUNCTION', 'active', 5000, 'POST'),
('tool-3', 'weather', '天气查询', '查询天气信息', 'API', 'active', 10000, 'GET'),
('tool-4', 'get_current_time', '获取当前时间', '获取当前系统时间', 'FUNCTION', 'active', 1000, 'GET'),
('tool-5', 'technicalDocumentationRetrieval', '技术文档检索', '检索和查询技术文档内容', 'FUNCTION', 'active', 10000, 'GET'),
('tool-6', 'technicalCodeExplanation', '技术代码解释', '分析和解释技术代码的功能和实现逻辑', 'FUNCTION', 'active', 10000, 'GET'),
('tool-7', 'chartGeneration', '图表生成', '根据数据生成各种类型的图表', 'FUNCTION', 'active', 10000, 'GET'),
('tool-8', 'statisticalCalculation', '统计计算', '执行各种统计分析计算', 'FUNCTION', 'active', 10000, 'GET'),
('tool-9', 'writingStyleReference', '创作风格参考', '提供各种写作风格的参考和指导', 'FUNCTION', 'active', 10000, 'GET'),
('tool-10', 'documentTemplate', '文档模板', '提供各种类型的文档模板', 'FUNCTION', 'active', 10000, 'GET'),
('tool-11', 'studyPlanGeneration', '学习计划制定', '根据学习目标和时间安排制定个性化的学习计划', 'FUNCTION', 'active', 10000, 'GET'),
('tool-12', 'courseMaterialRetrieval', '课程资料检索', '检索和查询相关课程资料', 'FUNCTION', 'active', 10000, 'GET');
\ No newline at end of file
# -- 插入默认工具数据
# INSERT INTO tool (id, name, display_name, description, category, status, timeout, http_method) VALUES
# ('tool-1', 'search', '搜索工具', '进行网络搜索查询', 'API', 'active', 30000, 'GET'),
# ('tool-2', 'calculator', '计算器', '进行数学计算', 'FUNCTION', 'active', 5000, 'POST'),
# ('tool-3', 'weather', '天气查询', '查询天气信息', 'API', 'active', 10000, 'GET'),
# ('tool-4', 'get_current_time', '获取当前时间', '获取当前系统时间', 'FUNCTION', 'active', 1000, 'GET'),
# ('tool-5', 'technicalDocumentationRetrieval', '技术文档检索', '检索和查询技术文档内容', 'FUNCTION', 'active', 10000, 'GET'),
# ('tool-6', 'technicalCodeExplanation', '技术代码解释', '分析和解释技术代码的功能和实现逻辑', 'FUNCTION', 'active', 10000, 'GET'),
# ('tool-7', 'chartGeneration', '图表生成', '根据数据生成各种类型的图表', 'FUNCTION', 'active', 10000, 'GET'),
# ('tool-8', 'statisticalCalculation', '统计计算', '执行各种统计分析计算', 'FUNCTION', 'active', 10000, 'GET'),
# ('tool-9', 'writingStyleReference', '创作风格参考', '提供各种写作风格的参考和指导', 'FUNCTION', 'active', 10000, 'GET'),
# ('tool-10', 'documentTemplate', '文档模板', '提供各种类型的文档模板', 'FUNCTION', 'active', 10000, 'GET'),
# ('tool-11', 'studyPlanGeneration', '学习计划制定', '根据学习目标和时间安排制定个性化的学习计划', 'FUNCTION', 'active', 10000, 'GET'),
# ('tool-12', 'courseMaterialRetrieval', '课程资料检索', '检索和查询相关课程资料', 'FUNCTION', 'active', 10000, 'GET');
#
# -- 插入oauth2.0 服务商信息
# INSERT INTO oauth2_provider
# (id, provider_name, display_name, description, auth_type, authorize_url, token_url, userinfo_url, client_id, client_secret, redirect_uri, `scope`, enabled, config_json, created_at, updated_at, created_by, updated_by, deleted, remark)
# VALUES('hiagent', 'sso', 'sso', 'sso-provider', 'authorization_code', 'https://sso.hisense.com/esc-sso/oauth2.0/authorize', 'https://sso.hisense.com/esc-sso/oauth2.0/accessToken', 'https://sso.hisense.com/esc-sso/oauth2.0/profile', '', '', '', 'user', 1, '{}', '2025-12-17 17:26:57', '2025-12-17 17:27:48', '', '', 0, '');
......@@ -19,7 +19,7 @@ CREATE TABLE IF NOT EXISTS sys_user (
remark text,
PRIMARY KEY (id)
);
CREATE INDEX IF NOT EXISTS idx_username ON sys_user (username);
-- -- CREATE INDEX idx_username ON sys_user (username);
-- OAuth2 提供者配置表
CREATE TABLE IF NOT EXISTS oauth2_provider (
......@@ -46,8 +46,8 @@ CREATE TABLE IF NOT EXISTS oauth2_provider (
PRIMARY KEY (id),
UNIQUE (provider_name)
);
CREATE INDEX IF NOT EXISTS idx_oauth2_enabled ON oauth2_provider (enabled);
CREATE INDEX IF NOT EXISTS idx_oauth2_auth_type ON oauth2_provider (auth_type);
-- CREATE INDEX idx_oauth2_enabled ON oauth2_provider (enabled);
-- CREATE INDEX idx_oauth2_auth_type ON oauth2_provider (auth_type);
-- OAuth2 账户关联表
CREATE TABLE IF NOT EXISTS oauth2_account (
......@@ -72,9 +72,9 @@ CREATE TABLE IF NOT EXISTS oauth2_account (
UNIQUE (user_id, provider_name),
FOREIGN KEY (user_id) REFERENCES sys_user(id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS idx_oauth2_user_id ON oauth2_account (user_id);
CREATE INDEX IF NOT EXISTS idx_oauth2_provider_name ON oauth2_account (provider_name);
CREATE INDEX IF NOT EXISTS idx_oauth2_remote_user_id ON oauth2_account (remote_user_id);
-- CREATE INDEX idx_oauth2_user_id ON oauth2_account (user_id);
-- CREATE INDEX idx_oauth2_provider_name ON oauth2_account (provider_name);
-- CREATE INDEX idx_oauth2_remote_user_id ON oauth2_account (remote_user_id);
-- 登录模式配置表
CREATE TABLE IF NOT EXISTS login_mode_config (
......@@ -94,7 +94,7 @@ CREATE TABLE IF NOT EXISTS login_mode_config (
PRIMARY KEY (id),
UNIQUE (mode_name)
);
CREATE INDEX IF NOT EXISTS idx_login_mode_enabled ON login_mode_config (enabled);
-- CREATE INDEX idx_login_mode_enabled ON login_mode_config (enabled);
-- LLM配置表
CREATE TABLE IF NOT EXISTS llm_config (
......@@ -118,9 +118,9 @@ CREATE TABLE IF NOT EXISTS llm_config (
remark text,
PRIMARY KEY (id)
);
CREATE INDEX IF NOT EXISTS idx_enabled ON llm_config (enabled);
CREATE INDEX IF NOT EXISTS idx_provider ON llm_config (provider);
CREATE INDEX IF NOT EXISTS idx_name ON llm_config (name);
-- CREATE INDEX idx_enabled ON llm_config (enabled);
-- CREATE INDEX idx_provider ON llm_config (provider);
-- CREATE INDEX idx_name ON llm_config (name);
-- Agent表
CREATE TABLE IF NOT EXISTS agent (
......@@ -156,9 +156,9 @@ CREATE TABLE IF NOT EXISTS agent (
PRIMARY KEY (id),
FOREIGN KEY (default_model) REFERENCES llm_config(name)
);
CREATE INDEX IF NOT EXISTS idx_owner ON agent (owner);
CREATE INDEX IF NOT EXISTS idx_status ON agent (status);
CREATE INDEX IF NOT EXISTS idx_created_at ON agent (created_at);
-- CREATE INDEX idx_owner ON agent (owner);
-- CREATE INDEX idx_status ON agent (status);
-- CREATE INDEX idx_created_at ON agent (created_at);
-- 文档表
CREATE TABLE IF NOT EXISTS document (
......@@ -204,8 +204,8 @@ CREATE TABLE IF NOT EXISTS document_chunk (
remark text,
PRIMARY KEY (id)
);
CREATE INDEX IF NOT EXISTS idx_document_id ON document_chunk (document_id);
CREATE INDEX IF NOT EXISTS idx_vector_id ON document_chunk (vector_id);
-- CREATE INDEX idx_document_id ON document_chunk (document_id);
-- CREATE INDEX idx_vector_id ON document_chunk (vector_id);
-- Agent对话表
CREATE TABLE IF NOT EXISTS agent_dialogue (
......@@ -229,10 +229,10 @@ CREATE TABLE IF NOT EXISTS agent_dialogue (
remark text,
PRIMARY KEY (id)
);
CREATE INDEX IF NOT EXISTS idx_agent_id ON agent_dialogue (agent_id);
CREATE INDEX IF NOT EXISTS idx_user_id ON agent_dialogue (user_id);
CREATE INDEX IF NOT EXISTS idx_context_id ON agent_dialogue (context_id);
CREATE INDEX IF NOT EXISTS idx_created_at ON agent_dialogue (created_at);
-- CREATE INDEX idx_agent_id ON agent_dialogue (agent_id);
-- CREATE INDEX idx_user_id ON agent_dialogue (user_id);
-- CREATE INDEX idx_context_id ON agent_dialogue (context_id);
-- CREATE INDEX idx_created_at ON agent_dialogue (created_at);
-- 系统日志表
CREATE TABLE IF NOT EXISTS sys_log (
......@@ -256,11 +256,11 @@ CREATE TABLE IF NOT EXISTS sys_log (
remark text,
PRIMARY KEY (id)
);
CREATE INDEX IF NOT EXISTS idx_user_id ON sys_log (user_id);
CREATE INDEX IF NOT EXISTS idx_created_at ON sys_log (created_at);
CREATE INDEX IF NOT EXISTS idx_operation_type ON sys_log (operation_type);
CREATE INDEX IF NOT EXISTS idx_resource_type ON sys_log (resource_type);
CREATE INDEX IF NOT EXISTS idx_success ON sys_log (success);
-- CREATE INDEX idx_user_id ON sys_log (user_id);
-- CREATE INDEX idx_created_at ON sys_log (created_at);
-- CREATE INDEX idx_operation_type ON sys_log (operation_type);
-- CREATE INDEX idx_resource_type ON sys_log (resource_type);
-- CREATE INDEX idx_success ON sys_log (success);
-- 工具表
CREATE TABLE IF NOT EXISTS tool (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment