chore(init): Scaffold video platform microservices

This commit is contained in:
2025-03-27 01:22:56 +08:00
parent 23643dc383
commit 4c1a035a1e
47 changed files with 2081 additions and 0 deletions
@@ -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":""
}
+38
View File
@@ -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
+10
View File
@@ -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/
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ApifoxUploaderProjectSetting">
<option name="apiAccessToken" value="APS-8W5ece3ancukaCFg7XU25oGRku4hR3r5" />
</component>
</project>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CheckStyle-IDEA" serialisationVersion="2">
<checkstyleVersion>10.21.3</checkstyleVersion>
<scanScope>JavaOnly</scanScope>
<copyLibs>true</copyLibs>
<option name="thirdPartyClasspath" />
<option name="activeLocationIds" />
<option name="locations">
<list>
<ConfigurationLocation id="bundled-sun-checks" type="BUNDLED" scope="All" description="Sun Checks">(bundled)</ConfigurationLocation>
<ConfigurationLocation id="bundled-google-checks" type="BUNDLED" scope="All" description="Google Checks">(bundled)</ConfigurationLocation>
</list>
</option>
</component>
</project>
+7
View File
@@ -0,0 +1,7 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<ScalaCodeStyleSettings>
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
</ScalaCodeStyleSettings>
</code_scheme>
</component>
+5
View File
@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/video-admin/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/video-auth/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/video-comment/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/video-common/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/video-content/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/video-gateway/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/video-recommend/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/video-user/src/main/java" charset="UTF-8" />
</component>
</project>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="fastRequestCurrentProjectLocalConfig">
<option name="initFlag" value="1" />
</component>
</project>
+5
View File
@@ -0,0 +1,5 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
</profile>
</component>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
Generated
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
+79
View File
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.4</version>
<relativePath/>
</parent>
<groupId>com.nuaa.video</groupId>
<artifactId>video-platform</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>video-platform</name>
<description>基于Spring Cloud的高可用在线视频平台</description>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-cloud.version>2023.0.1</spring-cloud.version>
<spring-cloud-alibaba.version>2023.0.1.0</spring-cloud-alibaba.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- Spring Cloud -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Spring Cloud Alibaba -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${spring-cloud-alibaba.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<modules>
<module>video-common</module>
<module>video-gateway</module>
<module>video-auth</module>
<module>video-user</module>
<module>video-content</module>
<module>video-comment</module>
<module>video-recommend</module>
<module>video-admin</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
+783
View File
@@ -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:开启)');
+13
View File
@@ -0,0 +1,13 @@
package com.nuaa.video;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
+38
View File
@@ -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 );
}
}
+21
View File
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>video-platform</artifactId>
<groupId>com.nuaa.video</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>video-admin</artifactId>
<dependencies>
<dependency>
<groupId>com.nuaa.video</groupId>
<artifactId>video-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
@@ -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);
}
}
@@ -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
@@ -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 );
}
}
+34
View File
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>video-platform</artifactId>
<groupId>com.nuaa.video</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>video-auth</artifactId>
<dependencies>
<dependency>
<groupId>com.nuaa.video</groupId>
<artifactId>video-common</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Spring Security OAuth2 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>
<!-- Spring Security OAuth2 Authorization Server -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-authorization-server</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
</project>
@@ -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);
}
}
@@ -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
@@ -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 );
}
}
+21
View File
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>video-platform</artifactId>
<groupId>com.nuaa.video</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>video-comment</artifactId>
<dependencies>
<dependency>
<groupId>com.nuaa.video</groupId>
<artifactId>video-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
@@ -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);
}
}
@@ -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
@@ -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 );
}
}
+105
View File
@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>video-platform</artifactId>
<groupId>com.nuaa.video</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>video-common</artifactId>
<dependencies>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- Spring Boot Starter Web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Spring Boot Starter Validation -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- Spring Cloud Alibaba Nacos Discovery -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- Spring Cloud OpenFeign -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- Spring Cloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- MyBatis Plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.5</version>
</dependency>
<!-- MySQL Connector -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
</dependency>
<!-- Redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- MinIO -->
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.5.7</version>
</dependency>
<!-- Hutool工具包 -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.26</version>
</dependency>
<!-- JWT -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.12.3</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.12.3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.12.3</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
@@ -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!" );
}
}
@@ -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 );
}
}
+35
View File
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>video-platform</artifactId>
<groupId>com.nuaa.video</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>video-content</artifactId>
<dependencies>
<dependency>
<groupId>com.nuaa.video</groupId>
<artifactId>video-common</artifactId>
<version>${project.version}</version>
</dependency>
<!-- RocketMQ -->
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-spring-boot-starter</artifactId>
<version>2.2.3</version>
</dependency>
<!-- FFmpeg -->
<dependency>
<groupId>net.bramp.ffmpeg</groupId>
<artifactId>ffmpeg</artifactId>
<version>0.7.0</version>
</dependency>
</dependencies>
</project>
@@ -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);
}
}
@@ -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
@@ -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 );
}
}
+45
View File
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>video-platform</artifactId>
<groupId>com.nuaa.video</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>video-gateway</artifactId>
<dependencies>
<!-- Spring Cloud Gateway -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<!-- Spring Cloud Alibaba Nacos Discovery -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- Spring Cloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- Sentinel Gateway适配 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
</dependency>
<!-- Spring Boot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
</project>
@@ -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);
}
}
@@ -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: '*'
@@ -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 );
}
}
+35
View File
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>video-platform</artifactId>
<groupId>com.nuaa.video</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>video-recommend</artifactId>
<dependencies>
<dependency>
<groupId>com.nuaa.video</groupId>
<artifactId>video-common</artifactId>
<version>${project.version}</version>
</dependency>
<!-- 机器学习相关 -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-mllib_2.12</artifactId>
<version>3.4.1</version>
</dependency>
<!-- 数据计算 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
</dependencies>
</project>
@@ -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);
}
}
@@ -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
@@ -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 );
}
}
+21
View File
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>video-platform</artifactId>
<groupId>com.nuaa.video</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>video-user</artifactId>
<dependencies>
<dependency>
<groupId>com.nuaa.video</groupId>
<artifactId>video-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
@@ -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);
}
}
@@ -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
@@ -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 );
}
}