提交功能
This commit is contained in:
34
Db/DB.cs
Normal file
34
Db/DB.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace ACBuildService;
|
||||
|
||||
public static class DB
|
||||
{
|
||||
public static SqlSugarClient Main { get; private set; }
|
||||
|
||||
public static void InitDb()
|
||||
{
|
||||
//创建数据库对象 (用法和EF Dappper一样通过new保证线程安全)
|
||||
Main = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = "datasource=data.db",
|
||||
DbType = DbType.Sqlite,
|
||||
IsAutoCloseConnection = true
|
||||
},
|
||||
db =>
|
||||
{
|
||||
// db.Aop.OnLogExecuting = (sql, pars) =>
|
||||
// {
|
||||
// //获取原生SQL推荐 5.1.4.63 性能OK
|
||||
// Console.WriteLine(UtilMethods.GetNativeSql(sql, pars));
|
||||
// };
|
||||
});
|
||||
|
||||
//建库
|
||||
Main.DbMaintenance.CreateDatabase();
|
||||
|
||||
//建表
|
||||
Main.CodeFirst.InitTables<VideoTable>();
|
||||
Main.CodeFirst.InitTables<DeviceTable>();
|
||||
}
|
||||
}
|
||||
38
Db/Tables/DeviceTable.cs
Normal file
38
Db/Tables/DeviceTable.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace ACBuildService;
|
||||
|
||||
[SugarTable("device")]
|
||||
public class DeviceTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备id
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 观看视频
|
||||
/// </summary>
|
||||
public int WatchId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备名字
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总观看时长
|
||||
/// </summary>
|
||||
public long TotalTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 今日观看时长
|
||||
/// </summary>
|
||||
public long TodayTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后更新时间,用于判定今日时长和跨天
|
||||
/// </summary>
|
||||
public DateTime LastTime { get; set; }
|
||||
}
|
||||
59
Db/Tables/VideoTable.cs
Normal file
59
Db/Tables/VideoTable.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using SqlSugar;
|
||||
|
||||
namespace ACBuildService;
|
||||
|
||||
|
||||
[SugarTable("video")]
|
||||
public class VideoTable
|
||||
{
|
||||
//数据是自增需要加上IsIdentity
|
||||
//数据库是主键需要加上IsPrimaryKey
|
||||
//注意:要完全和数据库一致2个属性
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 源视频地址
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "text")]
|
||||
public string SourcePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 本地存储地址
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "text")]
|
||||
public string FilePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 作者
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "text")]
|
||||
public string AuthorName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "text")]
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 简介
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "text")]
|
||||
public string Desc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 视频时长
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "text")]
|
||||
public string Duration { get; set; }
|
||||
|
||||
public int Like { get; set; }
|
||||
public int Collect { get; set; }
|
||||
public int Message { get; set; }
|
||||
public int Share { get; set; }
|
||||
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user