From 3932d785ca6f4d307c57105c3236542d57a78319 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Thu, 5 Jun 2025 15:44:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.IServices/IGuestbookServices.cs | 15 -- Tiobon.Core.Model/Models/Guestbook.cs | 47 ---- .../ViewModels/GuestbookViewModels.cs | 49 ----- Tiobon.Core.Services/GuestbookServices.cs | 202 ------------------ Tiobon.Core/Tiobon.Core.Model.xml | 80 ------- 5 files changed, 393 deletions(-) delete mode 100644 Tiobon.Core.IServices/IGuestbookServices.cs delete mode 100644 Tiobon.Core.Model/Models/Guestbook.cs delete mode 100644 Tiobon.Core.Model/ViewModels/GuestbookViewModels.cs delete mode 100644 Tiobon.Core.Services/GuestbookServices.cs diff --git a/Tiobon.Core.IServices/IGuestbookServices.cs b/Tiobon.Core.IServices/IGuestbookServices.cs deleted file mode 100644 index 57baef90..00000000 --- a/Tiobon.Core.IServices/IGuestbookServices.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Tiobon.Core.Model; - -namespace Tiobon.Core.IServices; - -public partial interface IGuestbookServices : IBaseServices -{ - Task> TestTranInRepository(); - Task TestTranInRepositoryAOP(); - - Task TestTranPropagation(); - - Task TestTranPropagationNoTran(); - - Task TestTranPropagationTran(); -} \ No newline at end of file diff --git a/Tiobon.Core.Model/Models/Guestbook.cs b/Tiobon.Core.Model/Models/Guestbook.cs deleted file mode 100644 index 346fd5b2..00000000 --- a/Tiobon.Core.Model/Models/Guestbook.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace Tiobon.Core.Model.Models; - -public class Guestbook : RootEntityTkey -{ - - /// 博客ID - /// - /// - public long? TiobonId { get; set; } - /// 创建时间 - /// - /// - public DateTime createdate { get; set; } - - [SugarColumn(Length = 2000, IsNullable = true)] - public string username { get; set; } - - /// 手机 - /// - /// - [SugarColumn(Length = 2000, IsNullable = true)] - public string phone { get; set; } - /// qq - /// - /// - [SugarColumn(Length = 2000, IsNullable = true)] - public string QQ { get; set; } - - /// 留言内容 - /// - /// - [SugarColumn(Length = 2000, IsNullable = true)] - public string body { get; set; } - /// ip地址 - /// - /// - [SugarColumn(Length = 2000, IsNullable = true)] - public string ip { get; set; } - - /// 是否显示在前台,0否1是 - /// - /// - public bool isshow { get; set; } - - [SugarColumn(IsIgnore = true)] - public TiobonArticle Tiobonarticle { get; set; } -} diff --git a/Tiobon.Core.Model/ViewModels/GuestbookViewModels.cs b/Tiobon.Core.Model/ViewModels/GuestbookViewModels.cs deleted file mode 100644 index 28b8f11e..00000000 --- a/Tiobon.Core.Model/ViewModels/GuestbookViewModels.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Tiobon.Core.Model.Models; - -namespace Tiobon.Core.Model.ViewModels; - -/// -/// 留言信息展示类 -/// -public class GuestbookViewModels -{ - /// 留言表 - /// - /// - public int id { get; set; } - - /// 博客ID - /// - /// - public int? TiobonId { get; set; } - /// 创建时间 - /// - /// - public DateTime createdate { get; set; } - public string username { get; set; } - - /// 手机 - /// - /// - public string phone { get; set; } - /// qq - /// - /// - public string QQ { get; set; } - - /// 留言内容 - /// - /// - public string body { get; set; } - /// ip地址 - /// - /// - public string ip { get; set; } - - /// 是否显示在前台,0否1是 - /// - /// - public bool isshow { get; set; } - - public TiobonArticle Tiobonarticle { get; set; } -} diff --git a/Tiobon.Core.Services/GuestbookServices.cs b/Tiobon.Core.Services/GuestbookServices.cs deleted file mode 100644 index 641230af..00000000 --- a/Tiobon.Core.Services/GuestbookServices.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Tiobon.Core.Common.DB; -using Tiobon.Core.Repository.UnitOfWorks; - -namespace Tiobon.Core.Services; - -public class GuestbookServices : BaseServices, IGuestbookServices -{ - private readonly IUnitOfWorkManage _unitOfWorkManage; - private readonly IBaseRepository _passwordLibRepository; - - private readonly IPasswordLibServices _passwordLibServices; - - public GuestbookServices(IUnitOfWorkManage unitOfWorkManage, IBaseRepository dal, IBaseRepository passwordLibRepository, IPasswordLibServices passwordLibServices) - { - _unitOfWorkManage = unitOfWorkManage; - _passwordLibRepository = passwordLibRepository; - _passwordLibServices = passwordLibServices; - } - - public async Task> TestTranInRepository() - { - try - { - Console.WriteLine($""); - Console.WriteLine($"事务操作开始"); - using (var uow = _unitOfWorkManage.CreateUnitOfWork()) - { - Console.WriteLine($""); - - Console.WriteLine($"insert a data into the table PasswordLib now."); - var insertPassword = await _passwordLibRepository.Add(new PasswordLib() - { - IsDeleted = false, - plAccountName = "aaa", - plCreateTime = DateTime.Now - }); - - - var passwords = await _passwordLibRepository.Query(d => d.IsDeleted == false); - Console.WriteLine($"second time : the count of passwords is :{passwords.Count}"); - - //...... - - Console.WriteLine($""); - var guestbooks = await BaseDal.Query(); - Console.WriteLine($"first time : the count of guestbooks is :{guestbooks.Count}"); - - int ex = 0; - Console.WriteLine($"\nThere's an exception!!"); - int throwEx = 1 / ex; - - Console.WriteLine($"insert a data into the table Guestbook now."); - var insertGuestbook = await BaseDal.Add(new Guestbook() - { - username = "bbb", - TiobonId = 1, - createdate = DateTime.Now, - isshow = true - }); - - guestbooks = await BaseDal.Query(); - Console.WriteLine($"second time : the count of guestbooks is :{guestbooks.Count}"); - - uow.Commit(); - } - - return new ServiceResult() - { - Success = true, - Message = "操作完成" - }; - } - catch (Exception) - { - var passwords = await _passwordLibRepository.Query(); - Console.WriteLine($"third time : the count of passwords is :{passwords.Count}"); - - var guestbooks = await BaseDal.Query(); - Console.WriteLine($"third time : the count of guestbooks is :{guestbooks.Count}"); - - return new ServiceResult() - { - Success = false, - Message = "操作异常" - }; - } - } - - [UseTran] - public async Task TestTranInRepositoryAOP() - { - var passwords = await _passwordLibRepository.Query(); - Console.WriteLine($"first time : the count of passwords is :{passwords.Count}"); - - - Console.WriteLine($"insert a data into the table PasswordLib now."); - var insertPassword = await _passwordLibRepository.Add(new PasswordLib() - { - IsDeleted = false, - plAccountName = "aaa", - plCreateTime = DateTime.Now - }); - - - passwords = await _passwordLibRepository.Query(d => d.IsDeleted == false); - Console.WriteLine($"second time : the count of passwords is :{passwords.Count}"); - - //...... - - Console.WriteLine($""); - var guestbooks = await BaseDal.Query(); - Console.WriteLine($"first time : the count of guestbooks is :{guestbooks.Count}"); - - int ex = 0; - Console.WriteLine($"\nThere's an exception!!"); - int throwEx = 1 / ex; - - Console.WriteLine($"insert a data into the table Guestbook now."); - var insertGuestbook = await BaseDal.Add(new Guestbook() - { - username = "bbb", - TiobonId = 1, - createdate = DateTime.Now, - isshow = true - }); - - guestbooks = await BaseDal.Query(); - Console.WriteLine($"second time : the count of guestbooks is :{guestbooks.Count}"); - - return true; - } - - /// - /// 测试使用同事务 - /// - /// - [UseTran(Propagation = Propagation.Required)] - public async Task TestTranPropagation() - { - var guestbooks = await base.Query(); - Console.WriteLine($"first time : the count of guestbooks is :{guestbooks.Count}"); - - var insertGuestbook = await base.Add(new Guestbook() - { - username = "bbb", - TiobonId = 1, - createdate = DateTime.Now, - isshow = true - }); - - await _passwordLibServices.TestTranPropagation2(); - - return true; - } - - - /// - /// 测试无事务 Mandatory传播机制报错 - /// - /// - public async Task TestTranPropagationNoTran() - { - var guestbooks = await base.Query(); - Console.WriteLine($"first time : the count of guestbooks is :{guestbooks.Count}"); - - var insertGuestbook = await base.Add(new Guestbook() - { - username = "bbb", - TiobonId = 1, - createdate = DateTime.Now, - isshow = true - }); - - await _passwordLibServices.TestTranPropagationNoTranError(); - - return true; - } - - - /// - /// 测试嵌套事务 - /// - /// - [UseTran(Propagation = Propagation.Required)] - public async Task TestTranPropagationTran() - { - var guestbooks = await base.Query(); - Console.WriteLine($"first time : the count of guestbooks is :{guestbooks.Count}"); - - var insertGuestbook = await base.Add(new Guestbook() - { - username = "bbb", - TiobonId = 1, - createdate = DateTime.Now, - isshow = true - }); - - await _passwordLibServices.TestTranPropagationTran2(); - - return true; - } -} \ No newline at end of file diff --git a/Tiobon.Core/Tiobon.Core.Model.xml b/Tiobon.Core/Tiobon.Core.Model.xml index 5e162309..fb449e97 100644 --- a/Tiobon.Core/Tiobon.Core.Model.xml +++ b/Tiobon.Core/Tiobon.Core.Model.xml @@ -38364,41 +38364,6 @@ Reverse5 - - 博客ID - - - - - 创建时间 - - - - - 手机 - - - - - qq - - - - - 留言内容 - - - - - ip地址 - - - - - 是否显示在前台,0否1是 - - - 接口API地址信息表 @@ -43638,51 +43603,6 @@ Offer文件路径 - - - 留言信息展示类 - - - - 留言表 - - - - - 博客ID - - - - - 创建时间 - - - - - 手机 - - - - - qq - - - - - 留言内容 - - - - - ip地址 - - - - - 是否显示在前台,0否1是 - - - 实现IJob的类