mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Add unit test
This commit is contained in:
parent
6b7a0433e8
commit
a6dd3c7f74
@ -95,7 +95,10 @@
|
||||
<Compile Include="Demo\Demo0_SqlSugarClient.cs" />
|
||||
<Compile Include="Models\ViewOrder.cs" />
|
||||
<Compile Include="UnitTest\Models\Order.cs" />
|
||||
<Compile Include="UnitTest\Models\RoleEntity.cs" />
|
||||
<Compile Include="UnitTest\Models\TestModel.cs" />
|
||||
<Compile Include="UnitTest\Models\UserEntity.cs" />
|
||||
<Compile Include="UnitTest\Models\UserRoleEntity.cs" />
|
||||
<Compile Include="UnitTest\UCustom01.cs" />
|
||||
<Compile Include="UnitTest\UCustom02.cs" />
|
||||
<Compile Include="UnitTest\UCustom03.cs" />
|
||||
|
65
Src/Asp.Net/SqlServerTest/UnitTest/Models/RoleEntity.cs
Normal file
65
Src/Asp.Net/SqlServerTest/UnitTest/Models/RoleEntity.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugarDemo
|
||||
{
|
||||
/// <summary>
|
||||
/// 角色信息表
|
||||
/// </summary>
|
||||
[SugarTable("Unit_SYS_Role")]
|
||||
public partial class RoleEntity
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 角色Id
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public Guid RoleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 角色名称
|
||||
/// </summary>
|
||||
public string RoleName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 角色类型|0-系统超管角色|1-系统普通角色|2-功能组|
|
||||
/// </summary>
|
||||
public int RoleType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 价格
|
||||
/// </summary>
|
||||
public decimal? UnitPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
public int? Quantity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int? SortNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属账号(账号表Id)
|
||||
/// </summary>
|
||||
public Guid ManageAccount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属机构(账号所属公司的一级机构)
|
||||
/// </summary>
|
||||
public Guid ManageOrg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 账号所属组织
|
||||
/// </summary>
|
||||
public Guid OrganizationId { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
141
Src/Asp.Net/SqlServerTest/UnitTest/Models/UserEntity.cs
Normal file
141
Src/Asp.Net/SqlServerTest/UnitTest/Models/UserEntity.cs
Normal file
@ -0,0 +1,141 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugarDemo
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 系统账号表
|
||||
/// </summary>
|
||||
[SugarTable("Unit_SYS_User")]
|
||||
public partial class UserEntity
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 系统账号Id
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义账号
|
||||
/// </summary>
|
||||
public string UserAccount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 手机账号
|
||||
/// </summary>
|
||||
public string PhoneAccount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 邮箱账号
|
||||
/// </summary>
|
||||
public string EmailAccount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 企业微信
|
||||
/// </summary>
|
||||
public string CompanyWX { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 密码凭证
|
||||
/// </summary>
|
||||
public string Credential { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 账号类型|100401-平台管理员|100402-平台用户|100403-平台OpenId|100404-租户管理员|100405-租户用户|100406-租户OpenId|100407-游客
|
||||
/// </summary>
|
||||
public int UserType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 昵称
|
||||
/// </summary>
|
||||
public string NickName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 性别
|
||||
/// </summary>
|
||||
public int Sex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 有效开始时间
|
||||
/// </summary>
|
||||
public DateTime? StartDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 有效截止时间
|
||||
/// </summary>
|
||||
public DateTime? EndDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否强制修改密码
|
||||
/// </summary>
|
||||
public bool IsChangePassword { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 安全手机号
|
||||
/// </summary>
|
||||
public string SafePhone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否实名|0-否|1-是
|
||||
/// </summary>
|
||||
public int IsReal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 真实姓名
|
||||
/// </summary>
|
||||
public string RealName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 身份证号
|
||||
/// </summary>
|
||||
public string CardNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后登录时间
|
||||
/// </summary>
|
||||
public DateTime? LastLoginDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 失败登录次数
|
||||
/// </summary>
|
||||
public int? FailedLoginPwdCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 失败登录时间
|
||||
/// </summary>
|
||||
public DateTime? VerificationLoginPwdDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 禁止用户登录时间
|
||||
/// </summary>
|
||||
public DateTime? StopLoginTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属账号(账号表Id)
|
||||
/// </summary>
|
||||
public Guid ManageAccount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属机构(账号所属公司的一级机构)
|
||||
/// </summary>
|
||||
public Guid ManageOrg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户角色
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<UserRoleEntity> UserRoleEntities { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 角色主表ID集合
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<RoleEntity> RoleEntities { get; set; }
|
||||
}
|
||||
}
|
32
Src/Asp.Net/SqlServerTest/UnitTest/Models/UserRoleEntity.cs
Normal file
32
Src/Asp.Net/SqlServerTest/UnitTest/Models/UserRoleEntity.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugarDemo
|
||||
{
|
||||
/// <summary>
|
||||
/// 账号角色表
|
||||
/// </summary>
|
||||
[SugarTable("Unit_SYS_UserRole")]
|
||||
public partial class UserRoleEntity
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 系统账号Id
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 角色Id
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public Guid RoleId { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -216,6 +216,55 @@ namespace OrmTest
|
||||
bool? bq = true;
|
||||
var d1111111111 = db.Queryable<BoolTest1>().Where(it => it.a.Equals(bq.Value)).ToArray();
|
||||
var d11111111111 = db.Queryable<BoolTest1>().Where(it => SqlFunc.IIF(bq.Value,1,2)==1).ToArray();
|
||||
|
||||
|
||||
db.CodeFirst.InitTables<SqlSugarDemo.UserEntity, SqlSugarDemo.RoleEntity, SqlSugarDemo.UserRoleEntity>();
|
||||
var data = new SqlSugarDemo.UserEntity()
|
||||
{
|
||||
CardNo = "",
|
||||
CompanyWX = "",
|
||||
Credential = "",
|
||||
EmailAccount = "",
|
||||
EndDate = DateTime.Now,
|
||||
FailedLoginPwdCount = 1,
|
||||
IsChangePassword = true,
|
||||
IsReal = 1,
|
||||
LastLoginDate = DateTime.Now,
|
||||
ManageAccount = Guid.NewGuid(),
|
||||
ManageOrg = Guid.NewGuid(),
|
||||
NickName = "",
|
||||
PhoneAccount = "",
|
||||
RealName = "",
|
||||
VerificationLoginPwdDate = DateTime.Now,
|
||||
SafePhone = "",
|
||||
Sex = 1,
|
||||
StartDate = DateTime.Now,
|
||||
StopLoginTime = DateTime.Now,
|
||||
UserAccount = "",
|
||||
UserId = Guid.NewGuid(),
|
||||
UserType = 1
|
||||
};
|
||||
db.Insertable(data).ExecuteCommand();
|
||||
var role = new SqlSugarDemo.RoleEntity()
|
||||
{
|
||||
RoleId=Guid.NewGuid(),
|
||||
ManageAccount= Guid.NewGuid(),
|
||||
ManageOrg=Guid.NewGuid(),
|
||||
OrganizationId=Guid.NewGuid(),
|
||||
UnitPrice=1,
|
||||
Quantity=1,
|
||||
RoleName="",
|
||||
RoleType=1,
|
||||
SortNum=1
|
||||
};
|
||||
db.Insertable(role).ExecuteCommand();
|
||||
db.Insertable(new SqlSugarDemo.UserRoleEntity()
|
||||
{
|
||||
RoleId= role.RoleId,
|
||||
UserId=data.UserId
|
||||
}).ExecuteCommand();
|
||||
var d111111111111 = db.Queryable<SqlSugarDemo.UserEntity>()
|
||||
.Mapper<SqlSugarDemo.UserEntity, SqlSugarDemo.RoleEntity, SqlSugarDemo.UserRoleEntity>(it => ManyToMany.Config(it.UserId, it.RoleId)).InSingle(data.UserId);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user