Video教程的Domain设计
Domain设计
下面将介绍Video的表设计,和模型定义。
表设计
Videos
设计
/// <summary>
/// 视频聚合
/// </summary>
public class Video : FullAggregateRoot<long, long>
{
/// <summary>
/// 视频标题
/// </summary>
public string title;
/// <summary>
/// 视频描述
/// </summary>
public string description;
/// <summary>
/// 视频地址
/// </summary>
public string url;
/// <summary>
/// 视频总长度(秒)
/// </summary>
public int duration;
/// <summary>
/// 浏览量
/// </summary>
public int views;
/// <summary>
/// 视频标签
/// </summary>
public List<string> tags;
/// <summary>
/// 视频封面图片地址
/// </summary>
public string thumbnailUrl;
/// <summary>
/// 视频播放次数
/// </summary>
public long playCount;
/// <summary>
/// 视频点赞数
/// </summary>
public long likes;
/// <summary>
/// 视频踩数
/// </summary>
public long dislikes;
/// <summary>
/// 视频评论数
/// </summary>
public long commentsCount;
/// <summary>
/// 视频标题
/// </summary>
public string Title { get => title; set => title = value; }
/// <summary>
/// 视频描述
/// </summary>
public string Description { get => description; set => description = value; }
/// <summary>
/// 视频地址
/// </summary>
public string Url { get => url; set => url = value; }
/// <summary>
/// 视频总长度(秒)
/// </summary>
public int Duration { get => duration; private set => duration = value; }
/// <summary>
/// 浏览量
/// </summary>
public int Views { get => views; private set => views = value; }
/// <summary>
/// 视频标签
/// </summary>
public List<string> Tags { get => tags; set => tags = value; }
/// <summary>
/// 视频封面图片地址
/// </summary>
public string ThumbnailUrl { get => thumbnailUrl; set => thumbnailUrl = value; }
/// <summary>
/// 视频播放次数
/// </summary>
public long PlayCount { get => playCount; private set => playCount = value; }
/// <summary>
/// 视频点赞数
/// </summary>
public long Likes { get => likes; private set => likes = value; }
/// <summary>
/// 视频踩数
/// </summary>
public long Dislikes { get => dislikes; private set => dislikes = value; }
/// <summary>
/// 视频评论数
/// </summary>
public long CommentsCount { get => commentsCount; private set => commentsCount = value; }
protected Video()
{
}
public Video(long id) : base(id)
{
}
/// <summary>
/// 修改视频总长度
/// </summary>
/// <param name="duration"></param>
public void SetDuration(int duration)
{
Duration = duration;
}
}
Users
设计
/// <summary>
/// 用户表
/// </summary>
public class VideoUsers : FullAggregateRoot<long, long>
{
/// <summary>
/// 用户名
/// </summary>
private string username;
/// <summary>
/// 用户密码
/// </summary>
private string password;
/// <summary>
/// 用户邮箱
/// </summary>
private string email;
/// <summary>
/// 用户头像
/// </summary>
private string avatar;
/// <summary>
/// 用户描述
/// </summary>
private string description;
/// <summary>
/// 用户名
/// </summary>
public string Username { get => username; private set => username = value; }
/// <summary>
/// 用户密码
/// </summary>
public string Password { get => password; private set => password = value; }
/// <summary>
/// 用户邮箱
/// </summary>
public string Email { get => email; private set => email = value; }
/// <summary>
/// 用户头像
/// </summary>
public string Avatar { get => avatar; set => avatar = value; }
/// <summary>
/// 用户描述
/// </summary>
public string Description { get => description; set => description = value; }
protected VideoUsers()
{
}
public VideoUsers(string username, string password, string email, string avatar, string description)
{
SetUserName(username);
UpdateEmail(email);
UpdatePassword(password);
Avatar = avatar;
Description = description;
}
/// <summary>
/// 修改用户名
/// </summary>
/// <param name="username"></param>
/// <exception cref="UserFriendlyException"></exception>
public void SetUserName(string username)
{
// 判断用户名是否符合要求
if (username.IsNullOrWhiteSpace())
{
throw new UserFriendlyException("用户名不能为空");
}
if (username.Length < 5)
{
throw new UserFriendlyException("用户名长度不能小于5位");
}
Username = username;
}
/// <summary>
/// 修改密码
/// </summary>
/// <param name="password"></param>
/// <exception cref="UserFriendlyException"></exception>
public void UpdatePassword(string password)
{
// 判断密码是否符合要求
if (password.IsNullOrWhiteSpace())
{
throw new UserFriendlyException("密码不能为空");
}
if (!IsComplexPassword(password))
{
throw new UserFriendlyException("密码过于简单");
}
Password = password;
}
/// <summary>
/// 修改邮箱
/// </summary>
/// <param name="email"></param>
/// <exception cref="UserFriendlyException"></exception>
public void UpdateEmail(string email)
{
if (email.IsNullOrWhiteSpace())
{
throw new UserFriendlyException("邮箱不能为空");
}
if (!IsValidEmail(email))
{
throw new UserFriendlyException("邮箱校验失败");
}
Email = email;
}
public static bool IsValidEmail(string email)
{
// 正则表达式模式
string pattern = @"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$";
// 使用正则表达式进行匹配
Match match = Regex.Match(email, pattern);
// 如果匹配成功,则为有效邮箱
return match.Success;
}
public static bool IsComplexPassword(string password)
{
bool hasUpperCase = password.Any(char.IsUpper);
bool hasLowerCase = password.Any(char.IsLower);
bool hasDigit = password.Any(char.IsDigit);
bool hasSpecialChar = password.Any(ch => !char.IsLetterOrDigit(ch));
return password.Length >= 8 && hasUpperCase && hasLowerCase && hasDigit && hasSpecialChar;
}
}
Roles
设计
public class Roles : FullAggregateRoot<int, long>
{
/// <summary>
/// 角色排序
/// </summary>
public int sort;
/// <summary>
/// 角色名称
/// </summary>
public string name;
/// <summary>
/// 角色描述
/// </summary>
public string description;
/// <summary>
/// 默认角色不允许删除
/// </summary>
public bool isDefault;
/// <summary>
/// 是否正常使用的
/// </summary>
public bool isActive;
/// <summary>
/// 角色排序
/// </summary>
public int Sort { get => sort; set => sort = value; }
/// <summary>
/// 角色名称
/// </summary>
public string Name { get => name; set => name = value; }
/// <summary>
/// 角色描述
/// </summary>
public string Description { get => description; set => description = value; }
/// <summary>
/// 默认角色不允许删除
/// </summary>
public bool IsDefault { get => isDefault; private set => isDefault = value; }
/// <summary>
/// 是否正常使用的
/// </summary>
public bool IsActive { get => isActive; private set => isActive = value; }
public Roles()
{
}
public Roles(int sort, string name, string description, bool isDefault)
{
UpdateName(name);
Sort = sort;
Description = description;
IsDefault = isDefault;
IsActive = true;
}
public void UpdateName(string name)
{
if (name.IsNullOrWhiteSpace())
{
throw new UserFriendlyException("角色名称不能为空");
}
Name = name;
}
}
RoleUsers
设计
public class RoleUsers : Entity<long>
{
/// <summary>
/// 用户id
/// </summary>
public long UserId { get; set; }
/// <summary>
/// 角色id
/// </summary>
public long RoleId { get; set; }
}
VideoComments
设计
public class VideoComments : Entity<long>, IAuditEntity<long>
{
public long videoId;
public string comment;
public long? parentId;
/// <summary>
/// 视频Id
/// </summary>
public long VideoId { get => videoId; private set => videoId = value; }
/// <summary>
/// 评论内容
/// </summary>
public string Comment { get => comment; private set => comment = value; }
/// <summary>
/// 父级id如果为空则是顶层
/// </summary>
public long? ParentId { get => parentId; private set => parentId = value; }
public long Creator { get; private set; }
public DateTime CreationTime { get; private set; }
public long Modifier { get; private set; }
public DateTime ModificationTime { get; private set; }
protected VideoComments()
{
}
public VideoComments(long videoId, string comment, long? parentId)
{
UpdateVideoId(videoId);
UpdateComment(comment);
VideoId = videoId;
ParentId = parentId;
}
public void UpdateVideoId(long videoId)
{
if (videoId == null)
{
throw new UserFriendlyException("您的视频id为空!");
}
VideoId = videoId;
}
public void UpdateComment(string comment)
{
if (comment.IsNullOrWhiteSpace())
{
throw new UserFriendlyException("您的评论为空");
}
Comment = comment;
}
}
VideoLikes
设计
public class VideoLikes{
public long Id { get; set; }
/// <summary>
/// 视频id
/// </summary>
public long VideoId { get; set; }
/// <summary>
/// 点赞用户id
/// </summary>
public long UserId { get; set; }
}
VideoCategories
设计
public class VideoCategories : Entity<int>
{
public string name;
public string description;
/// <summary>
/// 分类名称
/// </summary>
public string Name { get => name; private set => name = value; }
/// <summary>
/// 分类描述
/// </summary>
public string Description { get => description; private set => description = value; }
protected VideoCategories()
{
}
public VideoCategories(string name, string description)
{
UpdateName(name);
UpdateDescription(description);
}
public void UpdateName(string name)
{
if (name.IsNullOrWhiteSpace())
{
throw new UserFriendlyException("分类名称不能为空");
}
Name = name;
}
public void UpdateDescription(string description)
{
if (description.IsNullOrWhiteSpace())
{
throw new UserFriendlyException("分类描述不能为空");
}
Description = description;
}
}
VideoTags
设计
public class VideoTags : Entity<int>
{
public string name;
public string description;
/// <summary>
/// 标签名称
/// </summary>
public string Name { get => name; private set => name = value; }
/// <summary>
/// 标签描述
/// </summary>
public string Description { get => description; private set => description = value; }
protected VideoTags()
{
}
public VideoTags(string name, string description)
{
UpdateName(name);
UpdateDescription(description);
}
public void UpdateName(string name)
{
if (name.IsNullOrWhiteSpace())
{
throw new UserFriendlyException("分类名称不能为空");
}
Name = name;
}
public void UpdateDescription(string description)
{
if (description.IsNullOrWhiteSpace())
{
throw new UserFriendlyException("分类描述不能为空");
}
Description = description;
}
}
UserFollows
设计
public class UserFollows : Entity<long>
{
/// <summary>
/// 关注者id
/// </summary>
public long FollowerId { get; set; }
/// <summary>
/// 被关注者id
/// </summary>
public long FollowedId { get; set; }
}
VideoPlayRecords
设计
public class VideoPlayRecords : Entity<long>, IAuditEntity<long>
{
private long videoId;
private DateTime playTime;
/// <summary>
/// 视频id
/// </summary>
public long VideoId { get => videoId; private set => videoId = value; }
/// <summary>
/// 播放时间
/// </summary>
public DateTime PlayTime { get => playTime; private set => playTime = value; }
public long Creator { get; private set; }
public DateTime CreationTime { get; private set; }
public long Modifier { get; private set; }
public DateTime ModificationTime { get; private set; }
public VideoPlayRecords()
{
}
public VideoPlayRecords(long videoId, DateTime playTime)
{
VideoId = videoId;
PlayTime = playTime;
}
}
FileStorage
设计
public class FileStorage : FullAggregateRoot<long, long>
{
/// <summary>
/// 文件名
/// </summary>
public string name;
/// <summary>
/// 文件路径
/// </summary>
public string path;
public long size;
public FileType type;
/// <summary>
/// 文件名
/// </summary>
public string Name { get => name; set => name = value; }
/// <summary>
/// 文件路径
/// </summary>
public string Path { get => path; set => path = value; }
/// <summary>
/// 文件大小
/// </summary>
public long Size { get => size; set => size = value; }
/// <summary>
/// 文件类型
/// </summary>
public FileType Type { get => type; private set => type = value; }
protected FileStorage()
{
}
public FileStorage(string name, string path, long size, FileType type)
{
UpdateName(name);
UpdatePath(path);
Size = size;
Type = type;
}
public void UpdateName(string name)
{
if (name.IsNullOrWhiteSpace())
{
throw new UserFriendlyException("文件名称不能为空");
}
Name = name;
}
public void UpdatePath(string path)
{
if (path.IsNullOrWhiteSpace())
{
throw new UserFriendlyException("文件地址不能为空");
}
Path = path;
}
}
// 文件类别
public enum FileType
{
/// <summary>
/// 文件
/// </summary>
File,
/// <summary>
/// 图片
/// </summary>
Image,
/// <summary>
/// 视频
/// </summary>
Video,
/// <summary>
/// 音频
/// </summary>
Audio
}
Auditlog
设计
/// <summary>
/// 审计模型
/// </summary>
public class Auditlog : FullAggregateRoot<long, long>
{
/// <summary>
/// 请求路由
/// </summary>
private string requestRoute;
/// <summary>
/// 请求路由
/// </summary>
public string RequestRoute
{
get { return requestRoute; }
private set { requestRoute = value; }
}
/// <summary>
/// 请求Query参数
/// </summary>
private string requestQuery;
/// <summary>
///请求Query参数
/// </summary>
public string RequestQuery
{
get { return requestQuery; }
private set { requestQuery = value; }
}
/// <summary>
/// 请求方式
/// </summary>
private string requestMethod;
/// <summary>
/// 请求方式
/// </summary>
public string RequestMethod
{
get { return requestMethod; }
private set { requestMethod = value; }
}
/// <summary>
/// 请求客户端标识
/// </summary>
private string clientIdentifier;
/// <summary>
/// 请求客户端标识
/// </summary>
public string ClientIdentifier
{
get { return clientIdentifier; }
private set { clientIdentifier = value; }
}
/// <summary>
/// 响应状态
/// </summary>
private int responseStatus;
/// <summary>
/// 响应状态
/// </summary>
public int ResponseStatus
{
get { return responseStatus; }
private set { responseStatus = value; }
}
/// <summary>
/// 请求ip
/// </summary>
private string requestIp;
/// <summary>
/// 请求ip
/// </summary>
public string RequestIp
{
get { return requestIp; }
private set { requestIp = value; }
}
/// <summary>
/// 扩展参数
/// </summary>
private Dictionary<string, string> extendedParameters;
/// <summary>
/// 扩展参数
/// </summary>
public Dictionary<string, string> ExtendedParameters
{
get { return extendedParameters; }
private set { extendedParameters = value; }
}
/// <summary>
/// 请求耗时(ms)
/// </summary>
private int requestDuration;
/// <summary>
/// 请求耗时(ms)
/// </summary>
public int RequestDuration
{
get => requestDuration;
private set => requestDuration = value;
}
/// <summary>
/// 应用环境
/// </summary>
private string applicationEnvironment;
/// <summary>
/// 应用环境
/// </summary>
public string ApplicationEnvironment
{
get => applicationEnvironment;
private set => applicationEnvironment = value;
}
protected Auditlog()
{
}
public Auditlog(string requestRoute, string requestQuery, string requestMethod, string clientIdentifier, int responseStatus, string requestIp, Dictionary<string, string> extendedParameters, int requestDuration, string applicationEnvironment)
{
RequestRoute = requestRoute;
RequestQuery = requestQuery;
RequestMethod = requestMethod;
ClientIdentifier = clientIdentifier;
ResponseStatus = responseStatus;
RequestIp = requestIp;
ExtendedParameters = extendedParameters;
RequestDuration = requestDuration;
ApplicationEnvironment = applicationEnvironment;
}
}
SettingManager
设计
public class SettingManager : Entity<long>
{
private string name;
private string value;
/// <summary>
/// 扩展参数
/// </summary>
public string Name { get => name; private set => name = value; }
/// <summary>
/// 请求耗时(ms)
/// </summary>
public string Value { get => value; private set => this.value = value; }
protected SettingManager()
{
}
public SettingManager(string name, string value)
{
Name = name;
Value = value;
}
}
技术交流
qq群:737776595
在线文档地址:https://docs.chat.tokengo.top/docs/video/Service/Domain_Design
Video教程的Domain设计的更多相关文章
- Xamarin XAML语言教程将XAML设计的UI显示到界面
Xamarin XAML语言教程将XAML设计的UI显示到界面 如果通过XAML将UI设计好以后,就可以将XAML中的内容显示给用户了,也就是显示到界面上.由于创建XAML文件方式的不同,所以将XAM ...
- Expression Blend实例中文教程(8) - 动画设计快速入门StoryBoard http://silverlightchina.net/html/tips/2010/0329/934.html
Expression Blend实例中文教程(8) - 动画设计快速入门StoryBoard 时间:2010-03-29 11:13来源:SilverlightChina.Net 作者:jv9 点击: ...
- Gemini.Workflow 双子工作流高级教程:数据库设计及各表作用说明
整体数据库设计,可见这一篇:Gemini.Workflow 双子工作流高级教程:数据库-设计文档 这里对各数据表进行介绍: 工作流里的设计表并不多,核心只有以下8个: 下面按照流程的顺序来介绍一下表的 ...
- PS网页设计教程XXIV——从头设计一个漂亮的网站
作为编码者,美工基础是偏弱的.我们可以参考一些成熟的网页PS教程,提高自身的设计能力.套用一句话,“熟读唐诗三百首,不会作诗也会吟”. 本系列的教程来源于网上的PS教程,都是国外的,全英文的.本人尝试 ...
- github 授权登录教程与如何设计第三方授权登录的用户表
需求:在网站上想评论一篇文章,而评论文章是要用户注册与登录的,那么怎么免去这麻烦的步骤呢?答案是通过第三方授权登录.本文讲解的就是 github 授权登录的教程. 效果体验地址:http://biao ...
- 豪斯课堂K先生全套教程淘宝设计美工第一期+第四期教程(无水印)
第一期课程包括 <配色如此简单> <配色的流程><对称之美>第二期课程包括 <字体的气质及组合><平衡及构图形式><信息的筛选与图片的 ...
- kafka系列教程2(设计构造及原理1)
kafka采用了一些非主流(unconventional)并经过实践的设计使其高效和可扩展.在实际使用中kafka显示出了相对于常见流行的消息系统的优越性.并且每天能够处理上百GB的新的数据. 类 ...
- UI设计教程分享:设计一个高质量的logo要从哪方面入手呢?
有的人觉得logo只是一个简单的图形,对品牌影响无关紧要:但有的人却觉得logo对品牌有较大的影响.其实logo承载着一个公司的品牌形象.公司背景.公司理念等.就像Landor往往给一个企业做logo ...
- pageadmin CMS网站建设教程:网页设计的常用参数
由于网络速度问题,我们需要考虑图片大小对传输速度的影响,如果图片太大就会影响浏览速度,访问者很快就会对这个网站失去了兴趣,只有充分了解图片质量与下载速度的关系,并了解不同的文件格式,才能更有效的表达内 ...
- Expression Blend实例中文教程(8) - 动画设计快速入门StoryBoard
上一篇,介绍了Silverlight动画设计基础知识,Silverlight动画是基于时间线的,对于动画的实现,其实也就是对对象属性的修改过程. 而Silverlight动画分类两种类型,From/T ...
随机推荐
- OpenCV实战:从图像处理到深度学习的全面指南
本文深入浅出地探讨了OpenCV库在图像处理和深度学习中的应用.从基本概念和操作,到复杂的图像变换和深度学习模型的使用,文章以详尽的代码和解释,带领大家步入OpenCV的实战世界. 1. OpenCV ...
- ES6之清楚明白的使用类(class)
定义 类是构造函数.原型链的语法糖. 定义类有两种方式 class Student { } var Student = class { } 某些浏览器可能无法解析es6及以上的语法,这时候需要通过ba ...
- 解决Avalonia 11.X版本的中文字体问题
网上搜索的方法使用接口"IFontManagerImpl"这个方法目前只能用于Avalonia 10.X版本,因为11版本后官方把这个接口的成员都设置成了非plubic,所以之前的 ...
- 2.0 Python 数据结构与类型
数据类型是编程语言中的一个重要概念,它定义了数据的类型和提供了特定的操作和方法.在 python 中,数据类型的作用是将不同类型的数据进行分类和定义,例如数字.字符串.列表.元组.集合.字典等.这些数 ...
- 一个简单利用WebGL绘制频谱瀑布图示例
先看效果 还是比较节省性能的,这个还是包含了生成测试数据的性能,实际应用如果是直接通信获得数据应该还能少几毫秒吧! 准备工作 用了React,但是关系不大 WebGL的基础用法(推荐看一看掘金里的一个 ...
- MATLAB入门小操作(数据类型)
这是一篇有助于快速上手MATLAB软件的文章(新手向).(学习过其他的语言更容易看懂) 数据类型 这篇文章我想从MATLAB中的数据类型出发去列举一些经常使用的操作.MATLAB中的数据类型包括其他语 ...
- 命令行安装ipa包
我们可以通过ssh连接我们的iphone,来使用命令行安装ipa包 itunnel_mux.exe --lport 9993 --iport 22 itunnel_mux.exe --lport 99 ...
- EXE一机一码打包加密大师(EXE加密, 一机一码, 添加授权,添加静态密码,支持设置试用时间)
EXE一机一码打包加密大师可以打包加密保护EXE文件,同时给EXE文件添加上一机一码认证,或者静态密码,不同的电脑打开加密后的文件需要输入不同的激活码才能正常使用,保护文件安全,方便向用户收费. 下载 ...
- 【译】ASP.NET Core在 .NET Core 3.1 Preview 1中的更新
.NET Core 3.1 Preview 1现在可用.此版本主要侧重于错误修复,但同时也包含一些新功能. 这是此版本的ASP.NET Core的新增功能: 对Razor components的部分类 ...
- ISIS 协议常用基本配置总结
转载请注明出处: 1.创建IS-IS进程,进入IS-IS进程 [Huawei] isis [process-id ] 参数process-id用来指定一个IS-IS进程.如果不指定参数process- ...