概括
本篇文章主要是构建了发布视频所需要的四张表的sql,以及对应的预上传部分的代码,仅供参考,参考视频在13集
数据库文件
视频信息表:video_info
sql
-- easylive.video_info definition
CREATE TABLE `video_info` (
`video_id` varchar(10) NOT NULL DEFAULT '0' COMMENT '视频ID',
`video_cover` varchar(50) NOT NULL COMMENT '视频封面',
`video_name` varchar(100) NOT NULL COMMENT '视频名称',
`user_id` varchar(10) NOT NULL COMMENT '用户id',
`create_time` datetime NOT NULL COMMENT '创建时间',
`last_update_time` datetime NOT NULL COMMENT '最后更新时间',
`p_category_id` int(11) NOT NULL COMMENT '父级分类id',
`category_id` int(11) DEFAULT NULL COMMENT '分类id',
`status` tinyint(1) NOT NULL COMMENT '0:转码中 1:转码失败 2:待审核 3:审核成功 4:审核失败',
`post_type` tinyint(4) NOT NULL COMMENT '0:自制 1:转载',
`origin_info` varchar(200) DEFAULT NULL COMMENT '源资源说明',
`tags` varchar(300) DEFAULT NULL COMMENT '标签',
`introduction` varchar(2000) DEFAULT NULL COMMENT '简介',
`interaction` varchar(5) DEFAULT NULL COMMENT '互动设置',
`duration` int(11) DEFAULT '0' COMMENT '持续时间(秒)',
`play_count` int(11) DEFAULT '0' COMMENT '播放数量',
`like_count` int(11) DEFAULT '0' COMMENT '点赞数量',
`danmu_count` int(11) DEFAULT '0' COMMENT '弹幕数量',
`comment_count` int(11) DEFAULT '0' COMMENT '评论数量',
`coin_count` int(11) DEFAULT '0' COMMENT '投币数量',
`collect_count` int(11) DEFAULT '0' COMMENT '收藏数量',
`recommend_type` int(11) DEFAULT '0' COMMENT '是否推荐 0:未推荐 1:已推荐',
`last_play_time` datetime DEFAULT NULL COMMENT '最后播放时间',
PRIMARY KEY (`video_id`) USING BTREE,
KEY `idx_key_create_time` (`create_time`) USING BTREE,
KEY `idx_key_user_id` (`user_id`) USING BTREE,
KEY `idx_key_category_id` (`category_id`) USING BTREE,
KEY `idx_key_pcategory_id` (`p_category_id`) USING BTREE,
KEY `idx_key_recommend_type` (`recommend_type`) USING BTREE,
KEY `idx_key_last_play_time` (`last_play_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='视频信息';
video_info_file :视频文件信息
sql
-- easylive.video_info_file definition
CREATE TABLE `video_info_file` (
`file_id` varchar(20) NOT NULL COMMENT '唯一ID',
`video_id` varchar(10) NOT NULL COMMENT '视频ID',
`user_id` varchar(10) NOT NULL COMMENT '用户ID',
`file_index` int(11) NOT NULL COMMENT '文件索引',
`file_name` varchar(200) DEFAULT NULL COMMENT '文件名',
`file_size` bigint(20) DEFAULT NULL COMMENT '文件大小',
`file_path` varchar(100) DEFAULT NULL COMMENT '文件路径',
`duration` int(11) DEFAULT NULL COMMENT '持续时间(秒)',
PRIMARY KEY (`file_id`) USING BTREE,
KEY `idx_key_video_id` (`video_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='视频文件信息';
video_info_file_post:视频文件信息
sql
-- easylive.video_info_file_post definition
CREATE TABLE `video_info_file_post` (
`file_id` varchar(20) NOT NULL COMMENT '唯一ID',
`upload_id` varchar(15) NOT NULL COMMENT '上传Id',
`video_id` varchar(10) NOT NULL COMMENT '视频ID',
`user_id` varchar(10) NOT NULL COMMENT '用户ID',
`file_index` int(11) NOT NULL COMMENT '文件索引',
`file_name` varchar(200) DEFAULT NULL COMMENT '文件名',
`file_size` bigint(20) DEFAULT NULL COMMENT '文件大小',
`file_path` varchar(100) DEFAULT NULL COMMENT '文件路径',
`upate_type` tinyint(4) DEFAULT NULL COMMENT '0:无更新 1:有更新',
`transfer_result` tinyint(4) DEFAULT NULL COMMENT '0:转码中 1:转码成功 2:转码失败',
`duration` int(11) DEFAULT NULL COMMENT '持续时间(秒)',
PRIMARY KEY (`file_id`) USING BTREE,
UNIQUE KEY `idx_key_upload_id` (`upload_id`,`user_id`) USING BTREE,
KEY `idx_key_video_id` (`video_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='视频文件信息';
video_info_post:视频信息
sql
-- easylive.video_info_post definition
CREATE TABLE `video_info_post` (
`video_id` varchar(10) NOT NULL DEFAULT '0' COMMENT '视频ID',
`video_cover` varchar(50) NOT NULL COMMENT '视频封面',
`video_name` varchar(100) NOT NULL COMMENT '视频名称',
`user_id` varchar(10) NOT NULL COMMENT '用户id',
`create_time` datetime NOT NULL COMMENT '创建时间',
`last_update_time` datetime NOT NULL COMMENT '最后更新时间',
`p_category_id` int(11) NOT NULL COMMENT '父级分类id',
`category_id` int(11) DEFAULT NULL COMMENT '分类id',
`status` tinyint(1) NOT NULL COMMENT '0:转码中 1:转码失败 2:待审核 3:审核成功 4:审核失败',
`post_type` tinyint(4) NOT NULL COMMENT '0:自制 1:转载',
`origin_info` varchar(200) DEFAULT NULL COMMENT '源资源说明',
`tags` varchar(300) DEFAULT NULL COMMENT '标签',
`introduction` varchar(2000) DEFAULT NULL COMMENT '简介',
`interaction` varchar(5) DEFAULT NULL COMMENT '互动设置',
`duration` int(11) DEFAULT NULL COMMENT '持续时间(秒)',
PRIMARY KEY (`video_id`) USING BTREE,
KEY `idx_key_create_time` (`create_time`) USING BTREE,
KEY `idx_key_user_id` (`user_id`) USING BTREE,
KEY `idx_key_category_id` (`category_id`) USING BTREE,
KEY `idx_key_pcategory_id` (`p_category_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='视频信息';
部分后端代码
通过代码生器生成部分代码后,需要将部分代码移动到指定的项目文件夹后。下面给出一些部分工具类和公共方法代码,来帮助你更快的去完善项目。最好还是自己能够手动编写,来熟悉。
新增SysSettingDto
类,该类主要是用来提供校验配置的一些数据量,之后会转移到配置文件中
java
package com.easylive.entity.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.springframework.stereotype.Component;
import java.io.Serializable;
@JsonIgnoreProperties(ignoreUnknown = true)
public class SysSettingDto implements Serializable {
private static final long serialVersionUID = 1L;
private Integer registerCoinCount = 10;
private Integer postVideoCoinCount = 10;
private Integer videoSize = 5;
private Integer videoPCount = 10;
private Integer videoCount = 10;
private Integer commentCount = 20;
private Integer danmuCount = 20;
public Integer getRegisterCoinCount() {
return registerCoinCount;
}
public void setRegisterCoinCount(Integer registerCoinCount) {
this.registerCoinCount = registerCoinCount;
}
public Integer getPostVideoCoinCount() {
return postVideoCoinCount;
}
public void setPostVideoCoinCount(Integer postVideoCoinCount) {
this.postVideoCoinCount = postVideoCoinCount;
}
public Integer getVideoSize() {
return videoSize;
}
public void setVideoSize(Integer videoSize) {
this.videoSize = videoSize;
}
public Integer getVideoPCount() {
return videoPCount;
}
public void setVideoPCount(Integer videoPCount) {
this.videoPCount = videoPCount;
}
public Integer getVideoCount() {
return videoCount;
}
public void setVideoCount(Integer videoCount) {
this.videoCount = videoCount;
}
public Integer getCommentCount() {
return commentCount;
}
public void setCommentCount(Integer commentCount) {
this.commentCount = commentCount;
}
public Integer getDanmuCount() {
return danmuCount;
}
public void setDanmuCount(Integer danmuCount) {
this.danmuCount = danmuCount;
}
}
新增UploadingFileDto
类,该类主要是用来提供文件上传的部分数据
java
package com.easylive.entity.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.io.Serializable;
@JsonIgnoreProperties(ignoreUnknown = true)
public class UploadingFileDto implements Serializable {
private static final long serialVersionUID = 1L;
private String fileName;
private String uploadId;
private Integer chunkIndex;
private Integer chunks;
private Long fileSize = 0L;
private String filePath;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getUploadId() {
return uploadId;
}
public void setUploadId(String uploadId) {
this.uploadId = uploadId;
}
public Integer getChunkIndex() {
return chunkIndex;
}
public void setChunkIndex(Integer chunkIndex) {
this.chunkIndex = chunkIndex;
}
public Integer getChunks() {
return chunks;
}
public void setChunks(Integer chunks) {
this.chunks = chunks;
}
public Long getFileSize() {
return fileSize;
}
public void setFileSize(Long fileSize) {
this.fileSize = fileSize;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
@Override
public String toString() {
return "UploadingFileDto{" +
"fileName='" + fileName + '\'' +
", uploadId='" + uploadId + '\'' +
", chunkIndex=" + chunkIndex +
", chunks=" + chunks +
", fileSize=" + fileSize +
", filePath='" + filePath + '\'' +
'}';
}
}