init
This commit is contained in:
90
DouyinApi.Services/PasswordLibServices.cs
Normal file
90
DouyinApi.Services/PasswordLibServices.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using DouyinApi.Common;
|
||||
using DouyinApi.Common.DB;
|
||||
using DouyinApi.Common.Utility;
|
||||
using DouyinApi.IRepository.Base;
|
||||
using DouyinApi.IServices;
|
||||
using DouyinApi.Model.Models;
|
||||
using DouyinApi.Repository.UnitOfWorks;
|
||||
using DouyinApi.Services.BASE;
|
||||
using SqlSugar;
|
||||
|
||||
namespace DouyinApi.Services
|
||||
{
|
||||
public partial class PasswordLibServices : BaseServices<PasswordLib>, IPasswordLibServices
|
||||
{
|
||||
IBaseRepository<PasswordLib> _dal;
|
||||
private readonly IUnitOfWorkManage _unitOfWorkManage;
|
||||
private readonly ISqlSugarClient _db;
|
||||
private SqlSugarScope db => _db as SqlSugarScope;
|
||||
|
||||
public PasswordLibServices(IBaseRepository<PasswordLib> dal, IUnitOfWorkManage unitOfWorkManage, ISqlSugarClient db)
|
||||
{
|
||||
this._dal = dal;
|
||||
_unitOfWorkManage = unitOfWorkManage;
|
||||
_db = db;
|
||||
base.BaseDal = dal;
|
||||
}
|
||||
|
||||
[UseTran(Propagation = Propagation.Required)]
|
||||
public async Task<bool> TestTranPropagation2()
|
||||
{
|
||||
await _dal.Add(new PasswordLib()
|
||||
{
|
||||
PLID = IdGeneratorUtility.NextId(),
|
||||
IsDeleted = false,
|
||||
plAccountName = "aaa",
|
||||
plCreateTime = DateTime.Now
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[UseTran(Propagation = Propagation.Mandatory)]
|
||||
public async Task<bool> TestTranPropagationNoTranError()
|
||||
{
|
||||
await _dal.Add(new PasswordLib()
|
||||
{
|
||||
IsDeleted = false,
|
||||
plAccountName = "aaa",
|
||||
plCreateTime = DateTime.Now
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[UseTran(Propagation = Propagation.Nested)]
|
||||
public async Task<bool> TestTranPropagationTran2()
|
||||
{
|
||||
await db.Insertable(new PasswordLib()
|
||||
{
|
||||
PLID = IdGeneratorUtility.NextId(),
|
||||
IsDeleted = false,
|
||||
plAccountName = "aaa",
|
||||
plCreateTime = DateTime.Now
|
||||
}).ExecuteReturnSnowflakeIdAsync();
|
||||
|
||||
//throw new Exception("测试嵌套事务异常回滚");
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> TestTranPropagationTran3()
|
||||
{
|
||||
Console.WriteLine("Begin Transaction Before:" + db.ContextID);
|
||||
db.BeginTran();
|
||||
Console.WriteLine("Begin Transaction After:" + db.ContextID);
|
||||
Console.WriteLine("");
|
||||
await db.Insertable(new PasswordLib()
|
||||
{
|
||||
PLID = IdGeneratorUtility.NextId(),
|
||||
IsDeleted = false,
|
||||
plAccountName = "aaa",
|
||||
plCreateTime = DateTime.Now
|
||||
}).ExecuteReturnSnowflakeIdAsync();
|
||||
|
||||
//throw new Exception("测试嵌套事务异常回滚");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user