From 0d098a9a297508010921982a46f9f227f2c1c883 Mon Sep 17 00:00:00 2001 From: yubaolee Date: Wed, 14 May 2025 11:19:07 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=88=86=E7=B1=BB=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E4=B8=BAsqlsugar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/Category/CategoryApp.cs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/OpenAuth.App/Category/CategoryApp.cs b/OpenAuth.App/Category/CategoryApp.cs index 9ff2d790..4059237a 100644 --- a/OpenAuth.App/Category/CategoryApp.cs +++ b/OpenAuth.App/Category/CategoryApp.cs @@ -3,18 +3,15 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Infrastructure; -using Microsoft.EntityFrameworkCore; using OpenAuth.App.Interface; using OpenAuth.App.Request; using OpenAuth.App.Response; -using OpenAuth.Repository; using OpenAuth.Repository.Domain; -using OpenAuth.Repository.Interface; - +using SqlSugar; namespace OpenAuth.App { - public class CategoryApp : BaseStringApp + public class CategoryApp : SqlSugarBaseApp { /// /// 加载列表 @@ -40,7 +37,7 @@ namespace OpenAuth.App } var result = new TableData(); - var objs = UnitWork.Find(null); + var objs = SugarClient.Queryable(); if (!string.IsNullOrEmpty(request.TypeId)) { objs = objs.Where(u => u.TypeId == request.TypeId); @@ -60,7 +57,7 @@ namespace OpenAuth.App result.columnFields = columnFields; result.data = objs.OrderBy(u => u.DtCode) .Skip((request.page - 1) * request.limit) - .Take(request.limit).Select($"new ({propertyStr})"); + .Take(request.limit).Select($"{propertyStr}").ToList(); result.count = await objs.CountAsync(); return result; } @@ -72,13 +69,13 @@ namespace OpenAuth.App var user = _auth.GetCurrentUser().User; obj.CreateUserId = user.Id; obj.CreateUserName = user.Name; - await Repository.AddAsync(obj); + await SugarClient.Insertable(obj).ExecuteCommandAsync(); } public void Update(AddOrUpdateCategoryReq obj) { var user = _auth.GetCurrentUser().User; - UnitWork.Update(u => u.Id == obj.Id, u => new Category + Repository.Update(u => new Category { Name = obj.Name, Enable = obj.Enable, @@ -89,7 +86,7 @@ namespace OpenAuth.App UpdateUserId = user.Id, UpdateUserName = user.Name, SortNo = obj.SortNo - }); + },u => u.Id == obj.Id); } @@ -100,10 +97,10 @@ namespace OpenAuth.App /// public List LoadByTypeId(string typeId) { - return Repository.Find(u => u.TypeId == typeId).ToList(); + return SugarClient.Queryable().Where(u => u.TypeId == typeId).ToList(); } - public CategoryApp(IUnitWork unitWork, IRepository repository,IAuth auth) : base(unitWork, repository, auth) + public CategoryApp(ISqlSugarClient client, IAuth auth) : base(client, auth) { } }