日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

Video教程的Domain设计

發布時間:2023/11/29 windows 38 coder
生活随笔 收集整理的這篇文章主要介紹了 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设计的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。