From 1bfa11facc694e85d488114a5b7c63fef21118b4 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 10 Jul 2023 17:11:51 +0800 Subject: [PATCH] Add unit test --- .../SqlSeverTest/UnitTest/Main.cs | 1 + .../SqlSeverTest/UnitTest/UnitOneToOneNAny.cs | 19 ++ .../UnitTest/Unitasf1/EmpDepartmentJob.cs | 52 +++++ .../UnitTest/Unitasf1/EmpInformation.cs | 180 ++++++++++++++++++ .../UnitTest/Unitasf1/EmpLicense.cs | 158 +++++++++++++++ .../UnitTest/Unitasf1/EmpLicenseLogOff.cs | 86 +++++++++ 6 files changed, 496 insertions(+) create mode 100644 Src/Asp.NetCore2/SqlSeverTest/UnitTest/UnitOneToOneNAny.cs create mode 100644 Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpDepartmentJob.cs create mode 100644 Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpInformation.cs create mode 100644 Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpLicense.cs create mode 100644 Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpLicenseLogOff.cs diff --git a/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Main.cs b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Main.cs index e07c15bbd..ad3761c7b 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Main.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Main.cs @@ -31,6 +31,7 @@ namespace OrmTest } public static void Init() { + UnitOneToOneNAny.Init(); Unitrasdfa.Init(); Unitadfasdfa.Init(); UpdateNavOneToOne.Init(); diff --git a/Src/Asp.NetCore2/SqlSeverTest/UnitTest/UnitOneToOneNAny.cs b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/UnitOneToOneNAny.cs new file mode 100644 index 000000000..0a6307331 --- /dev/null +++ b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/UnitOneToOneNAny.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace OrmTest +{ + internal class UnitOneToOneNAny + { + public static void Init() + { + var db = NewUnitTest.Db; + db.CodeFirst.InitTables(); + db.Queryable() + .Where(it => it.EmpLicense.EmpInformation.EmpDepartmentJobs.Any(z => z.DepId == 1)) + .ToList(); + } + } +} diff --git a/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpDepartmentJob.cs b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpDepartmentJob.cs new file mode 100644 index 000000000..f5acd6122 --- /dev/null +++ b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpDepartmentJob.cs @@ -0,0 +1,52 @@ +using SqlSugar; +using SqlSugar.Extensions; + +namespace OrmTest +{ + /// + ///数据实体对象 + /// @author 作者:曹伟 + /// @date 2022-12-28 19:37:41 + /// + [SugarTable("Emp_Department_Job")] + public class EmpDepartmentJob + { + /// + /// 描述 :主键 + /// 空值 : false /// + [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "Id")] + public long Id { get; set; } + /// + /// 描述 :人员id + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpId")] + public long? EmpId { get; set; } + /// + /// 描述 :部门id + /// 空值 : true + /// + [SugarColumn(ColumnName = "DepId")] + public long? DepId { get; set; } + /// + /// 描述 :岗位id + /// 空值 : true + /// + [SugarColumn(ColumnName = "JobId")] + public long? JobId { get; set; } + /// + /// 描述 :是否主部门 + /// 空值 : true + /// + [SugarColumn(ColumnName = "Active")] + public bool? Active { get; set; } + + /// + /// 描述 :是否主部门 + /// 空值 : false + /// + [SugarColumn(ColumnName = "IsSelect")] + public bool? IsSelect { get; set; } + + } +} \ No newline at end of file diff --git a/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpInformation.cs b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpInformation.cs new file mode 100644 index 000000000..6d13a64df --- /dev/null +++ b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpInformation.cs @@ -0,0 +1,180 @@ +using SqlSugar; +using SqlSugar.Extensions; +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace OrmTest +{ + /// + ///数据实体对象 + /// @author 作者:曹伟 + /// @date 2022/11/3 15:30:19 + /// + [SugarTable("Emp_Information")] + public class EmpInformation + { + /// + /// 描述 :主键 + /// 空值 : false /// + [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "Id")] + public long Id { get; set; } + /// + /// 描述 :姓名 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpName")] + public string? EmpName { get; set; } + /// + /// 描述 :性别 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpSex")] + public byte? EmpSex { get; set; } + /// + /// 描述 :身份证号码 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpIdentityCard")] + public string? EmpIdentityCard { get; set; } + /// + /// 描述 :工作证号 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpWorkID")] + public string? EmpWorkID { get; set; } + /// + /// 描述 :公司 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpCompanyId")] + public long? EmpCompanyId { get; set; } + /// + /// 描述 :公司类型 本部1 2委外 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpCompanyType")] + public string? EmpCompanyType { get; set; } + /// + /// 描述 :用工性质 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpNatureValue")] + public string? EmpNatureValue { get; set; } + /// + /// 描述 :手机号码 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpPhoneNumber")] + public string? EmpPhoneNumber { get; set; } + /// + /// 描述 :固定电话 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpFixPhoneNumber")] + public string? EmpFixPhoneNumber { get; set; } + /// + /// 描述 :邮政编码 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpZipCode")] + public string? EmpZipCode { get; set; } + /// + /// 描述 :家庭住址 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpHomeAddress")] + public string? EmpHomeAddress { get; set; } + /// + /// 描述 :户籍地址 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpResidenceAddress")] + public string? EmpResidenceAddress { get; set; } + /// + /// 描述 :所属街道 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpStreet")] + public string? EmpStreet { get; set; } + /// + /// 描述 :民族 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpNationValue")] + public string? EmpNationValue { get; set; } + /// + /// 描述 :政治面貌 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpPoliticalValue")] + public string? EmpPoliticalValue { get; set; } + /// + /// 描述 :账号类型 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpAccountTypeValue")] + public string? EmpAccountTypeValue { get; set; } + /// + /// 描述 :状态 emp_action_status在职 emp_leave_status离职 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpStatusType")] + public string? EmpStatusType { get; set; } + /// + /// 描述 :状态关系 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EmpStatusValue")] + public string? EmpStatusValue { get; set; } + /// + /// 描述 :是否机关各部门老大 + /// 空值 : true + /// + [SugarColumn(ColumnName = "IsJBoss")] + public byte? IsJBoss { get; set; } + /// + /// 描述 : + /// 空值 : true + /// + [SugarColumn(ColumnName = "CreateById")] + public long? CreateById { get; set; } + /// + /// 描述 : + /// 空值 : true + /// + [SugarColumn(ColumnName = "CreateBy")] + public string? CreateBy { get; set; } + /// + /// 描述 : + /// 空值 : true + /// + [SugarColumn(ColumnName = "CreateTime")] + public DateTime? CreateTime { get; set; } + /// + /// 描述 : + /// 空值 : true + /// + [SugarColumn(ColumnName = "LastUpdateById")] + public long? LastUpdateById { get; set; } + /// + /// 描述 : + /// 空值 : true + /// + [SugarColumn(ColumnName = "LastUpdateBy")] + public string? LastUpdateBy { get; set; } + /// + /// 描述 : + /// 空值 : true + /// + [SugarColumn(ColumnName = "LastUpdateTime")] + public DateTime? LastUpdateTime { get; set; } + + [Navigate(NavigateType.OneToMany, nameof(EmpDepartmentJob.EmpId))]//部门岗位表中的EmpId + public List? EmpDepartmentJobs { get; set; }//注意禁止给手动赋值 + + [Navigate(NavigateType.OneToMany, nameof(EmpLicense.IdentityCard), nameof(EmpIdentityCard))]//部门岗位表中的EmpId + public List? EmpLicenses { get; set; }//注意禁止给手动赋值 + + } +} \ No newline at end of file diff --git a/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpLicense.cs b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpLicense.cs new file mode 100644 index 000000000..6b3dedb12 --- /dev/null +++ b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpLicense.cs @@ -0,0 +1,158 @@ +using Newtonsoft.Json; +using SqlSugar; +using SqlSugar.Extensions; +using System; + +namespace OrmTest +{ + /// + ///数据实体对象 + /// @author 作者:曹伟 + /// @date 2023-02-13 18:02:23 + /// + [SugarTable("Emp_License")] + public class EmpLicense + { + /// + /// 描述 :主键 + /// 空值 : false + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "Id")] + public long Id { get; set; } + /// + /// 描述 :姓名 + /// 空值 : true + /// + [SugarColumn(ColumnName = "Name")] + public string? Name { get; set; } + /// + /// 描述 :身份证号码 + /// 空值 : true + /// + [SugarColumn(ColumnName = "IdentityCard")] + public string? IdentityCard { get; set; } + /// + /// 描述 :证照类别 + /// 空值 : true + /// + [SugarColumn(ColumnName = "LicenseClassify")] + public long? LicenseClassify { get; set; } + /// + /// 描述 :证照名称 + /// 空值 : true + /// + [SugarColumn(ColumnName = "LicenseValue")] + public string? LicenseValue { get; set; } + /// + /// 描述 :证照编号 + /// 空值 : true + /// + [SugarColumn(ColumnName = "LicenseCode")] + public string? LicenseCode { get; set; } + /// + /// 描述 :证照所属 + /// 空值 : true + /// + [SugarColumn(ColumnName = "LicenseBelong")] + public int? LicenseBelong { get; set; } + /// + /// 描述 :初证日期 + /// 空值 : true + /// + [SugarColumn(ColumnName = "InitialDate")] + public DateTime? InitialDate { get; set; } + /// + /// 描述 :复证日期 + /// 空值 : true + /// + [SugarColumn(ColumnName = "RepeatDate")] + public DateTime? RepeatDate { get; set; } + /// + /// 描述 :有效日期 + /// 空值 : true + /// + [SugarColumn(ColumnName = "EffectiveDate")] + public DateTime? EffectiveDate { get; set; } + /// + /// 描述 :核证日期 + /// 空值 : true + /// + [SugarColumn(ColumnName = "VerifyDate")] + public DateTime? VerifyDate { get; set; } + /// + /// 描述 :原件位置 + /// 空值 : true + /// + [SugarColumn(ColumnName = "Location")] + public string? Location { get; set; } + /// + /// 描述 :状态 + /// 空值 : true + /// + [SugarColumn(ColumnName = "Status")] + public int? Status { get; set; } + /// + /// 描述 :创建人id + /// 空值 : true + /// + [SugarColumn(ColumnName = "OperateById")] + public long? OperateById { get; set; } + /// + /// 描述 :创建人姓名 + /// 空值 : true + /// + [SugarColumn(ColumnName = "OperateBy")] + public string? OperateBy { get; set; } + /// + /// 描述 :创建时间 + /// 空值 : true + /// + [SugarColumn(ColumnName = "OperateTime")] + public DateTime? OperateTime { get; set; } + /// + /// 描述 :创建人id + /// 空值 : true + /// + [SugarColumn(ColumnName = "CreateById", IsOnlyIgnoreUpdate = true)] + public long? CreateById { get; set; } + /// + /// 描述 :创建人姓名 + /// 空值 : true + /// + [SugarColumn(ColumnName = "CreateBy", IsOnlyIgnoreUpdate = true)] + public string? CreateBy { get; set; } + /// + /// 描述 :创建时间 + /// 空值 : true + /// + [SugarColumn(ColumnName = "CreateTime", IsOnlyIgnoreUpdate = true)] + public DateTime? CreateTime { get; set; } + /// + /// 描述 :最后修改人id + /// 空值 : true + /// + [SugarColumn(ColumnName = "LastUpdateById", IsOnlyIgnoreInsert = true)] + public long? LastUpdateById { get; set; } + /// + /// 描述 :最后修改人 + /// 空值 : true + /// + [SugarColumn(ColumnName = "LastUpdateBy", IsOnlyIgnoreInsert = true)] + public string? LastUpdateBy { get; set; } + /// + /// 描述 :最后修改时间 + /// 空值 : true + /// + [SugarColumn(ColumnName = "LastUpdateTime", IsOnlyIgnoreInsert = true)] + public DateTime? LastUpdateTime { get; set; } + + [Navigate(NavigateType.OneToOne, nameof(IdentityCard), nameof(OrmTest.EmpInformation.EmpIdentityCard))] //自定义关系映射 + public EmpInformation? EmpInformation { get; set; } //只能是null 不能赋默认值 + + + //证照注销信息 + [Navigate(NavigateType.OneToOne, nameof(Id), nameof(OrmTest.EmpLicenseLogOff.LicenseId))]// + public EmpLicenseLogOff? EmpLicenseLogOff { get; set; } + + } +} \ No newline at end of file diff --git a/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpLicenseLogOff.cs b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpLicenseLogOff.cs new file mode 100644 index 000000000..05ab6b4d6 --- /dev/null +++ b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpLicenseLogOff.cs @@ -0,0 +1,86 @@ +using SqlSugar; +using SqlSugar.Extensions; +using System; + +namespace OrmTest +{ + /// + ///数据实体对象 + /// @author 作者:曹伟 + /// @date 2023/7/5 17:08:20 + /// + [SugarTable("Emp_License_LogOff")] + public class EmpLicenseLogOff + { + /// + /// 描述 :主键 + /// 空值 : false /// + [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "Id")] + public long Id { get; set; } + /// + /// 描述 :关联自有证照id + /// 空值 : false /// + [SugarColumn(ColumnName = "LicenseId")] + public long LicenseId { get; set; } + /// + /// 描述 :证照注销原因 + /// 空值 : true + /// + [SugarColumn(ColumnName = "LogOffReasonValue")] + public string? LogOffReasonValue { get; set; } + /// + /// 描述 :备注 + /// 空值 : true + /// + [SugarColumn(ColumnName = "Remarks")] + public string? Remarks { get; set; } + /// + /// 描述 : + /// 空值 : true + /// + [SugarColumn(ColumnName = "Status")] + public int? Status { get; set; } + /// + /// 描述 : + /// 空值 : true + /// + [SugarColumn(ColumnName = "CreateById")] + public long? CreateById { get; set; } + /// + /// 描述 : + /// 空值 : true + /// + [SugarColumn(ColumnName = "CreateBy")] + public string? CreateBy { get; set; } + /// + /// 描述 : + /// 空值 : true + /// + [SugarColumn(ColumnName = "CreateTime")] + public DateTime? CreateTime { get; set; } + /// + /// 描述 : + /// 空值 : true + /// + [SugarColumn(ColumnName = "LastUpdateById")] + public long? LastUpdateById { get; set; } + /// + /// 描述 : + /// 空值 : true + /// + [SugarColumn(ColumnName = "LastUpdateBy")] + public string? LastUpdateBy { get; set; } + /// + /// 描述 : + /// 空值 : true + /// + [SugarColumn(ColumnName = "LastUpdateTime")] + public DateTime? LastUpdateTime { get; set; } + + + //委外证照信息 + [Navigate(NavigateType.OneToOne, nameof(LicenseId), nameof(OrmTest.EmpLicense.Id))]// + public EmpLicense? EmpLicense { get; set; } + + } +} \ No newline at end of file