You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
314 lines
9.9 KiB
314 lines
9.9 KiB
import 'dart:async';
|
|
import 'package:get_storage/get_storage.dart';
|
|
import 'package:path/path.dart';
|
|
import 'package:sqflite/sqflite.dart';
|
|
|
|
class DatabaseHelper {
|
|
static final DatabaseHelper _instance = DatabaseHelper._internal();
|
|
factory DatabaseHelper() => _instance;
|
|
static Database? _database;
|
|
static String _userId = '';
|
|
|
|
DatabaseHelper._internal();
|
|
|
|
Future<Database> get database async {
|
|
if (_database != null) return _database!;
|
|
_database = await _initDatabase();
|
|
return _database!;
|
|
}
|
|
|
|
Future<Database> _initDatabase() async {
|
|
final GetStorage storage = GetStorage();
|
|
Map? userInfo = storage.read("user_info");
|
|
if (userInfo != null) {
|
|
_userId = userInfo['user']['uid'];
|
|
}
|
|
String path = join(
|
|
await getDatabasesPath(),
|
|
_userId.isNotEmpty ? '${_userId}database.db' : 'database.db',
|
|
);
|
|
return await openDatabase(path, version: 1, onCreate: _createDB);
|
|
}
|
|
|
|
Future<void> _createDB(Database db, int version) async {
|
|
final batch = db.batch();
|
|
// 用户信息
|
|
batch.execute('''
|
|
CREATE TABLE IF NOT EXISTS user (
|
|
id TEXT PRIMARY KEY,
|
|
synctime INTEGER
|
|
)
|
|
''');
|
|
// 操作记录
|
|
batch.execute('''
|
|
CREATE TABLE IF NOT EXISTS operationrecord (
|
|
id INTEGER PRIMARY KEY,
|
|
method TEXT,
|
|
data TEXT
|
|
)
|
|
''');
|
|
// 商务会议助手列表
|
|
batch.execute('''
|
|
CREATE TABLE IF NOT EXISTS meeting (
|
|
id INTEGER PRIMARY KEY,
|
|
title TEXT,
|
|
type TEXT,
|
|
seconds INTEGER,
|
|
filepath TEXT,
|
|
audiourl TEXT,
|
|
tasktype INTEGER,
|
|
creationtime INTEGER
|
|
)
|
|
''');
|
|
// 商务会议助手详情内容
|
|
batch.execute('''
|
|
CREATE TABLE IF NOT EXISTS meetingdetails (
|
|
id INTEGER PRIMARY KEY,
|
|
meetingid INTEGER,
|
|
address TEXT,
|
|
personnel TEXT,
|
|
taskid TEXT,
|
|
tasktype INTEGER,
|
|
overview TEXT,
|
|
summary TEXT,
|
|
mindmap TEXT
|
|
)
|
|
''');
|
|
// 商务会议助手转写内容
|
|
batch.execute('''
|
|
CREATE TABLE IF NOT EXISTS meetingspeaker (
|
|
id INTEGER PRIMARY KEY,
|
|
meetingid INTEGER,
|
|
content TEXT,
|
|
starttime INTEGER,
|
|
endtime INTEGER,
|
|
speaker TEXT
|
|
)
|
|
''');
|
|
// 商务会议助手模版分类
|
|
batch.execute('''
|
|
CREATE TABLE IF NOT EXISTS meetingcategorytemplate (
|
|
id INTEGER PRIMARY KEY,
|
|
name TEXT
|
|
)
|
|
''');
|
|
// 商务会议助手模版
|
|
batch.execute('''
|
|
CREATE TABLE IF NOT EXISTS meetingtemplate (
|
|
id INTEGER PRIMARY KEY,
|
|
categoryid INTEGER,
|
|
name TEXT,
|
|
icon TEXT,
|
|
tag TEXT,
|
|
desc TEXT,
|
|
prompt TEXT
|
|
)
|
|
''');
|
|
batch.insert('user', {
|
|
'id': _userId,
|
|
'synctime': 0,
|
|
});
|
|
// 商务会议助手插入默认模版
|
|
batch.insert('meetingcategorytemplate', {
|
|
'id': 1,
|
|
'name': '通用',
|
|
});
|
|
batch.insert('meetingcategorytemplate', {
|
|
'id': 2,
|
|
'name': '会议',
|
|
});
|
|
batch.insert('meetingcategorytemplate', {
|
|
'id': 3,
|
|
'name': '演讲',
|
|
});
|
|
batch.insert('meetingcategorytemplate', {
|
|
'id': 4,
|
|
'name': '自定义',
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 1,
|
|
'name': '会议纪要',
|
|
'icon': 'auto_stories',
|
|
'tag': '主题, 代办事项',
|
|
'desc': '旨在概述和回顾项目内容,重点捕捉所提话题的精髓和关键点',
|
|
'prompt': '提示词',
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 1,
|
|
'name': 'Autopilot',
|
|
'icon': 'auto_graph',
|
|
'tag': '自适应结构, 全场景适配',
|
|
'desc': '旨在概述和回顾项目内容,重点捕捉所提话题的精髓和关键点',
|
|
'prompt': '提示词',
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 1,
|
|
'name': '推理Autopilot',
|
|
'icon': 'add_to_drive_outlined',
|
|
'tag': '推理模型, 自动结构化',
|
|
'desc': '旨在概述和回顾项目内容,重点捕捉所提话题的精髓和关键点',
|
|
'prompt': '提示词',
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 1,
|
|
'name': '通话',
|
|
'icon': 'perm_phone_msg',
|
|
'tag': '主题, 代办事项',
|
|
'desc': '旨在概述和回顾项目内容,重点捕捉所提话题的精髓和关键点',
|
|
'prompt': '提示词',
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 1,
|
|
'name': '项目计划',
|
|
'icon': 'assignment',
|
|
'tag': '目标, 里程碑',
|
|
'desc': '用于规划项目阶段和关键节点,跟踪项目执行进度',
|
|
'prompt': '请按时间顺序整理项目阶段'
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 1,
|
|
'name': '头脑风暴',
|
|
'icon': 'lightbulb',
|
|
'tag': '创意, 发散思维',
|
|
'desc': '记录创意发散过程,结构化整理核心创意点',
|
|
'prompt': '请将讨论内容按创新性排序'
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 1,
|
|
'name': '日常记录',
|
|
'icon': 'note',
|
|
'tag': '日志, 每日总结',
|
|
'desc': '自动化生成结构化日报,自动提取工作亮点与待办事项',
|
|
'prompt': '请按优先级排列今日工作事项'
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 2,
|
|
'name': '咨询',
|
|
'icon': 'auto_stories',
|
|
'tag': '主题, 代办事项',
|
|
'desc': '旨在概述和回顾项目内容,重点捕捉所提话题的精髓和关键点',
|
|
'prompt': '提示词',
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 2,
|
|
'name': '讨论',
|
|
'icon': 'auto_graph',
|
|
'tag': '自适应结构, 全场景适配',
|
|
'desc': '旨在概述和回顾项目内容,重点捕捉所提话题的精髓和关键点',
|
|
'prompt': '提示词',
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 2,
|
|
'name': '汇报',
|
|
'icon': 'add_to_drive_outlined',
|
|
'tag': '推理模型, 自动结构化',
|
|
'desc': '旨在概述和回顾项目内容,重点捕捉所提话题的精髓和关键点',
|
|
'prompt': '提示词',
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 2,
|
|
'name': '任务分配',
|
|
'icon': 'perm_phone_msg',
|
|
'tag': '主题, 代办事项',
|
|
'desc': '旨在概述和回顾项目内容,重点捕捉所提话题的精髓和关键点',
|
|
'prompt': '提示词',
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 2,
|
|
'name': '评审会议',
|
|
'icon': 'rate_review',
|
|
'tag': '质量评估, 改进建议',
|
|
'desc': '用于评估项目阶段成果,生成改进建议和风险评估',
|
|
'prompt': '请按优先级列出需要改进的环节'
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 2,
|
|
'name': '周例会',
|
|
'icon': 'event_repeat',
|
|
'tag': '进度汇报, 计划制定',
|
|
'desc': '自动生成每周工作进展摘要,识别延期风险',
|
|
'prompt': '请按部门分类整理工作进度'
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 2,
|
|
'name': '客户洽谈',
|
|
'icon': 'handshake',
|
|
'tag': '需求沟通, 合同条款',
|
|
'desc': '记录客户核心诉求和合作关键条款',
|
|
'prompt': '请按优先级排列客户需求'
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 2,
|
|
'name': '项目复盘',
|
|
'icon': 'restart_alt',
|
|
'tag': '经验总结, 问题分析',
|
|
'desc': '自动生成项目得失分析报告',
|
|
'prompt': '请按影响程度排序待改进项'
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 3,
|
|
'name': '课堂笔记',
|
|
'icon': 'auto_stories',
|
|
'tag': '主题, 代办事项',
|
|
'desc': '旨在概述和回顾项目内容,重点捕捉所提话题的精髓和关键点',
|
|
'prompt': '提示词',
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 3,
|
|
'name': '讲座',
|
|
'icon': 'auto_graph',
|
|
'tag': '自适应结构, 全场景适配',
|
|
'desc': '旨在概述和回顾项目内容,重点捕捉所提话题的精髓和关键点',
|
|
'prompt': '提示词',
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 3,
|
|
'name': '培训',
|
|
'icon': 'add_to_drive_outlined',
|
|
'tag': '推理模型, 自动结构化',
|
|
'desc': '旨在概述和回顾项目内容,重点捕捉所提话题的精髓和关键点',
|
|
'prompt': '提示词',
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 3,
|
|
'name': 'Sermon',
|
|
'icon': 'perm_phone_msg',
|
|
'tag': '主题, 代办事项',
|
|
'desc': '旨在概述和回顾项目内容,重点捕捉所提话题的精髓和关键点',
|
|
'prompt': '提示词',
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 3,
|
|
'name': '产品发布会',
|
|
'icon': 'rocket_launch',
|
|
'tag': '功能展示, 市场定位',
|
|
'desc': '结构化整理产品核心卖点和市场差异化特征',
|
|
'prompt': '请按用户场景分类产品功能'
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 3,
|
|
'name': '技术分享',
|
|
'icon': 'code',
|
|
'tag': '知识传递, 最佳实践',
|
|
'desc': '自动提取技术要点和可复用代码片段',
|
|
'prompt': '请按技术难度分级整理内容'
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 3,
|
|
'name': '投资者路演',
|
|
'icon': 'bar_chart',
|
|
'tag': '财务数据, 商业模式',
|
|
'desc': '自动提取核心财务指标和增长预期',
|
|
'prompt': '请按投资关注度整理内容'
|
|
});
|
|
batch.insert('meetingtemplate', {
|
|
'categoryid': 3,
|
|
'name': '学术报告',
|
|
'icon': 'school',
|
|
'tag': '研究成果, 数据分析',
|
|
'desc': '结构化整理实验数据和学术论点',
|
|
'prompt': '请按研究重要性排序结论'
|
|
});
|
|
await batch.commit();
|
|
}
|
|
}
|
|
|