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设计的更多相关文章

  1. Xamarin XAML语言教程将XAML设计的UI显示到界面

    Xamarin XAML语言教程将XAML设计的UI显示到界面 如果通过XAML将UI设计好以后,就可以将XAML中的内容显示给用户了,也就是显示到界面上.由于创建XAML文件方式的不同,所以将XAM ...

  2. 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 点击: ...

  3. Gemini.Workflow 双子工作流高级教程:数据库设计及各表作用说明

    整体数据库设计,可见这一篇:Gemini.Workflow 双子工作流高级教程:数据库-设计文档 这里对各数据表进行介绍: 工作流里的设计表并不多,核心只有以下8个: 下面按照流程的顺序来介绍一下表的 ...

  4. PS网页设计教程XXIV——从头设计一个漂亮的网站

    作为编码者,美工基础是偏弱的.我们可以参考一些成熟的网页PS教程,提高自身的设计能力.套用一句话,“熟读唐诗三百首,不会作诗也会吟”. 本系列的教程来源于网上的PS教程,都是国外的,全英文的.本人尝试 ...

  5. github 授权登录教程与如何设计第三方授权登录的用户表

    需求:在网站上想评论一篇文章,而评论文章是要用户注册与登录的,那么怎么免去这麻烦的步骤呢?答案是通过第三方授权登录.本文讲解的就是 github 授权登录的教程. 效果体验地址:http://biao ...

  6. 豪斯课堂K先生全套教程淘宝设计美工第一期+第四期教程(无水印)

    第一期课程包括 <配色如此简单> <配色的流程><对称之美>第二期课程包括 <字体的气质及组合><平衡及构图形式><信息的筛选与图片的 ...

  7. kafka系列教程2(设计构造及原理1)

    kafka采用了一些非主流(unconventional)并经过实践的设计使其高效和可扩展.在实际使用中kafka显示出了相对于常见流行的消息系统的优越性.并且每天能够处理上百GB的新的数据.   类 ...

  8. UI设计教程分享:设计一个高质量的logo要从哪方面入手呢?

    有的人觉得logo只是一个简单的图形,对品牌影响无关紧要:但有的人却觉得logo对品牌有较大的影响.其实logo承载着一个公司的品牌形象.公司背景.公司理念等.就像Landor往往给一个企业做logo ...

  9. pageadmin CMS网站建设教程:网页设计的常用参数

    由于网络速度问题,我们需要考虑图片大小对传输速度的影响,如果图片太大就会影响浏览速度,访问者很快就会对这个网站失去了兴趣,只有充分了解图片质量与下载速度的关系,并了解不同的文件格式,才能更有效的表达内 ...

  10. Expression Blend实例中文教程(8) - 动画设计快速入门StoryBoard

    上一篇,介绍了Silverlight动画设计基础知识,Silverlight动画是基于时间线的,对于动画的实现,其实也就是对对象属性的修改过程. 而Silverlight动画分类两种类型,From/T ...

随机推荐

  1. Mybatis开发中的常用Maven配置

    Mybatis导入Maven配置 <!-- MyBatis导入 --> <dependency> <groupId>org.mybatis</groupId& ...

  2. 事务,不只ACID

    1. 什么是事务? 应用在运行时可能会发生数据库.硬件的故障,应用与数据库的网络连接断开或多个客户端端并发修改数据导致预期之外的数据覆盖问题,为了提高应用的可靠性和数据的一致性,事务应运而生. 从概念 ...

  3. 论文解读(TAT)《 Transferable Adversarial Training: A General Approach to Adapting Deep Classifiers》

    Note:[ wechat:Y466551 | 可加勿骚扰,付费咨询 ] 论文信息 论文标题:Transferable Adversarial Training: A General Approach ...

  4. 5、Spring之bean的作用域和生命周期

    5.1.bean的作用域 5.1.1.单例(默认且常用) 5.1.1.1.配置bean 注意:当bean不配置scope属性时,默认是singleton(单例) <?xml version=&q ...

  5. Iphone常用工具

    iFunBox itools 百度助手 崩溃日志的路径 /var/mobile/Library/Logs/CrashReporter

  6. vivo数据中心网络链路质量监测的探索实践

    作者:vivo 互联网服务器团队- Wang Shimin 网络质量监测中心是一个用于数据中心网络延迟测量和分析的大型系统.通过部署在服务器上的Agent发起5次ICMP Ping以获取端到端之间的网 ...

  7. docker bridge网络类型研究

    bridge模式是docker的默认网络模式,使用docker run -p时,docker实际是在iptables做了DNAT规则,实现端口转发功能.可以使用iptables -t nat -vnL ...

  8. element-ui实现弹窗

    element-ui实现弹窗 需要的官网组件 要弹出的页面 <template> <el-form :model="ruleForm" :rules=" ...

  9. ActivityNotFoundException

    activity  加入 AndroidManifest android.content.ActivityNotFoundException: Unable to find explicit acti ...

  10. Spring框架中 依赖注入和控制反转,最简单、最通俗的解释! 再加上一个AOP

    首先依赖注入 == 控制反转,只不过控制反转这个词汇,让人产生了错误的理解,才使用新的词汇:依赖注入来替换到这个词汇. "依赖注入"是指一个对象应用另外一个对象来提供一个特殊的能力 ...