From 56c0a2da1a39d074251152ac17645b1118cd6113 Mon Sep 17 00:00:00 2001
From: sunkaixuna <610262374@qq.com>
Date: Fri, 24 Sep 2021 21:29:39 +0800
Subject: [PATCH] Add unit test
---
.../SqlServerTest/SqlServerTest.csproj | 6 +-
.../UnitTest/Models/TB_AdminUser.cs | 137 ++++++++++++++++++
.../UnitTest/Models/TB_ClientConfig.cs | 134 +++++++++++++++++
.../SqlServerTest/UnitTest/UQueryable2.cs | 33 +++++
4 files changed, 307 insertions(+), 3 deletions(-)
create mode 100644 Src/Asp.Net/SqlServerTest/UnitTest/Models/TB_AdminUser.cs
create mode 100644 Src/Asp.Net/SqlServerTest/UnitTest/Models/TB_ClientConfig.cs
diff --git a/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj b/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj
index 8404479a1..40a7e0d47 100644
--- a/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj
+++ b/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj
@@ -93,6 +93,8 @@
+
+
@@ -132,9 +134,7 @@
Designer
-
-
-
+
False
diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/Models/TB_AdminUser.cs b/Src/Asp.Net/SqlServerTest/UnitTest/Models/TB_AdminUser.cs
new file mode 100644
index 000000000..67d029e6a
--- /dev/null
+++ b/Src/Asp.Net/SqlServerTest/UnitTest/Models/TB_AdminUser.cs
@@ -0,0 +1,137 @@
+using SqlSugar;
+using System;
+
+namespace OrmTest
+{
+ ///
+ /// 后台用户信息表
+ ///
+ public class TB_AdminUser
+ {
+ ///
+ /// 后台用户信息表
+ ///
+ public TB_AdminUser()
+ {
+ }
+
+ ///
+ /// 后台用户信息表
+ ///
+ /// 是否给ID赋值
+ public TB_AdminUser(bool setid)
+ {
+
+ }
+
+ ///
+ /// 后台用户ID, 主键
+ ///
+ [SugarColumn(IsPrimaryKey = true) ]
+ public System.Int64 ID { get; set; }
+
+ ///
+ /// 用户真实姓名
+ ///
+ public System.String Name { get; set; }
+
+ ///
+ /// 用户职称
+ ///
+ public System.String JobTitle { get; set; }
+
+ ///
+ /// 用户手机号, 亦为登录后台系统的账号
+ ///
+ public System.String Phone { get; set; }
+
+ ///
+ /// 登录密码, MD5加密的, 32位
+ ///
+
+ public string Password { get; set; }
+
+ ///
+ /// 所属部门ID, 逻辑关联TB_AdminDepartment表的ID
+ ///
+
+ public System.Int64 AdminDepartmentID { get; set; }
+
+ ///
+ /// 角色ID, 逻辑关联TB_AdminRole表的ID
+ ///
+
+ public System.Int64 AdminRoleID { get; set; }
+
+ ///
+ /// 用户状态. -1: 离职停用, 0: 冻结, 1: 正常
+ ///
+
+ public AdminUserStatus Status { get; set; }
+
+ ///
+ /// 备注.
+ ///
+
+ public System.String Remarks { get; set; }
+
+ ///
+ /// 创建后台用户ID, 逻辑关联TB_AdminUser表的ID
+ ///
+
+ public System.Int64 CreateAdminUserID { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public System.DateTime CreateDateTime { get; set; }
+
+ ///
+ /// 最后修改后台用户ID, 逻辑关联TB__AdminUser表的ID
+ ///
+
+ public System.Int64 ModifyAdminUserID { get; set; }
+
+ ///
+ /// 最后修改时间
+ ///
+ public System.DateTime ModifyDateTime { get; set; }
+
+ ///
+ /// 最后登录时间, null未登录过
+ ///
+ public System.DateTime? LastLoginDateTime { get; set; }
+
+ ///
+ /// 累计登录次数
+ ///
+ public System.Int32 LoginCount { get; set; }
+
+ ///
+ /// 最后修改密码的时间
+ ///
+ public DateTime ModifyPasswordDateTime { get; set; }
+
+ ///
+ /// 后台用户信息表状态枚举
+ /// -1: 离职停用, 0: 冻结, 1: 正常
+ ///
+ public enum AdminUserStatus : sbyte
+ {
+ ///
+ /// 离职 (停用, 类似删除)
+ ///
+ Dimission = -1,
+
+ ///
+ /// 冻结, 无法登录
+ ///
+ Freeze = 0,
+
+ ///
+ /// 正常
+ ///
+ Normal = 1
+ }
+ }
+}
\ No newline at end of file
diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/Models/TB_ClientConfig.cs b/Src/Asp.Net/SqlServerTest/UnitTest/Models/TB_ClientConfig.cs
new file mode 100644
index 000000000..cc5c01678
--- /dev/null
+++ b/Src/Asp.Net/SqlServerTest/UnitTest/Models/TB_ClientConfig.cs
@@ -0,0 +1,134 @@
+
+using SqlSugar;
+
+namespace OrmTest
+{
+ ///
+ /// 终端平台配置信息表
+ ///
+ public class TB_ClientConfig
+ {
+ ///
+ /// 终端平台配置信息表
+ ///
+ public TB_ClientConfig()
+ {
+ }
+
+ ///
+ /// 终端平台配置信息表
+ ///
+ /// 是否给ID赋值
+ public TB_ClientConfig(bool setid)
+ {
+
+ }
+
+ ///
+ /// 主键 雪花ID. 平台唯一Key
+ ///
+ [SugarColumn(IsPrimaryKey = true)]
+ public System.Int64 ID { get; set; }
+
+ ///
+ /// 平台名称. 如: 友玩安卓APP
+ ///
+ public System.String Name { get; set; }
+
+
+ ///
+ /// 微信开放平台的AppID
+ ///
+ public System.String OpenWechatAppID { get; set; }
+
+ ///
+ /// 微信开放平台的AppSecret
+ ///
+ public System.String OpenWechatAppSecret { get; set; }
+
+ ///
+ /// 微信支付的商户号
+ ///
+ public System.String WechatPayMchID { get; set; }
+
+ ///
+ /// 微信支付的API签名Key
+ ///
+ public System.String WechatPayApiKey { get; set; }
+
+ ///
+ /// 微信支付V3版本的API签名Key
+ ///
+ public System.String WechatPayApiKeyV3 { get; set; }
+
+ ///
+ /// 微信支付是否开启
+ ///
+ public System.Boolean WechatPaymentOpen { get; set; }
+
+ ///
+ /// 微信提现是否开启
+ ///
+ public System.Boolean WechatWithdrawOpen { get; set; }
+
+ ///
+ /// 微信小程序原始ID
+ ///
+ public System.String WechatMiniOriginalID { get; set; }
+
+ ///
+ /// 支付宝支付的AppID
+ ///
+ public System.String AlipayAppID { get; set; }
+
+ ///
+ /// 支付宝支付的私钥
+ ///
+ public System.String AlipayPrivateKey { get; set; }
+
+ ///
+ /// 支付宝支付的公钥
+ ///
+ public System.String AlipayPublicKey { get; set; }
+
+ ///
+ /// 支付宝支付是否开启
+ ///
+ public System.Boolean AlipayPaymentOpen { get; set; }
+
+ ///
+ /// 支付宝提现是否开启
+ ///
+ public System.Boolean AlipayWithdrawOpen { get; set; }
+
+ ///
+ /// 是否有效
+ ///
+ public System.Boolean IsValid { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public System.Int64 CreateDateTime { get; set; }
+
+ ///
+ /// 创建后台用户ID
+ ///
+ public System.Int64 CreateAdminUserID { get; set; }
+
+ ///
+ /// 最后修改时间
+ ///
+ public System.Int64? ModifyDateTime { get; set; }
+
+ ///
+ /// 最后修改的后台用户ID
+ ///
+ public System.Int64? ModifyAdminUserID { get; set; }
+
+ ///
+ /// 扩展信息, 一般为JSON格式
+ ///
+ public System.String Extension { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UQueryable2.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UQueryable2.cs
index 8b18afc62..d263c4c97 100644
--- a/Src/Asp.Net/SqlServerTest/UnitTest/UQueryable2.cs
+++ b/Src/Asp.Net/SqlServerTest/UnitTest/UQueryable2.cs
@@ -214,6 +214,39 @@ namespace OrmTest
}).ToList();
var list16=Db.Queryable().OrderBy(it => it.CreateTime.ToString("yyyy-MM-dd")).Select(it=> new { x = it.CreateTime.ToString("yyyy-MM-dd") }).ToList();
+
+ Db.CodeFirst.InitTables();
+ Db.Insertable(new TB_ClientConfig()
+ {
+ AlipayAppID = "aa",
+ AlipayPaymentOpen=true,
+ AlipayPrivateKey="a",
+ AlipayPublicKey="",
+ AlipayWithdrawOpen=true,
+ CreateAdminUserID=1 ,
+ CreateDateTime=11,
+ Extension="a",
+ ModifyAdminUserID=1,
+ ModifyDateTime=1,
+ Name="a",
+ WechatPayMchID="a",
+ OpenWechatAppID="a",
+ OpenWechatAppSecret="a",
+ WechatMiniOriginalID="b",
+ WechatPayApiKey="a",
+ WechatPayApiKeyV3="z"
+
+ }).ExecuteReturnSnowflakeId();
+ var list17= Db.Queryable((f, c, m) => new JoinQueryInfos(
+ JoinType.Left, f.CreateAdminUserID == c.ID,
+ JoinType.Left, f.ModifyAdminUserID == m.ID))
+ .OrderBy(f => f.CreateDateTime, OrderByType.Desc)
+ .Select((f, c, m) => new
+ {
+ f,
+ CreateAdminUserName = c.Name,
+ ModifyAdminUserName = m.Name
+ }).ToList();
}
public class UnitEnumTest