diff --git a/OpenAuth.App/AppManager/AppManager.cs b/OpenAuth.App/AppManager/AppManager.cs index 8a72b408..9af23eb8 100644 --- a/OpenAuth.App/AppManager/AppManager.cs +++ b/OpenAuth.App/AppManager/AppManager.cs @@ -47,10 +47,6 @@ namespace OpenAuth.App { return Repository.GetFirst(u => u.AppSecret == modelAppKey); } - - public void Delete(string[] ids) - { - Repository.DeleteByIds(ids); - } + } } \ No newline at end of file diff --git a/OpenAuth.App/Base/SqlSugarBaseApp.cs b/OpenAuth.App/Base/SqlSugarBaseApp.cs index b4b77bdb..803eaf5f 100644 --- a/OpenAuth.App/Base/SqlSugarBaseApp.cs +++ b/OpenAuth.App/Base/SqlSugarBaseApp.cs @@ -9,6 +9,10 @@ using SqlSugar; namespace OpenAuth.App { + /// + /// SqlSugar基础类 + /// + /// public abstract class SqlSugarBaseApp where T : class, new() { protected ISqlSugarClient SugarClient; @@ -23,6 +27,16 @@ namespace OpenAuth.App SugarClient = client; _auth = auth; } + + public void Delete(string[] ids) + { + Repository.DeleteByIds(ids); + } + + public T Get(string id) + { + return SugarClient.Queryable().Where("Id=@id", new {id = id}).First(); + } /// /// 获取当前登录用户的数据访问权限 diff --git a/OpenAuth.App/Resources/ResourceApp.cs b/OpenAuth.App/Resources/ResourceApp.cs index 969e87d1..a0685eff 100644 --- a/OpenAuth.App/Resources/ResourceApp.cs +++ b/OpenAuth.App/Resources/ResourceApp.cs @@ -96,10 +96,6 @@ namespace OpenAuth.App public ResourceApp(ISqlSugarClient client, IAuth auth) : base(client, auth) { } - - public void Delete(string[] ids) - { - Repository.DeleteByIds(ids); - } + } } \ No newline at end of file diff --git a/OpenAuth.App/SysPrinterPlanApp/SysPrinterPlanApp.cs b/OpenAuth.App/SysPrinterPlanApp/SysPrinterPlanApp.cs index 2fed2f57..11860ff8 100644 --- a/OpenAuth.App/SysPrinterPlanApp/SysPrinterPlanApp.cs +++ b/OpenAuth.App/SysPrinterPlanApp/SysPrinterPlanApp.cs @@ -2,18 +2,16 @@ using System; 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 SysPrinterPlanApp : BaseStringApp + public class SysPrinterPlanApp : SqlSugarBaseApp { /// /// 加载列表 @@ -42,9 +40,9 @@ namespace OpenAuth.App var propertyStr = string.Join(',', columnFields.Select(u => u.ColumnName)); result.columnFields = columnFields; - result.data = objs.OrderBy(u => u.Id) + result.data = objs.OrderByDescending(u => u.CreateTime) .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; } @@ -53,23 +51,24 @@ namespace OpenAuth.App { //程序类型取入口应用的名称,可以根据自己需要调整 var addObj = obj.MapTo(); - //addObj.Time = DateTime.Now; - Repository.Add(addObj); + addObj.CreateTime = DateTime.Now; + addObj.CreateUser = _auth.GetUserName(); + Repository.Insert(addObj); } public void Update(AddOrUpdateSysPrinterPlanReq obj) { - UnitWork.Update(u => u.Id == obj.Id, u => new SysPrinterPlan + Repository.Update(u => new SysPrinterPlan { Name = obj.Name, SourceSql = obj.SourceSql, PlanContent = obj.PlanContent - }); + },u => u.Id == obj.Id); } - - public SysPrinterPlanApp(IUnitWork unitWork, - IRepository repository, IAuth auth) : base(unitWork, repository, auth) + + public SysPrinterPlanApp(ISqlSugarClient client, IAuth auth) : base(client, auth) { } + } } \ No newline at end of file