修正消息中心不显示
This commit is contained in:
@@ -69,8 +69,8 @@ INSERT INTO `tb_sys_permission` (id,permission_id, name, code, description, modu
|
||||
('19','perm_sensitive_manage', '敏感词管理', 'sensitive:manage', '敏感词管理权限', 'module_sensitive', '1', now());
|
||||
|
||||
-- 插入角色-权限关联数据
|
||||
INSERT INTO `tb_sys_role_permission` (id, role_id, permission_id, creator, create_time) VALUES
|
||||
-- 超级管理员:拥有所有权限
|
||||
INSERT INTO `tb_sys_role_permission` (id, role_id, permission_id, creator, create_time) VALUES
|
||||
('1', 'superadmin', 'perm_default', '1', now()),
|
||||
('2', 'superadmin', 'perm_system_manage', '1', now()),
|
||||
('3', 'superadmin', 'perm_system_dept_manage', '1', now()),
|
||||
@@ -116,8 +116,8 @@ INSERT INTO `tb_sys_role_permission` (id, role_id, permission_id, creator, creat
|
||||
('45', 'freedom', 'perm_message_view', '1', now());
|
||||
|
||||
-- 插入前端菜单数据
|
||||
INSERT INTO `tb_sys_menu` VALUES
|
||||
-- 用户前端菜单 (100-699)
|
||||
INSERT INTO `tb_sys_menu` VALUES
|
||||
('100', 'menu_home', '首页', NULL, '/home', 'user/home/HomeView', NULL, 1, 1, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:49:56', NULL, 0),
|
||||
('101', 'menu_resource_hot', '热门资源', NULL, '/resource-hot', 'user/resource-center/HotResourceView', NULL, 2, 3, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:49:56', NULL, 0),
|
||||
('200', 'menu_resource_center', '资源中心', NULL, '/resource-center', 'user/resource-center/ResourceCenterView', NULL, 2, 1, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:49:56', NULL, 0),
|
||||
@@ -128,13 +128,13 @@ INSERT INTO `tb_sys_menu` VALUES
|
||||
('304', 'menu_course_detail', '课程详情', 'menu_study_plan', '/study-plan/course-detail', 'user/study-plan/CourseDetailView', NULL, 4, 3, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:48:39', NULL, 0),
|
||||
('305', 'menu_course_study', '课程学习', 'menu_study_plan', '/study-plan/course-study', 'user/study-plan/CourseStudyView', NULL, 5, 3, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:48:39', NULL, 0),
|
||||
('400', 'menu_user_dropdown', '用户下拉菜单', NULL, '', '', NULL, 4, 0, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:49:56', NULL, 0),
|
||||
('401', 'menu_user_center', '个人中心', 'menu_user_dropdown', '/user-center', 'user/user-center/UserCenterView', NULL, 4, 1, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:49:56', NULL, 0),
|
||||
('401', 'menu_user_center', '个人中心', 'menu_user_dropdown', '/user-center', 'user/user-center/UserCenterLayout', NULL, 4, 1, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:49:56', NULL, 0),
|
||||
('402', 'menu_learning_records', '学习记录', 'menu_user_center', '/user-center/learning-records', 'user/user-center/LearningRecordsView', NULL, 1, 0, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:49:56', NULL, 0),
|
||||
('403', 'menu_my_favorites', '我的收藏', 'menu_user_center', '/user-center/favorites', 'user/user-center/MyFavoritesView', NULL, 2, 0, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:49:56', NULL, 0),
|
||||
('404', 'menu_my_achievements', '我的成就', 'menu_user_center', '/user-center/achievements', 'user/user-center/MyAchievementsView', NULL, 3, 0, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:49:56', NULL, 0),
|
||||
('500', 'menu_profile', '账号中心', 'menu_user_dropdown', '/profile', 'user/profile/ProfileView', NULL, 5, 1, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:49:56', NULL, 0),
|
||||
('501', 'menu_personal_info', '个人信息', 'menu_profile', '/profile/personal-info', 'user/profile/PersonalInfoView', NULL, 1, 0, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:48:39', NULL, 0),
|
||||
('502', 'menu_account_settings', '账号设置', 'menu_profile', '/profile/account-settings', 'user/profile/AccountSettingsView', NULL, 2, 0, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:48:39', NULL, 0),
|
||||
('500', 'menu_profile', '账号中心', 'menu_user_dropdown', '/profile', 'user/user-center/UserCenterLayout', NULL, 5, 1, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:49:56', NULL, 0),
|
||||
('501', 'menu_personal_info', '个人信息', 'menu_profile', '/profile/personal-info', 'user/user-center/profile/PersonalInfoView', NULL, 1, 0, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:48:39', NULL, 0),
|
||||
('502', 'menu_account_settings', '账号设置', 'menu_profile', '/profile/account-settings', 'user/user-center/profile/AccountSettingsView', NULL, 2, 0, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:48:39', NULL, 0),
|
||||
('503', 'menu_search', '搜索', NULL, '/search', 'user/resource-center/SearchView', NULL, 3, 0, 'NavigationLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:48:39', NULL, 0),
|
||||
-- 管理后台菜单 (1000-8999)
|
||||
('1000', 'menu_admin_overview', '系统总览', NULL, '/admin/overview', 'admin/overview/SystemOverviewView', 'admin/overview.svg', 1, 0, 'SidebarLayout', '1', NULL, '2025-10-27 17:26:06', '2025-10-29 11:52:32', NULL, 0),
|
||||
@@ -177,8 +177,8 @@ INSERT INTO `tb_sys_menu` VALUES
|
||||
('651', 'menu_user_message_detail', '消息详情', 'menu_user_message_center', '/user/message/detail/:messageID', 'user/message/MyMessageDetailView', NULL, 1, 3, 'NavigationLayout', '1', NULL, '2025-11-13 10:00:00', '2025-11-13 10:00:00', NULL, 0);
|
||||
|
||||
-- 插入菜单权限关联数据
|
||||
INSERT INTO `tb_sys_menu_permission` (id, permission_id, menu_id, creator, create_time) VALUES
|
||||
-- 前端菜单权限关联
|
||||
INSERT INTO `tb_sys_menu_permission` (id, permission_id, menu_id, creator, create_time) VALUES
|
||||
('100', 'perm_default', 'menu_home', '1', now()),
|
||||
('102', 'perm_default', 'menu_resource_hot', '1', now()),
|
||||
('101', 'perm_default', 'menu_resource_center', '1', now()),
|
||||
@@ -241,11 +241,7 @@ INSERT INTO `tb_sys_menu_permission` (id, permission_id, menu_id, creator, creat
|
||||
|
||||
-- 消息通知管理菜单权限关联
|
||||
('240', 'perm_message_manage', 'menu_admin_message_manage', '1', now()),
|
||||
('241', 'perm_message_manage', 'menu_admin_message_list', '1', now()),
|
||||
('242', 'perm_message_send', 'menu_admin_message_create', '1', now()),
|
||||
('243', 'perm_message_manage', 'menu_admin_message_detail', '1', now()),
|
||||
|
||||
-- 用户端消息中心权限关联
|
||||
('250', 'perm_message_view', 'menu_user_message_center', '1', now()),
|
||||
('251', 'perm_message_view', 'menu_user_message_detail', '1', now());
|
||||
('250', 'perm_default', 'menu_user_message_center', '1', now()),
|
||||
('251', 'perm_default', 'menu_user_message_detail', '1', now());
|
||||
|
||||
|
||||
@@ -97,6 +97,51 @@ execute_init_script() {
|
||||
fi
|
||||
}
|
||||
|
||||
# 执行敏感词导入
|
||||
import_sensitive_words() {
|
||||
print_message $BLUE "开始导入敏感词数据..."
|
||||
|
||||
# 检查conda是否可用
|
||||
if ! command -v conda &> /dev/null; then
|
||||
print_message $YELLOW "conda命令未找到,跳过敏感词导入"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# 检查schoolNewsCrawler环境是否存在
|
||||
if ! conda env list | grep -q "schoolNewsCrawler"; then
|
||||
print_message $YELLOW "conda环境 'schoolNewsCrawler' 不存在,跳过敏感词导入"
|
||||
print_message $YELLOW "提示: 可以使用以下命令创建环境: conda create -n schoolNewsCrawler python=3.10"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# 切换到敏感词脚本目录
|
||||
local sensitive_dir="$SCRIPT_DIR/sensitiveData"
|
||||
if [ ! -d "$sensitive_dir" ]; then
|
||||
print_message $YELLOW "敏感词脚本目录不存在: $sensitive_dir"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ ! -f "$sensitive_dir/writeWord.py" ]; then
|
||||
print_message $YELLOW "敏感词脚本不存在: $sensitive_dir/writeWord.py"
|
||||
return 0
|
||||
fi
|
||||
|
||||
print_message $BLUE "激活conda环境: schoolNewsCrawler"
|
||||
cd "$sensitive_dir"
|
||||
|
||||
# 使用conda run来在指定环境中执行命令,添加-y参数自动确认
|
||||
conda run -n schoolNewsCrawler python writeWord.py -y
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
print_message $GREEN "敏感词数据导入成功"
|
||||
else
|
||||
print_message $YELLOW "敏感词数据导入失败,但不影响系统运行"
|
||||
fi
|
||||
|
||||
# 返回脚本目录
|
||||
cd "$SCRIPT_DIR"
|
||||
}
|
||||
|
||||
# 验证初始化结果
|
||||
verify_initialization() {
|
||||
print_message $BLUE "验证初始化结果..."
|
||||
@@ -120,6 +165,14 @@ verify_initialization() {
|
||||
else
|
||||
print_message $YELLOW "默认用户创建失败"
|
||||
fi
|
||||
|
||||
# 检查敏感词数量
|
||||
local sensitive_count=$(mysql -h"$DB_HOST" -P"$DB_PORT" -u"$DB_USER" -p"$DB_PASSWORD" -D"$DB_NAME" -e "SELECT COUNT(*) FROM tb_sensitive_word;" 2>/dev/null | tail -n 1)
|
||||
if [ -n "$sensitive_count" ] && [ "$sensitive_count" -gt 0 ]; then
|
||||
print_message $GREEN "敏感词数据: $sensitive_count 个"
|
||||
else
|
||||
print_message $YELLOW "敏感词数据: 0 个 (可能未导入或表不存在)"
|
||||
fi
|
||||
}
|
||||
|
||||
# 显示初始化信息
|
||||
@@ -146,6 +199,8 @@ show_initialization_info() {
|
||||
print_message $YELLOW " - AI智能体"
|
||||
print_message $YELLOW " - 系统配置"
|
||||
print_message $YELLOW " - 文件管理"
|
||||
print_message $YELLOW " - 敏感词过滤"
|
||||
print_message $YELLOW " - 消息通知"
|
||||
print_message $BLUE "====================================================="
|
||||
}
|
||||
|
||||
@@ -153,7 +208,7 @@ show_initialization_info() {
|
||||
main() {
|
||||
print_message $BLUE "====================================================="
|
||||
print_message $BLUE "校园思政新闻平台数据库重新初始化脚本"
|
||||
print_message $BLUE "版本: 1.0.0"
|
||||
print_message $BLUE "版本: 1.1.0"
|
||||
print_message $BLUE "====================================================="
|
||||
|
||||
# 检查MySQL连接
|
||||
@@ -170,12 +225,15 @@ main() {
|
||||
# 执行初始化脚本
|
||||
execute_init_script
|
||||
|
||||
# 导入敏感词数据
|
||||
|
||||
# 验证初始化结果
|
||||
verify_initialization
|
||||
|
||||
# 显示初始化信息
|
||||
show_initialization_info
|
||||
|
||||
import_sensitive_words
|
||||
|
||||
print_message $GREEN "初始化完成!"
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import pymysql
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
from datetime import datetime
|
||||
|
||||
# 数据库配置
|
||||
@@ -110,13 +111,25 @@ def check_duplicates(connection, words):
|
||||
|
||||
def main():
|
||||
"""主函数"""
|
||||
# 解析命令行参数
|
||||
parser = argparse.ArgumentParser(description='敏感词批量导入工具')
|
||||
parser.add_argument('-y', '--yes', action='store_true',
|
||||
help='自动确认导入,跳过交互式确认')
|
||||
parser.add_argument('--file', type=str,
|
||||
help='指定敏感词文件路径(默认: sensitive_word_dict.txt)')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
print("=" * 50)
|
||||
print("敏感词批量导入工具")
|
||||
print("=" * 50)
|
||||
|
||||
# 获取脚本所在目录
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
dict_file = os.path.join(script_dir, 'sensitive_word_dict.txt')
|
||||
# 获取敏感词文件路径
|
||||
if args.file:
|
||||
dict_file = args.file
|
||||
else:
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
dict_file = os.path.join(script_dir, 'sensitive_word_dict.txt')
|
||||
|
||||
# 检查敏感词文件是否存在
|
||||
if not os.path.exists(dict_file):
|
||||
@@ -150,11 +163,20 @@ def main():
|
||||
|
||||
# 确认导入
|
||||
print(f"准备导入 {len(words)} 个敏感词到数据库")
|
||||
confirm = input("是否继续?(y/N): ").strip().lower()
|
||||
|
||||
if confirm != 'y':
|
||||
print("用户取消导入")
|
||||
return
|
||||
if args.yes:
|
||||
print("自动确认模式,开始导入...")
|
||||
else:
|
||||
try:
|
||||
confirm = input("是否继续?(y/N): ").strip().lower()
|
||||
if confirm != 'y':
|
||||
print("用户取消导入")
|
||||
return
|
||||
except EOFError:
|
||||
print("检测到非交互式环境,自动确认导入...")
|
||||
except KeyboardInterrupt:
|
||||
print("\n用户中断导入")
|
||||
return
|
||||
|
||||
# 批量插入
|
||||
print("开始批量导入敏感词...")
|
||||
Reference in New Issue
Block a user