diff --git a/.fastRequest/config/fastRequestCurrentProjectConfig.json b/.fastRequest/config/fastRequestCurrentProjectConfig.json new file mode 100644 index 0000000..a1ecd01 --- /dev/null +++ b/.fastRequest/config/fastRequestCurrentProjectConfig.json @@ -0,0 +1,33 @@ +{ + "apiDocTemplate":"#if (${namingPolicy}=='byDoc')\n$H1 ${methodDescription}\n#else\n$H1 $!{methodName}\n\n$H3 Method description\n\n```\n$!{methodDescription}\n```\n#end\n\n> URL: $!{url}\n>\n> Origin Url: $!{originUrl}\n>\n> Type: $!{methodType}\n\n\n$H3 Request headers\n\n|Header Name| Header Value|\n|---------|------|\n#foreach( $h in ${headerList})\n|$h.type|$h.value|\n#end\n\n$H3 Parameters\n\n$H5 Path parameters\n\n| Parameter | Type | Value | Description |\n|---------|------|------|------------|\n#foreach( $node in ${pathKeyValueList})\n|$node.key|$!{node.type}|$!{node.value}|$!{node.comment}|\n#end\n\n\n$H5 URL parameters\n\n|Required| Parameter | Type | Value | Description |\n|---------|---------|------|------|------------|\n#foreach( $node in ${urlParamsKeyValueList})\n|$!{node.enabled}|$!{node.key}|$!{node.type}|$!{node.value}|$!{node.comment}|\n#end\n\n\n$H5 Body parameters\n\n$H6 JSON\n\n```\n${jsonParam}\n```\n\n$H6 JSON document\n\n```\n${jsonParamDocument}\n```\n\n\n$H5 Form URL-Encoded\n|Required| Parameter | Type | Value | Description |\n|---------|---------|------|------|------------|\n#foreach( $node in ${urlEncodedKeyValueList})\n|$!{node.enabled}|$!{node.key}|$!{node.type}|$!{node.value}|$!{node.comment}|\n#end\n\n\n$H5 Multipart\n|Required | Parameter | Type | Value | Description |\n|---------|---------|------|------|------------|\n#foreach( $node in ${multipartKeyValueList})\n|$!{node.enabled}|$!{node.key}|$!{node.type}|$!{node.value}|$!{node.comment}|\n#end\n\n\n$H3 Response\n\n$H5 Response example\n\n```\n$!{responseExample}\n```\n\n$H5 Response document\n```\n$!{returnDocument}\n```\n\n\n", + "apifoxSetting":{ + "domain":"https://api.apifox.com", + "syncAfterSave":false + }, + "dataList":[], + "envList":[], + "headerList":[], + "ignoreParseFieldList":[], + "maxDescriptionLength":-1, + "pmCollectionId":"", + "postScript":"", + "preScript":"", + "projectList":[], + "syncModel":{ + "branch":"master", + "domain":"https://github.com", + "enabled":false, + "gitToken":"", + "namingPolicy":"byDoc", + "owner":"", + "repo":"", + "repoUrl":"", + "syncAfterRun":false, + "type":"github" + }, + "syncPmAfterSave":false, + "urlEncodedKeyValueList":[], + "urlParamsKeyValueList":[], + "urlSuffix":"", + "workspaceId":"" +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..0a8642f --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Zeppelin ignored files +/ZeppelinRemoteNotebooks/ diff --git a/.idea/ApifoxUploaderProjectSetting.xml b/.idea/ApifoxUploaderProjectSetting.xml new file mode 100644 index 0000000..fc0729c --- /dev/null +++ b/.idea/ApifoxUploaderProjectSetting.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml new file mode 100644 index 0000000..e9f575b --- /dev/null +++ b/.idea/checkstyle-idea.xml @@ -0,0 +1,16 @@ + + + + 10.21.3 + JavaOnly + true + + + \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..919ce1f --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..1f87f06 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/fastRequest/fastRequestCurrentProjectLocalConfig.xml b/.idea/fastRequest/fastRequestCurrentProjectLocalConfig.xml new file mode 100644 index 0000000..e62f560 --- /dev/null +++ b/.idea/fastRequest/fastRequestCurrentProjectLocalConfig.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..8d66637 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..df00c07 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..74dff5e --- /dev/null +++ b/pom.xml @@ -0,0 +1,79 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.2.4 + + + + com.nuaa.video + video-platform + 1.0.0 + pom + video-platform + 基于Spring Cloud的高可用在线视频平台 + + + 17 + UTF-8 + UTF-8 + 2023.0.1 + 2023.0.1.0 + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + ${spring-cloud-alibaba.version} + pom + import + + + + + + + video-common + video-gateway + video-auth + video-user + video-content + video-comment + video-recommend + video-admin + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + + + + + \ No newline at end of file diff --git a/sql/init.sql b/sql/init.sql new file mode 100644 index 0000000..c3fd577 --- /dev/null +++ b/sql/init.sql @@ -0,0 +1,783 @@ +-- 1. 创建数据库 +CREATE DATABASE IF NOT EXISTS `video_auth` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +CREATE DATABASE IF NOT EXISTS `video_user` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +CREATE DATABASE IF NOT EXISTS `video_content` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +CREATE DATABASE IF NOT EXISTS `video_comment` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +CREATE DATABASE IF NOT EXISTS `video_recommend` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +CREATE DATABASE IF NOT EXISTS `video_admin` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- 2. 认证数据库(video_auth) +USE `video_auth`; + +-- 用户认证表 +CREATE TABLE IF NOT EXISTS `auth_user` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户ID', + `username` varchar(64) NOT NULL COMMENT '用户名', + `password` varchar(256) NOT NULL COMMENT '密码(加密)', + `salt` varchar(64) NOT NULL COMMENT '加密盐值', + `email` varchar(128) DEFAULT NULL COMMENT '邮箱', + `phone` varchar(20) DEFAULT NULL COMMENT '手机号', + `status` tinyint NOT NULL DEFAULT '1' COMMENT '状态(0:禁用,1:正常)', + `last_login_time` datetime DEFAULT NULL COMMENT '最后登录时间', + `last_login_ip` varchar(64) DEFAULT NULL COMMENT '最后登录IP', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_username` (`username`), + UNIQUE KEY `idx_email` (`email`), + UNIQUE KEY `idx_phone` (`phone`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户认证表'; + +-- 用户角色表 +CREATE TABLE IF NOT EXISTS `auth_role` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '角色ID', + `name` varchar(64) NOT NULL COMMENT '角色名称', + `code` varchar(64) NOT NULL COMMENT '角色编码(USER_开头)', + `description` varchar(256) DEFAULT NULL COMMENT '角色描述', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_code` (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户角色表'; + +-- 用户权限表 +CREATE TABLE IF NOT EXISTS `auth_permission` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '权限ID', + `name` varchar(64) NOT NULL COMMENT '权限名称', + `code` varchar(64) NOT NULL COMMENT '权限编码', + `description` varchar(256) DEFAULT NULL COMMENT '权限描述', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_code` (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户权限表'; + +-- 用户角色关联表 +CREATE TABLE IF NOT EXISTS `auth_user_role` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `role_id` bigint NOT NULL COMMENT '角色ID', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_user_role` (`user_id`,`role_id`), + CONSTRAINT `fk_aur_user` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_aur_role` FOREIGN KEY (`role_id`) REFERENCES `auth_role` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户角色关联表'; + +-- 角色权限关联表 +CREATE TABLE IF NOT EXISTS `auth_role_permission` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `role_id` bigint NOT NULL COMMENT '角色ID', + `permission_id` bigint NOT NULL COMMENT '权限ID', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_role_permission` (`role_id`,`permission_id`), + CONSTRAINT `fk_arp_role` FOREIGN KEY (`role_id`) REFERENCES `auth_role` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_arp_permission` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='角色权限关联表'; + +-- OAuth2客户端表 +CREATE TABLE IF NOT EXISTS `auth_oauth_client` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `client_id` varchar(64) NOT NULL COMMENT '客户端ID', + `client_secret` varchar(256) NOT NULL COMMENT '客户端密钥', + `client_name` varchar(128) NOT NULL COMMENT '客户端名称', + `client_uri` varchar(256) DEFAULT NULL COMMENT '客户端主页', + `redirect_uri` varchar(256) DEFAULT NULL COMMENT '重定向URI', + `scope` varchar(128) NOT NULL COMMENT '授权范围', + `grant_types` varchar(128) NOT NULL COMMENT '授权类型', + `access_token_validity` int NOT NULL DEFAULT '3600' COMMENT '访问令牌有效期(秒)', + `refresh_token_validity` int NOT NULL DEFAULT '86400' COMMENT '刷新令牌有效期(秒)', + `additional_information` text COMMENT '附加信息', + `status` tinyint NOT NULL DEFAULT '1' COMMENT '状态(0:禁用,1:正常)', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_client_id` (`client_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='OAuth2客户端表'; + +-- 初始化认证数据 +INSERT IGNORE INTO `auth_role` (`id`, `name`, `code`, `description`) VALUES + (1, '管理员', 'USER_ADMIN', '系统管理员'), + (2, '普通用户', 'USER_NORMAL', '普通用户'), + (3, 'VIP用户', 'USER_VIP', 'VIP用户'), + (4, '内容创作者', 'USER_CREATOR', '内容创作专用角色'); + +INSERT IGNORE INTO `auth_permission` (`id`, `name`, `code`, `description`) VALUES + (1, '视频上传', 'video:upload', '视频上传权限'), + (2, '视频管理', 'video:manage', '视频管理权限'), + (3, '评论管理', 'comment:manage', '评论管理权限'), + (4, '个人资料管理', 'profile:manage', '个人资料管理权限'); + +INSERT IGNORE INTO `auth_role_permission` (`role_id`, `permission_id`) VALUES + (1, 1), (1, 2), (1, 3), (1, 4), + (3, 1), (3, 4), + (4, 1), (4, 3), (4, 4); + +INSERT IGNORE INTO `auth_oauth_client` (`client_id`, `client_secret`, `client_name`, `redirect_uri`, `scope`, `grant_types`, `access_token_validity`, `refresh_token_validity`) VALUES + ('video-web', '$2a$10$oRZ7x/.dW.6Q9z0QY1JZ5e9ZQ9z0QY1JZ5e9ZQ9z0QY1JZ5e9ZQ', '视频网站前端', 'http://localhost:8080', 'all', 'password,refresh_token', 3600, 86400), + ('video-admin', '$2a$10$oRZ7x/.dW.6Q9z0QY1JZ5e9ZQ9z0QY1JZ5e9ZQ9z0QY1JZ5e9ZQ', '视频管理后台', 'http://localhost:8081', 'all', 'authorization_code,refresh_token', 3600, 86400); + +-- 3. 用户数据库(video_user) +USE `video_user`; + +-- 用户信息表 +CREATE TABLE IF NOT EXISTS `user_info` ( + `id` bigint NOT NULL COMMENT '用户ID', + `nickname` varchar(64) NOT NULL COMMENT '昵称', + `avatar` varchar(256) DEFAULT NULL COMMENT '头像URL', + `gender` tinyint DEFAULT '0' COMMENT '性别(0:未知,1:男,2:女)', + `birthday` date DEFAULT NULL COMMENT '生日', + `signature` varchar(256) DEFAULT NULL COMMENT '个性签名', + `region` varchar(128) DEFAULT NULL COMMENT '地区', + `follower_count` int NOT NULL DEFAULT '0' COMMENT '粉丝数', + `following_count` int NOT NULL DEFAULT '0' COMMENT '关注数', + `video_count` int NOT NULL DEFAULT '0' COMMENT '视频数', + `like_count` int NOT NULL DEFAULT '0' COMMENT '获赞数', + `coin_count` int NOT NULL DEFAULT '0' COMMENT '硬币数', + `favorite_count` int NOT NULL DEFAULT '0' COMMENT '收藏数', + `view_count` bigint NOT NULL DEFAULT '0' COMMENT '播放数', + `level` tinyint NOT NULL DEFAULT '1' COMMENT '等级', + `vip_level` tinyint NOT NULL DEFAULT '0' COMMENT 'VIP等级', + `vip_expire_time` datetime DEFAULT NULL COMMENT 'VIP到期时间', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + CONSTRAINT `fk_ui_user` FOREIGN KEY (`id`) REFERENCES `video_auth`.`auth_user` (`id`) ON DELETE CASCADE, + KEY `idx_nickname` (`nickname`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户信息表'; + +-- 用户统计表(按天) +CREATE TABLE IF NOT EXISTS `user_stat_daily` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `stat_date` date NOT NULL COMMENT '统计日期', + `follower_increment` int NOT NULL DEFAULT '0' COMMENT '新增粉丝数', + `following_increment` int NOT NULL DEFAULT '0' COMMENT '新增关注数', + `video_increment` int NOT NULL DEFAULT '0' COMMENT '新增视频数', + `like_increment` int NOT NULL DEFAULT '0' COMMENT '新增获赞数', + `coin_increment` int NOT NULL DEFAULT '0' COMMENT '新增硬币数', + `favorite_increment` int NOT NULL DEFAULT '0' COMMENT '新增收藏数', + `view_increment` bigint NOT NULL DEFAULT '0' COMMENT '新增播放数', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_user_date` (`user_id`,`stat_date`), + CONSTRAINT `fk_usd_user` FOREIGN KEY (`user_id`) REFERENCES `user_info` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户每日统计表'; + +-- 用户关注表 +CREATE TABLE IF NOT EXISTS `user_follow` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `follow_id` bigint NOT NULL COMMENT '关注用户ID', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_user_follow` (`user_id`,`follow_id`), + KEY `idx_follow` (`follow_id`), + CONSTRAINT `fk_uf_user` FOREIGN KEY (`user_id`) REFERENCES `user_info` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_uf_follow` FOREIGN KEY (`follow_id`) REFERENCES `user_info` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户关注表'; + +-- 用户私信表 +CREATE TABLE IF NOT EXISTS `user_message` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `sender_id` bigint NOT NULL COMMENT '发送者ID', + `receiver_id` bigint NOT NULL COMMENT '接收者ID', + `content` text NOT NULL COMMENT '消息内容', + `is_read` tinyint NOT NULL DEFAULT '0' COMMENT '是否已读(0:未读,1:已读)', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + KEY `idx_sender` (`sender_id`), + KEY `idx_receiver` (`receiver_id`), + KEY `idx_receiver_read` (`receiver_id`,`is_read`), + CONSTRAINT `fk_um_sender` FOREIGN KEY (`sender_id`) REFERENCES `user_info` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_um_receiver` FOREIGN KEY (`receiver_id`) REFERENCES `user_info` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户私信表'; + +-- 用户通知表 +CREATE TABLE IF NOT EXISTS `user_notification` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `type` tinyint NOT NULL COMMENT '通知类型(1:点赞,2:评论,3:关注,4:系统通知)', + `content` text NOT NULL COMMENT '通知内容', + `related_id` bigint DEFAULT NULL COMMENT '相关ID', + `is_read` tinyint NOT NULL DEFAULT '0' COMMENT '是否已读(0:未读,1:已读)', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + KEY `idx_user` (`user_id`), + KEY `idx_user_read` (`user_id`,`is_read`), + CONSTRAINT `fk_un_user` FOREIGN KEY (`user_id`) REFERENCES `user_info` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户通知表'; + +-- 用户设置表 +CREATE TABLE IF NOT EXISTS `user_setting` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `privacy_level` tinyint NOT NULL DEFAULT '1' COMMENT '隐私等级(1:公开,2:仅关注,3:私密)', + `comment_notify` tinyint NOT NULL DEFAULT '1' COMMENT '评论通知(0:关闭,1:开启)', + `like_notify` tinyint NOT NULL DEFAULT '1' COMMENT '点赞通知(0:关闭,1:开启)', + `follow_notify` tinyint NOT NULL DEFAULT '1' COMMENT '关注通知(0:关闭,1:开启)', + `system_notify` tinyint NOT NULL DEFAULT '1' COMMENT '系统通知(0:关闭,1:开启)', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_user` (`user_id`), + CONSTRAINT `fk_us_user` FOREIGN KEY (`user_id`) REFERENCES `user_info` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户设置表'; + +-- 4. 内容数据库(video_content) +USE `video_content`; + +-- 视频分类表 +CREATE TABLE IF NOT EXISTS `content_category` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '分类ID', + `name` varchar(64) NOT NULL COMMENT '分类名称', + `code` varchar(64) NOT NULL COMMENT '分类编码', + `parent_id` bigint DEFAULT '0' COMMENT '父分类ID', + `level` tinyint NOT NULL DEFAULT '1' COMMENT '分类层级', + `sort` int NOT NULL DEFAULT '0' COMMENT '排序', + `icon` varchar(256) DEFAULT NULL COMMENT '图标', + `status` tinyint NOT NULL DEFAULT '1' COMMENT '状态(0:禁用,1:正常)', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_code` (`code`), + KEY `idx_parent` (`parent_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='视频分类表'; + +-- 视频标签表 +CREATE TABLE IF NOT EXISTS `content_tag` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '标签ID', + `name` varchar(64) NOT NULL COMMENT '标签名称', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_name` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='视频标签表'; + +-- 视频信息表 +CREATE TABLE IF NOT EXISTS `content_video` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '视频ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `title` varchar(256) NOT NULL COMMENT '视频标题', + `description` text COMMENT '视频描述', + `cover_url` varchar(256) NOT NULL COMMENT '封面URL', + `video_url` varchar(256) NOT NULL COMMENT '视频URL', + `duration` int NOT NULL COMMENT '视频时长(秒)', + `width` int NOT NULL COMMENT '视频宽度', + `height` int NOT NULL COMMENT '视频高度', + `format` varchar(32) NOT NULL COMMENT '视频格式', + `size` bigint NOT NULL COMMENT '视频大小(字节)', + `category_id` bigint NOT NULL COMMENT '分类ID', + `status` tinyint NOT NULL DEFAULT '0' COMMENT '状态(0:审核中,1:已发布,2:已下架,3:审核不通过)', + `like_count` int NOT NULL DEFAULT '0' COMMENT '点赞数', + `coin_count` int NOT NULL DEFAULT '0' COMMENT '投币数', + `favorite_count` int NOT NULL DEFAULT '0' COMMENT '收藏数', + `comment_count` int NOT NULL DEFAULT '0' COMMENT '评论数', + `view_count` bigint NOT NULL DEFAULT '0' COMMENT '播放数', + `share_count` int NOT NULL DEFAULT '0' COMMENT '分享数', + `danmaku_count` int NOT NULL DEFAULT '0' COMMENT '弹幕数', + `is_recommend` tinyint NOT NULL DEFAULT '0' COMMENT '是否推荐(0:否,1:是)', + `is_top` tinyint NOT NULL DEFAULT '0' COMMENT '是否置顶(0:否,1:是)', + `publish_time` datetime DEFAULT NULL COMMENT '发布时间', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + KEY `idx_user_status` (`user_id`, `status`), + KEY `idx_category_status` (`category_id`, `status`), + KEY `idx_recommend` (`is_recommend`), + KEY `idx_top` (`is_top`), + FULLTEXT KEY `ft_title_desc` (`title`,`description`), + CONSTRAINT `fk_cv_user` FOREIGN KEY (`user_id`) REFERENCES `video_user`.`user_info` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_cv_category` FOREIGN KEY (`category_id`) REFERENCES `content_category` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='视频信息表'; + +-- 视频标签关联表 +CREATE TABLE IF NOT EXISTS `content_video_tag` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `video_id` bigint NOT NULL COMMENT '视频ID', + `tag_id` bigint NOT NULL COMMENT '标签ID', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_video_tag` (`video_id`,`tag_id`), + KEY `idx_tag` (`tag_id`), + CONSTRAINT `fk_cvt_video` FOREIGN KEY (`video_id`) REFERENCES `content_video` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_cvt_tag` FOREIGN KEY (`tag_id`) REFERENCES `content_tag` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='视频标签关联表'; + +-- 视频统计表(按天) +CREATE TABLE IF NOT EXISTS `content_video_stat_daily` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `video_id` bigint NOT NULL COMMENT '视频ID', + `stat_date` date NOT NULL COMMENT '统计日期', + `like_increment` int NOT NULL DEFAULT '0' COMMENT '新增点赞数', + `coin_increment` int NOT NULL DEFAULT '0' COMMENT '新增投币数', + `favorite_increment` int NOT NULL DEFAULT '0' COMMENT '新增收藏数', + `comment_increment` int NOT NULL DEFAULT '0' COMMENT '新增评论数', + `view_increment` bigint NOT NULL DEFAULT '0' COMMENT '新增播放数', + `share_increment` int NOT NULL DEFAULT '0' COMMENT '新增分享数', + `danmaku_increment` int NOT NULL DEFAULT '0' COMMENT '新增弹幕数', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_video_date` (`video_id`,`stat_date`), + CONSTRAINT `fk_cvsd_video` FOREIGN KEY (`video_id`) REFERENCES `content_video` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='视频每日统计表'; + +-- 视频审核记录表 +CREATE TABLE IF NOT EXISTS `content_video_review` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `video_id` bigint NOT NULL COMMENT '视频ID', + `reviewer_id` bigint NOT NULL COMMENT '审核员ID', + `status` tinyint NOT NULL COMMENT '审核状态(1:通过,2:不通过)', + `reason` varchar(256) DEFAULT NULL COMMENT '审核原因', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + KEY `idx_video` (`video_id`), + KEY `idx_reviewer` (`reviewer_id`), + CONSTRAINT `fk_cvr_video` FOREIGN KEY (`video_id`) REFERENCES `content_video` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_cvr_reviewer` FOREIGN KEY (`reviewer_id`) REFERENCES `video_auth`.`auth_user` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='视频审核记录表'; + +-- 视频点赞表 +CREATE TABLE IF NOT EXISTS `content_video_like` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `video_id` bigint NOT NULL COMMENT '视频ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_video_user` (`video_id`,`user_id`), + KEY `idx_user` (`user_id`), + CONSTRAINT `fk_cvl_video` FOREIGN KEY (`video_id`) REFERENCES `content_video` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_cvl_user` FOREIGN KEY (`user_id`) REFERENCES `video_user`.`user_info` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='视频点赞表'; + +-- 视频投币表 +CREATE TABLE IF NOT EXISTS `content_video_coin` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `video_id` bigint NOT NULL COMMENT '视频ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `amount` int NOT NULL DEFAULT '1' COMMENT '投币数量', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_video_user` (`video_id`,`user_id`), + KEY `idx_user` (`user_id`), + CONSTRAINT `fk_cvc_video` FOREIGN KEY (`video_id`) REFERENCES `content_video` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_cvc_user` FOREIGN KEY (`user_id`) REFERENCES `video_user`.`user_info` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='视频投币表'; + +-- 用户收藏夹表 +CREATE TABLE IF NOT EXISTS `content_user_favorite` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '收藏夹ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `name` varchar(64) NOT NULL COMMENT '收藏夹名称', + `description` varchar(256) DEFAULT NULL COMMENT '收藏夹描述', + `is_private` tinyint NOT NULL DEFAULT '0' COMMENT '是否私有(0:公开,1:私有)', + `video_count` int NOT NULL DEFAULT '0' COMMENT '视频数量', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + KEY `idx_user` (`user_id`), + CONSTRAINT `fk_cuf_user` FOREIGN KEY (`user_id`) REFERENCES `video_user`.`user_info` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户收藏夹表'; + +-- 视频收藏表 +CREATE TABLE IF NOT EXISTS `content_video_favorite` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `video_id` bigint NOT NULL COMMENT '视频ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `favorite_id` bigint NOT NULL COMMENT '收藏夹ID', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_video_user_favorite` (`video_id`,`user_id`,`favorite_id`), + KEY `idx_user_favorite` (`user_id`,`favorite_id`), + KEY `idx_video` (`video_id`), + CONSTRAINT `fk_cvf_video` FOREIGN KEY (`video_id`) REFERENCES `content_video` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_cvf_user` FOREIGN KEY (`user_id`) REFERENCES `video_user`.`user_info` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_cvf_favorite` FOREIGN KEY (`favorite_id`) REFERENCES `content_user_favorite` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='视频收藏表'; + +-- 弹幕表 +CREATE TABLE IF NOT EXISTS `content_danmaku` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '弹幕ID', + `video_id` bigint NOT NULL COMMENT '视频ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `content` varchar(256) NOT NULL COMMENT '弹幕内容', + `color` varchar(16) NOT NULL COMMENT '弹幕颜色', + `font_size` tinyint NOT NULL COMMENT '字体大小', + `position` tinyint NOT NULL COMMENT '位置(0:滚动,1:顶部,2:底部)', + `time` float NOT NULL COMMENT '发送时间(秒)', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + KEY `idx_video_time` (`video_id`,`time`), + KEY `idx_user` (`user_id`), + CONSTRAINT `fk_cd_video` FOREIGN KEY (`video_id`) REFERENCES `content_video` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_cd_user` FOREIGN KEY (`user_id`) REFERENCES `video_user`.`user_info` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='弹幕表'; + +-- 视频播放记录表 +CREATE TABLE IF NOT EXISTS `content_video_play_record` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `video_id` bigint NOT NULL COMMENT '视频ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `play_time` int NOT NULL DEFAULT '0' COMMENT '播放时长(秒)', + `is_finished` tinyint NOT NULL DEFAULT '0' COMMENT '是否看完(0:未看完,1:已看完)', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_video_user` (`video_id`,`user_id`), + KEY `idx_user` (`user_id`), + CONSTRAINT `fk_cvpr_video` FOREIGN KEY (`video_id`) REFERENCES `content_video` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_cvpr_user` FOREIGN KEY (`user_id`) REFERENCES `video_user`.`user_info` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='视频播放记录表'; + +-- 初始化分类数据 +INSERT IGNORE INTO `content_category` (`id`, `name`, `code`, `parent_id`, `level`, `sort`) VALUES + (1, '生活', 'life', 0, 1, 1), + (2, '科技', 'tech', 0, 1, 2), + (3, '游戏', 'game', 0, 1, 3), + (4, '美食', 'food', 0, 1, 4), + (5, '音乐', 'music', 0, 1, 5), + (6, '影视', 'movie', 0, 1, 6), + (7, '知识', 'knowledge', 0, 1, 7), + (8, '数码', 'digital', 2, 2, 1), + (9, '软件', 'software', 2, 2, 2), + (10, '硬件', 'hardware', 2, 2, 3), + (11, '手机游戏', 'mobile_game', 3, 2, 1), + (12, '电脑游戏', 'pc_game', 3, 2, 2), + (13, '主机游戏', 'console_game', 3, 2, 3); + +-- 5. 评论数据库(video_comment) +USE `video_comment`; + +-- 评论表 +CREATE TABLE IF NOT EXISTS `comment` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '评论ID', + `video_id` bigint NOT NULL COMMENT '视频ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `content` text NOT NULL COMMENT '评论内容', + `like_count` int NOT NULL DEFAULT '0' COMMENT '点赞数', + `reply_count` int NOT NULL DEFAULT '0' COMMENT '回复数', + `top_status` tinyint NOT NULL DEFAULT '0' COMMENT '置顶状态(0:普通,1:置顶)', + `status` tinyint NOT NULL DEFAULT '1' COMMENT '状态(0:删除,1:正常)', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + KEY `idx_video` (`video_id`), + KEY `idx_user` (`user_id`), + KEY `idx_video_top` (`video_id`,`top_status`), + FULLTEXT KEY `ft_content` (`content`), + CONSTRAINT `fk_c_video` FOREIGN KEY (`video_id`) REFERENCES `video_content`.`content_video` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_c_user` FOREIGN KEY (`user_id`) REFERENCES `video_user`.`user_info` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='评论表'; + +-- 评论回复表 +CREATE TABLE IF NOT EXISTS `comment_reply` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '回复ID', + `comment_id` bigint NOT NULL COMMENT '评论ID', + `video_id` bigint NOT NULL COMMENT '视频ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `reply_to_id` bigint DEFAULT NULL COMMENT '回复目标用户ID', + `content` text NOT NULL COMMENT '回复内容', + `like_count` int NOT NULL DEFAULT '0' COMMENT '点赞数', + `status` tinyint NOT NULL DEFAULT '1' COMMENT '状态(0:删除,1:正常)', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + KEY `idx_comment` (`comment_id`), + KEY `idx_video` (`video_id`), + KEY `idx_user` (`user_id`), + KEY `idx_reply_to` (`reply_to_id`), + KEY `idx_video_time` (`video_id`, `create_time`), + FULLTEXT KEY `ft_content` (`content`), + CONSTRAINT `fk_cr_comment` FOREIGN KEY (`comment_id`) REFERENCES `comment` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_cr_video` FOREIGN KEY (`video_id`) REFERENCES `video_content`.`content_video` (`id`), + CONSTRAINT `fk_cr_user` FOREIGN KEY (`user_id`) REFERENCES `video_user`.`user_info` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_cr_reply_to` FOREIGN KEY (`reply_to_id`) REFERENCES `video_user`.`user_info` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='评论回复表'; + +-- 评论点赞表 +CREATE TABLE IF NOT EXISTS `comment_like` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `comment_id` bigint NOT NULL COMMENT '评论ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `type` tinyint NOT NULL COMMENT '类型(1:评论,2:回复)', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_comment_user_type` (`comment_id`,`user_id`,`type`), + KEY `idx_user` (`user_id`), + CONSTRAINT `fk_cl_comment` FOREIGN KEY (`comment_id`) REFERENCES `comment` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_cl_user` FOREIGN KEY (`user_id`) REFERENCES `video_user`.`user_info` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='评论点赞表'; + +-- 6. 推荐数据库(video_recommend) +USE `video_recommend`; + +-- 用户兴趣标签表 +CREATE TABLE IF NOT EXISTS `recommend_user_interest` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `tag_id` bigint NOT NULL COMMENT '标签ID', + `weight` float NOT NULL DEFAULT '1.0' COMMENT '权重', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_user_tag` (`user_id`,`tag_id`), + KEY `idx_tag` (`tag_id`), + CONSTRAINT `fk_rui_user` FOREIGN KEY (`user_id`) REFERENCES `video_user`.`user_info` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_rui_tag` FOREIGN KEY (`tag_id`) REFERENCES `video_content`.`content_tag` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户兴趣标签表'; + +-- 用户行为记录表 +CREATE TABLE IF NOT EXISTS `recommend_user_behavior` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `video_id` bigint NOT NULL COMMENT '视频ID', + `behavior_type` tinyint NOT NULL COMMENT '行为类型(1:浏览,2:点赞,3:收藏,4:评论,5:分享,6:完整观看)', + `behavior_weight` float NOT NULL DEFAULT '1.0' COMMENT '行为权重', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + KEY `idx_user_video` (`user_id`,`video_id`), + KEY `idx_video` (`video_id`), + KEY `idx_user_behavior` (`user_id`,`behavior_type`), + KEY `idx_create_time` (`create_time`), + CONSTRAINT `fk_rub_user` FOREIGN KEY (`user_id`) REFERENCES `video_user`.`user_info` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_rub_video` FOREIGN KEY (`video_id`) REFERENCES `video_content`.`content_video` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户行为记录表'; + +-- 视频相似度表 +CREATE TABLE IF NOT EXISTS `recommend_video_similarity` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `video_id` bigint NOT NULL COMMENT '视频ID', + `similar_video_id` bigint NOT NULL COMMENT '相似视频ID', + `similarity` float NOT NULL COMMENT '相似度', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_video_similar` (`video_id`,`similar_video_id`), + KEY `idx_similar_video` (`similar_video_id`), + CONSTRAINT `fk_rvs_video` FOREIGN KEY (`video_id`) REFERENCES `video_content`.`content_video` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_rvs_similar_video` FOREIGN KEY (`similar_video_id`) REFERENCES `video_content`.`content_video` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='视频相似度表'; + +-- 用户推荐表 +CREATE TABLE IF NOT EXISTS `recommend_user_recommendation` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `video_id` bigint NOT NULL COMMENT '视频ID', + `recommend_type` tinyint NOT NULL COMMENT '推荐类型(1:基于内容,2:协同过滤,3:热门推荐,4:新视频推荐)', + `score` float NOT NULL COMMENT '推荐分数', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_user_video_type` (`user_id`,`video_id`,`recommend_type`), + KEY `idx_user_type` (`user_id`,`recommend_type`), + KEY `idx_video` (`video_id`), + CONSTRAINT `fk_rur_user` FOREIGN KEY (`user_id`) REFERENCES `video_user`.`user_info` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_rur_video` FOREIGN KEY (`video_id`) REFERENCES `video_content`.`content_video` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户推荐表'; + +-- 热门视频表 +CREATE TABLE IF NOT EXISTS `recommend_hot_video` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `video_id` bigint NOT NULL COMMENT '视频ID', + `hot_score` float NOT NULL COMMENT '热度分数', + `period_type` tinyint NOT NULL COMMENT '周期类型(1:天,2:周,3:月)', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_video_period` (`video_id`,`period_type`), + KEY `idx_period_score` (`period_type`,`hot_score`), + CONSTRAINT `fk_rhv_video` FOREIGN KEY (`video_id`) REFERENCES `video_content`.`content_video` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='热门视频表'; + +-- 7. 管理后台数据库(video_admin) +USE `video_admin`; + +-- 管理员表 +CREATE TABLE IF NOT EXISTS `admin_user` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '管理员ID', + `username` varchar(64) NOT NULL COMMENT '用户名', + `password` varchar(256) NOT NULL COMMENT '密码(加密)', + `salt` varchar(64) NOT NULL COMMENT '加密盐值', + `real_name` varchar(64) DEFAULT NULL COMMENT '真实姓名', + `avatar` varchar(256) DEFAULT NULL COMMENT '头像', + `email` varchar(128) DEFAULT NULL COMMENT '邮箱', + `phone` varchar(20) DEFAULT NULL COMMENT '手机号', + `status` tinyint NOT NULL DEFAULT '1' COMMENT '状态(0:禁用,1:正常)', + `last_login_time` datetime DEFAULT NULL COMMENT '最后登录时间', + `last_login_ip` varchar(64) DEFAULT NULL COMMENT '最后登录IP', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_username` (`username`), + UNIQUE KEY `idx_email` (`email`), + UNIQUE KEY `idx_phone` (`phone`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='管理员表'; + +-- 管理员角色表 +CREATE TABLE IF NOT EXISTS `admin_role` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '角色ID', + `name` varchar(64) NOT NULL COMMENT '角色名称', + `code` varchar(64) NOT NULL COMMENT '角色编码(ADMIN_开头)', + `description` varchar(256) DEFAULT NULL COMMENT '角色描述', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_code` (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='管理员角色表'; + +-- 管理员权限表 +CREATE TABLE IF NOT EXISTS `admin_permission` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '权限ID', + `name` varchar(64) NOT NULL COMMENT '权限名称', + `code` varchar(64) NOT NULL COMMENT '权限编码', + `description` varchar(256) DEFAULT NULL COMMENT '权限描述', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_code` (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='管理员权限表'; + +-- 管理员角色关联表 +CREATE TABLE IF NOT EXISTS `admin_user_role` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `admin_id` bigint NOT NULL COMMENT '管理员ID', + `role_id` bigint NOT NULL COMMENT '角色ID', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_admin_role` (`admin_id`,`role_id`), + CONSTRAINT `fk_aur_admin` FOREIGN KEY (`admin_id`) REFERENCES `admin_user` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_aur_role` FOREIGN KEY (`role_id`) REFERENCES `admin_role` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='管理员角色关联表'; + +-- 角色权限关联表 +CREATE TABLE IF NOT EXISTS `admin_role_permission` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `role_id` bigint NOT NULL COMMENT '角色ID', + `permission_id` bigint NOT NULL COMMENT '权限ID', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_role_permission` (`role_id`,`permission_id`), + CONSTRAINT `fk_arp_role` FOREIGN KEY (`role_id`) REFERENCES `admin_role` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_arp_permission` FOREIGN KEY (`permission_id`) REFERENCES `admin_permission` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='角色权限关联表'; + +-- 操作日志表 +CREATE TABLE IF NOT EXISTS `admin_operation_log` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `admin_id` bigint DEFAULT NULL COMMENT '管理员ID', + `username` varchar(64) DEFAULT NULL COMMENT '用户名', + `operation` varchar(64) NOT NULL COMMENT '操作', + `method` varchar(128) DEFAULT NULL COMMENT '方法名', + `params` text COMMENT '参数', + `ip` varchar(64) DEFAULT NULL COMMENT 'IP地址', + `status` tinyint DEFAULT NULL COMMENT '状态(0:失败,1:成功)', + `error_msg` text COMMENT '错误消息', + `operation_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '操作时间', + PRIMARY KEY (`id`), + KEY `idx_admin` (`admin_id`), + KEY `idx_operation_time` (`operation_time`), + CONSTRAINT `fk_aol_admin` FOREIGN KEY (`admin_id`) REFERENCES `admin_user` (`id`) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='操作日志表'; + +-- 系统配置表 +CREATE TABLE IF NOT EXISTS `admin_system_config` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `config_key` varchar(64) NOT NULL COMMENT '配置键', + `config_value` text NOT NULL COMMENT '配置值', + `description` varchar(256) DEFAULT NULL COMMENT '配置描述', + `created_by` varchar(64) DEFAULT 'system' COMMENT '创建人', + `updated_by` varchar(64) DEFAULT 'system' COMMENT '更新人', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_key` (`config_key`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统配置表'; + +-- 初始化管理员数据 +INSERT IGNORE INTO `admin_role` (`id`, `name`, `code`, `description`) VALUES + (1, '超级管理员', 'ADMIN_SUPER', '拥有所有权限'), + (2, '内容管理员', 'ADMIN_CONTENT', '内容管理权限'), + (3, '用户管理员', 'ADMIN_USER', '用户管理权限'), + (4, '系统管理员', 'ADMIN_SYSTEM', '系统配置权限'); + +INSERT IGNORE INTO `admin_permission` (`id`, `name`, `code`, `description`) VALUES + (1, '用户管理', 'user:manage', '用户管理权限'), + (2, '角色管理', 'role:manage', '角色管理权限'), + (3, '权限管理', 'permission:manage', '权限管理权限'), + (4, '视频管理', 'video:manage', '视频管理权限'), + (5, '评论管理', 'comment:manage', '评论管理权限'), + (6, '标签管理', 'tag:manage', '标签管理权限'), + (7, '分类管理', 'category:manage', '分类管理权限'), + (8, '推荐管理', 'recommend:manage', '推荐管理权限'), + (9, '系统配置', 'system:config', '系统配置权限'), + (10, '操作日志', 'operation:log', '操作日志权限'); + +INSERT IGNORE INTO `admin_role_permission` (`role_id`, `permission_id`) VALUES + (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), + (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), + (3, 1), + (4, 9), (4, 10); + +-- 初始化超级管理员账号(密码:admin123) +INSERT IGNORE INTO `admin_user` (`id`, `username`, `password`, `salt`, `real_name`, `email`, `phone`, `status`) VALUES + (1, 'admin', '$2a$10$oRZ7x/.dW.6Q9z0QY1JZ5e9ZQ9z0QY1JZ5e9ZQ9z0QY1JZ5e9ZQ', 'abcdefg', '超级管理员', 'admin@nuaa.edu.cn', '13800138000', 1); + +INSERT IGNORE INTO `admin_user_role` (`admin_id`, `role_id`) VALUES + (1, 1); + +-- 初始化系统配置 +INSERT IGNORE INTO `admin_system_config` (`config_key`, `config_value`, `description`) VALUES + ('site_name', '南航在线视频平台', '网站名称'), + ('site_logo', '/static/logo.png', '网站Logo'), + ('site_favicon', '/static/favicon.ico', '网站图标'), + ('site_copyright', 'Copyright © 2024 南京航空航天大学', '版权信息'), + ('video_upload_limit', '1024', '视频上传大小限制(MB)'), + ('video_review_enabled', '1', '视频审核开关(0:关闭,1:开启)'), + ('comment_review_enabled', '0', '评论审核开关(0:关闭,1:开启)'), + ('user_register_enabled', '1', '用户注册开关(0:关闭,1:开启)'); \ No newline at end of file diff --git a/src/main/java/com/nuaa/video/App.java b/src/main/java/com/nuaa/video/App.java new file mode 100644 index 0000000..7e439bb --- /dev/null +++ b/src/main/java/com/nuaa/video/App.java @@ -0,0 +1,13 @@ +package com.nuaa.video; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/src/test/java/com/nuaa/video/AppTest.java b/src/test/java/com/nuaa/video/AppTest.java new file mode 100644 index 0000000..62ddb11 --- /dev/null +++ b/src/test/java/com/nuaa/video/AppTest.java @@ -0,0 +1,38 @@ +package com.nuaa.video; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/video-admin/pom.xml b/video-admin/pom.xml new file mode 100644 index 0000000..09aa006 --- /dev/null +++ b/video-admin/pom.xml @@ -0,0 +1,21 @@ + + + + video-platform + com.nuaa.video + 1.0.0 + + 4.0.0 + + video-admin + + + + com.nuaa.video + video-common + ${project.version} + + + \ No newline at end of file diff --git a/video-admin/src/main/java/com/nuaa/video/admin/AdminApplication.java b/video-admin/src/main/java/com/nuaa/video/admin/AdminApplication.java new file mode 100644 index 0000000..f8329fd --- /dev/null +++ b/video-admin/src/main/java/com/nuaa/video/admin/AdminApplication.java @@ -0,0 +1,13 @@ +package com.nuaa.video.admin; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@SpringBootApplication +@EnableDiscoveryClient +public class AdminApplication { + public static void main(String[] args) { + SpringApplication.run(AdminApplication.class, args); + } +} \ No newline at end of file diff --git a/video-admin/src/main/resources/application.yml b/video-admin/src/main/resources/application.yml new file mode 100644 index 0000000..70eb187 --- /dev/null +++ b/video-admin/src/main/resources/application.yml @@ -0,0 +1,33 @@ +server: + port: 9006 + +spring: + application: + name: video-admin + cloud: + nacos: + discovery: + server-addr: 127.0.0.1:8848 + namespace: public + group: DEFAULT_GROUP + sentinel: + transport: + dashboard: localhost:8080 + port: 8725 + eager: true + datasource: + url: jdbc:mysql://localhost:3306/video_admin?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai + username: root + password: root + driver-class-name: com.mysql.cj.jdbc.Driver + data: + redis: + host: localhost + port: 6379 + password: + database: 5 + +mybatis-plus: + mapper-locations: classpath:mapper/*.xml + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl \ No newline at end of file diff --git a/video-admin/src/test/java/com/nuaa/video/admin/AppTest.java b/video-admin/src/test/java/com/nuaa/video/admin/AppTest.java new file mode 100644 index 0000000..d2ea046 --- /dev/null +++ b/video-admin/src/test/java/com/nuaa/video/admin/AppTest.java @@ -0,0 +1,38 @@ +package com.nuaa.video.admin; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/video-auth/pom.xml b/video-auth/pom.xml new file mode 100644 index 0000000..55a08f4 --- /dev/null +++ b/video-auth/pom.xml @@ -0,0 +1,34 @@ + + + + video-platform + com.nuaa.video + 1.0.0 + + 4.0.0 + + video-auth + + + + com.nuaa.video + video-common + ${project.version} + + + + + org.springframework.boot + spring-boot-starter-oauth2-resource-server + + + + + org.springframework.security + spring-security-oauth2-authorization-server + 1.2.1 + + + \ No newline at end of file diff --git a/video-auth/src/main/java/com/nuaa/video/auth/AuthApplication.java b/video-auth/src/main/java/com/nuaa/video/auth/AuthApplication.java new file mode 100644 index 0000000..7ba42cd --- /dev/null +++ b/video-auth/src/main/java/com/nuaa/video/auth/AuthApplication.java @@ -0,0 +1,13 @@ +package com.nuaa.video.auth; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@SpringBootApplication +@EnableDiscoveryClient +public class AuthApplication { + public static void main(String[] args) { + SpringApplication.run(AuthApplication.class, args); + } +} \ No newline at end of file diff --git a/video-auth/src/main/resources/application.yml b/video-auth/src/main/resources/application.yml new file mode 100644 index 0000000..35302da --- /dev/null +++ b/video-auth/src/main/resources/application.yml @@ -0,0 +1,38 @@ +server: + port: 9001 + +spring: + application: + name: video-auth + cloud: + nacos: + discovery: + server-addr: 127.0.0.1:8848 + namespace: public + group: DEFAULT_GROUP + sentinel: + transport: + dashboard: localhost:8080 + port: 8720 + eager: true + datasource: + url: jdbc:mysql://localhost:3306/video_auth?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai + username: root + password: root + driver-class-name: com.mysql.cj.jdbc.Driver + data: + redis: + host: localhost + port: 6379 + password: + database: 0 + +mybatis-plus: + mapper-locations: classpath:mapper/*.xml + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + +jwt: + secret: video-platform-secret-key-2024-nuaa + expiration: 86400 + token-header: Authorization \ No newline at end of file diff --git a/video-auth/src/test/java/com/nuaa/video/auth/AppTest.java b/video-auth/src/test/java/com/nuaa/video/auth/AppTest.java new file mode 100644 index 0000000..e039fb5 --- /dev/null +++ b/video-auth/src/test/java/com/nuaa/video/auth/AppTest.java @@ -0,0 +1,38 @@ +package com.nuaa.video.auth; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/video-comment/pom.xml b/video-comment/pom.xml new file mode 100644 index 0000000..42f9011 --- /dev/null +++ b/video-comment/pom.xml @@ -0,0 +1,21 @@ + + + + video-platform + com.nuaa.video + 1.0.0 + + 4.0.0 + + video-comment + + + + com.nuaa.video + video-common + ${project.version} + + + \ No newline at end of file diff --git a/video-comment/src/main/java/com/nuaa/video/comment/CommentApplication.java b/video-comment/src/main/java/com/nuaa/video/comment/CommentApplication.java new file mode 100644 index 0000000..2757cf2 --- /dev/null +++ b/video-comment/src/main/java/com/nuaa/video/comment/CommentApplication.java @@ -0,0 +1,13 @@ +package com.nuaa.video.comment; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@SpringBootApplication +@EnableDiscoveryClient +public class CommentApplication { + public static void main(String[] args) { + SpringApplication.run(CommentApplication.class, args); + } +} \ No newline at end of file diff --git a/video-comment/src/main/resources/application.yml b/video-comment/src/main/resources/application.yml new file mode 100644 index 0000000..a5b9c9c --- /dev/null +++ b/video-comment/src/main/resources/application.yml @@ -0,0 +1,33 @@ +server: + port: 9004 + +spring: + application: + name: video-comment + cloud: + nacos: + discovery: + server-addr: 127.0.0.1:8848 + namespace: public + group: DEFAULT_GROUP + sentinel: + transport: + dashboard: localhost:8080 + port: 8723 + eager: true + datasource: + url: jdbc:mysql://localhost:3306/video_comment?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai + username: root + password: root + driver-class-name: com.mysql.cj.jdbc.Driver + data: + redis: + host: localhost + port: 6379 + password: + database: 3 + +mybatis-plus: + mapper-locations: classpath:mapper/*.xml + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl \ No newline at end of file diff --git a/video-comment/src/test/java/com/nuaa/video/comment/AppTest.java b/video-comment/src/test/java/com/nuaa/video/comment/AppTest.java new file mode 100644 index 0000000..fbad6e7 --- /dev/null +++ b/video-comment/src/test/java/com/nuaa/video/comment/AppTest.java @@ -0,0 +1,38 @@ +package com.nuaa.video.comment; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/video-common/pom.xml b/video-common/pom.xml new file mode 100644 index 0000000..0d167bc --- /dev/null +++ b/video-common/pom.xml @@ -0,0 +1,105 @@ + + + + video-platform + com.nuaa.video + 1.0.0 + + 4.0.0 + + video-common + + + + + org.projectlombok + lombok + true + + + + + org.springframework.boot + spring-boot-starter-web + + + + + org.springframework.boot + spring-boot-starter-validation + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + com.baomidou + mybatis-plus-boot-starter + 3.5.5 + + + + + mysql + mysql-connector-java + 8.0.33 + + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + + io.minio + minio + 8.5.7 + + + + + cn.hutool + hutool-all + 5.8.26 + + + + + io.jsonwebtoken + jjwt-api + 0.12.3 + + + io.jsonwebtoken + jjwt-impl + 0.12.3 + runtime + + + io.jsonwebtoken + jjwt-jackson + 0.12.3 + runtime + + + \ No newline at end of file diff --git a/video-common/src/main/java/com/nuaa/video/common/App.java b/video-common/src/main/java/com/nuaa/video/common/App.java new file mode 100644 index 0000000..e2d2187 --- /dev/null +++ b/video-common/src/main/java/com/nuaa/video/common/App.java @@ -0,0 +1,13 @@ +package com.nuaa.video.common; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/video-common/src/test/java/com/nuaa/video/common/AppTest.java b/video-common/src/test/java/com/nuaa/video/common/AppTest.java new file mode 100644 index 0000000..fea1339 --- /dev/null +++ b/video-common/src/test/java/com/nuaa/video/common/AppTest.java @@ -0,0 +1,38 @@ +package com.nuaa.video.common; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/video-content/pom.xml b/video-content/pom.xml new file mode 100644 index 0000000..0abb635 --- /dev/null +++ b/video-content/pom.xml @@ -0,0 +1,35 @@ + + + + video-platform + com.nuaa.video + 1.0.0 + + 4.0.0 + + video-content + + + + com.nuaa.video + video-common + ${project.version} + + + + + org.apache.rocketmq + rocketmq-spring-boot-starter + 2.2.3 + + + + + net.bramp.ffmpeg + ffmpeg + 0.7.0 + + + \ No newline at end of file diff --git a/video-content/src/main/java/com/nuaa/video/content/ContentApplication.java b/video-content/src/main/java/com/nuaa/video/content/ContentApplication.java new file mode 100644 index 0000000..413dbbb --- /dev/null +++ b/video-content/src/main/java/com/nuaa/video/content/ContentApplication.java @@ -0,0 +1,13 @@ +package com.nuaa.video.content; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@SpringBootApplication +@EnableDiscoveryClient +public class ContentApplication { + public static void main(String[] args) { + SpringApplication.run(ContentApplication.class, args); + } +} \ No newline at end of file diff --git a/video-content/src/main/resources/application.yml b/video-content/src/main/resources/application.yml new file mode 100644 index 0000000..3355b7d --- /dev/null +++ b/video-content/src/main/resources/application.yml @@ -0,0 +1,43 @@ +server: + port: 9003 + +spring: + application: + name: video-content + cloud: + nacos: + discovery: + server-addr: 127.0.0.1:8848 + namespace: public + group: DEFAULT_GROUP + sentinel: + transport: + dashboard: localhost:8080 + port: 8722 + eager: true + datasource: + url: jdbc:mysql://localhost:3306/video_content?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai + username: root + password: root + driver-class-name: com.mysql.cj.jdbc.Driver + rocketmq: + name-server: localhost:9876 + producer: + group: video-content-group + data: + redis: + host: localhost + port: 6379 + password: + database: 2 + +mybatis-plus: + mapper-locations: classpath:mapper/*.xml + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + +minio: + endpoint: http://localhost:9000 + accessKey: minioadmin + secretKey: minioadmin + bucketName: video-platform \ No newline at end of file diff --git a/video-content/src/test/java/com/nuaa/video/content/AppTest.java b/video-content/src/test/java/com/nuaa/video/content/AppTest.java new file mode 100644 index 0000000..2d6d0d9 --- /dev/null +++ b/video-content/src/test/java/com/nuaa/video/content/AppTest.java @@ -0,0 +1,38 @@ +package com.nuaa.video.content; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/video-gateway/pom.xml b/video-gateway/pom.xml new file mode 100644 index 0000000..58927f2 --- /dev/null +++ b/video-gateway/pom.xml @@ -0,0 +1,45 @@ + + + + video-platform + com.nuaa.video + 1.0.0 + + 4.0.0 + + video-gateway + + + + + org.springframework.cloud + spring-cloud-starter-gateway + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + com.alibaba.cloud + spring-cloud-alibaba-sentinel-gateway + + + + + org.springframework.boot + spring-boot-starter-actuator + + + \ No newline at end of file diff --git a/video-gateway/src/main/java/com/nuaa/video/gateway/GatewayApplication.java b/video-gateway/src/main/java/com/nuaa/video/gateway/GatewayApplication.java new file mode 100644 index 0000000..60d5174 --- /dev/null +++ b/video-gateway/src/main/java/com/nuaa/video/gateway/GatewayApplication.java @@ -0,0 +1,13 @@ +package com.nuaa.video.gateway; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@SpringBootApplication +@EnableDiscoveryClient +public class GatewayApplication { + public static void main(String[] args) { + SpringApplication.run(GatewayApplication.class, args); + } +} \ No newline at end of file diff --git a/video-gateway/src/main/resources/application.yml b/video-gateway/src/main/resources/application.yml new file mode 100644 index 0000000..98a4fc8 --- /dev/null +++ b/video-gateway/src/main/resources/application.yml @@ -0,0 +1,69 @@ +server: + port: 9000 + +spring: + application: + name: video-gateway + cloud: + nacos: + discovery: + server-addr: 127.0.0.1:8848 + namespace: public + group: DEFAULT_GROUP + gateway: + discovery: + locator: + enabled: true + lower-case-service-id: true + routes: + - id: video-auth + uri: lb://video-auth + predicates: + - Path=/auth/** + filters: + - StripPrefix=1 + - id: video-user + uri: lb://video-user + predicates: + - Path=/user/** + filters: + - StripPrefix=1 + - id: video-content + uri: lb://video-content + predicates: + - Path=/content/** + filters: + - StripPrefix=1 + - id: video-comment + uri: lb://video-comment + predicates: + - Path=/comment/** + filters: + - StripPrefix=1 + - id: video-recommend + uri: lb://video-recommend + predicates: + - Path=/recommend/** + filters: + - StripPrefix=1 + - id: video-admin + uri: lb://video-admin + predicates: + - Path=/admin/** + filters: + - StripPrefix=1 + sentinel: + transport: + dashboard: localhost:8080 + port: 8719 + eager: true + scg: + fallback: + mode: response + response-body: '{"code":500,"message":"服务不可用,请稍后再试"}' + +management: + endpoints: + web: + exposure: + include: '*' \ No newline at end of file diff --git a/video-gateway/src/test/java/com/nuaa/video/gateway/AppTest.java b/video-gateway/src/test/java/com/nuaa/video/gateway/AppTest.java new file mode 100644 index 0000000..988bad1 --- /dev/null +++ b/video-gateway/src/test/java/com/nuaa/video/gateway/AppTest.java @@ -0,0 +1,38 @@ +package com.nuaa.video.gateway; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/video-recommend/pom.xml b/video-recommend/pom.xml new file mode 100644 index 0000000..3e8e77f --- /dev/null +++ b/video-recommend/pom.xml @@ -0,0 +1,35 @@ + + + + video-platform + com.nuaa.video + 1.0.0 + + 4.0.0 + + video-recommend + + + + com.nuaa.video + video-common + ${project.version} + + + + + org.apache.spark + spark-mllib_2.12 + 3.4.1 + + + + + org.apache.commons + commons-math3 + 3.6.1 + + + \ No newline at end of file diff --git a/video-recommend/src/main/java/com/nuaa/video/recommend/RecommendApplication.java b/video-recommend/src/main/java/com/nuaa/video/recommend/RecommendApplication.java new file mode 100644 index 0000000..0e12137 --- /dev/null +++ b/video-recommend/src/main/java/com/nuaa/video/recommend/RecommendApplication.java @@ -0,0 +1,13 @@ +package com.nuaa.video.recommend; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@SpringBootApplication +@EnableDiscoveryClient +public class RecommendApplication { + public static void main(String[] args) { + SpringApplication.run(RecommendApplication.class, args); + } +} \ No newline at end of file diff --git a/video-recommend/src/main/resources/application.yml b/video-recommend/src/main/resources/application.yml new file mode 100644 index 0000000..08c6e1f --- /dev/null +++ b/video-recommend/src/main/resources/application.yml @@ -0,0 +1,33 @@ +server: + port: 9005 + +spring: + application: + name: video-recommend + cloud: + nacos: + discovery: + server-addr: 127.0.0.1:8848 + namespace: public + group: DEFAULT_GROUP + sentinel: + transport: + dashboard: localhost:8080 + port: 8724 + eager: true + datasource: + url: jdbc:mysql://localhost:3306/video_recommend?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai + username: root + password: root + driver-class-name: com.mysql.cj.jdbc.Driver + data: + redis: + host: localhost + port: 6379 + password: + database: 4 + +mybatis-plus: + mapper-locations: classpath:mapper/*.xml + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl \ No newline at end of file diff --git a/video-recommend/src/test/java/com/nuaa/video/recommend/AppTest.java b/video-recommend/src/test/java/com/nuaa/video/recommend/AppTest.java new file mode 100644 index 0000000..c09c586 --- /dev/null +++ b/video-recommend/src/test/java/com/nuaa/video/recommend/AppTest.java @@ -0,0 +1,38 @@ +package com.nuaa.video.recommend; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/video-user/pom.xml b/video-user/pom.xml new file mode 100644 index 0000000..597d276 --- /dev/null +++ b/video-user/pom.xml @@ -0,0 +1,21 @@ + + + + video-platform + com.nuaa.video + 1.0.0 + + 4.0.0 + + video-user + + + + com.nuaa.video + video-common + ${project.version} + + + \ No newline at end of file diff --git a/video-user/src/main/java/com/nuaa/video/user/UserApplication.java b/video-user/src/main/java/com/nuaa/video/user/UserApplication.java new file mode 100644 index 0000000..88ada19 --- /dev/null +++ b/video-user/src/main/java/com/nuaa/video/user/UserApplication.java @@ -0,0 +1,13 @@ +package com.nuaa.video.user; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@SpringBootApplication +@EnableDiscoveryClient +public class UserApplication { + public static void main(String[] args) { + SpringApplication.run(UserApplication.class, args); + } +} \ No newline at end of file diff --git a/video-user/src/main/resources/application.yml b/video-user/src/main/resources/application.yml new file mode 100644 index 0000000..f228486 --- /dev/null +++ b/video-user/src/main/resources/application.yml @@ -0,0 +1,33 @@ +server: + port: 9002 + +spring: + application: + name: video-user + cloud: + nacos: + discovery: + server-addr: 127.0.0.1:8848 + namespace: public + group: DEFAULT_GROUP + sentinel: + transport: + dashboard: localhost:8080 + port: 8721 + eager: true + datasource: + url: jdbc:mysql://localhost:3306/video_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai + username: root + password: root + driver-class-name: com.mysql.cj.jdbc.Driver + data: + redis: + host: localhost + port: 6379 + password: + database: 1 + +mybatis-plus: + mapper-locations: classpath:mapper/*.xml + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl \ No newline at end of file diff --git a/video-user/src/test/java/com/nuaa/video/user/AppTest.java b/video-user/src/test/java/com/nuaa/video/user/AppTest.java new file mode 100644 index 0000000..fb4ca58 --- /dev/null +++ b/video-user/src/test/java/com/nuaa/video/user/AppTest.java @@ -0,0 +1,38 @@ +package com.nuaa.video.user; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +}