diff --git a/OpenAuth.App/AppManager.cs b/OpenAuth.App/AppManager.cs index f200e689..506183d6 100644 --- a/OpenAuth.App/AppManager.cs +++ b/OpenAuth.App/AppManager.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading.Tasks; using OpenAuth.App.Interface; using OpenAuth.App.Request; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; @@ -12,7 +13,7 @@ namespace OpenAuth.App /// /// 分类管理 /// - public class AppManager : BaseApp + public class AppManager : BaseApp { public void Add(Application Application) { @@ -36,7 +37,7 @@ namespace OpenAuth.App return applications.ToList(); } - public AppManager(IUnitWork unitWork, IRepository repository,IAuth auth) : base(unitWork, repository, auth) + public AppManager(IUnitWork unitWork, IRepository repository,IAuth auth) : base(unitWork, repository, auth) { } } diff --git a/OpenAuth.App/AuthContextFactory.cs b/OpenAuth.App/AuthContextFactory.cs index 8952e951..6bd10143 100644 --- a/OpenAuth.App/AuthContextFactory.cs +++ b/OpenAuth.App/AuthContextFactory.cs @@ -14,6 +14,7 @@ // // *********************************************************************** +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; @@ -27,11 +28,11 @@ namespace OpenAuth.App { private SystemAuthStrategy _systemAuth; private NormalAuthStrategy _normalAuthStrategy; - private readonly IUnitWork _unitWork; + private readonly IUnitWork _unitWork; public AuthContextFactory(SystemAuthStrategy sysStrategy , NormalAuthStrategy normalAuthStrategy - , IUnitWork unitWork) + , IUnitWork unitWork) { _systemAuth = sysStrategy; _normalAuthStrategy = normalAuthStrategy; diff --git a/OpenAuth.App/AuthStrategies/NormalAuthStrategy.cs b/OpenAuth.App/AuthStrategies/NormalAuthStrategy.cs index 0b68efa5..e4ace75e 100644 --- a/OpenAuth.App/AuthStrategies/NormalAuthStrategy.cs +++ b/OpenAuth.App/AuthStrategies/NormalAuthStrategy.cs @@ -19,6 +19,7 @@ using System.Collections.Generic; using System.Linq; using Infrastructure; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; @@ -27,7 +28,7 @@ namespace OpenAuth.App /// /// 普通用户授权策略 /// - public class NormalAuthStrategy :BaseApp, IAuthStrategy + public class NormalAuthStrategy :BaseApp, IAuthStrategy { protected User _user; @@ -134,7 +135,7 @@ namespace OpenAuth.App //用户角色 - public NormalAuthStrategy(IUnitWork unitWork, IRepository repository, DbExtension dbExtension) : base(unitWork, repository,null) + public NormalAuthStrategy(IUnitWork unitWork, IRepository repository, DbExtension dbExtension) : base(unitWork, repository,null) { _dbExtension = dbExtension; } diff --git a/OpenAuth.App/AuthStrategies/SystemAuthStrategy.cs b/OpenAuth.App/AuthStrategies/SystemAuthStrategy.cs index b3800c6f..4f4dd06d 100644 --- a/OpenAuth.App/AuthStrategies/SystemAuthStrategy.cs +++ b/OpenAuth.App/AuthStrategies/SystemAuthStrategy.cs @@ -19,6 +19,7 @@ using System.Collections.Generic; using System.Linq; using Infrastructure; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; @@ -29,7 +30,7 @@ namespace OpenAuth.App /// 超级管理员权限 /// 超级管理员使用guid.empty为ID,可以根据需要修改 /// - public class SystemAuthStrategy : BaseApp, IAuthStrategy + public class SystemAuthStrategy : BaseApp, IAuthStrategy { protected User _user; private DbExtension _dbExtension; @@ -97,7 +98,7 @@ namespace OpenAuth.App } - public SystemAuthStrategy(IUnitWork unitWork, IRepository repository, DbExtension dbExtension) : base(unitWork, repository, null) + public SystemAuthStrategy(IUnitWork unitWork, IRepository repository, DbExtension dbExtension) : base(unitWork, repository, null) { _dbExtension = dbExtension; _user = new User diff --git a/OpenAuth.App/AutofacExt.cs b/OpenAuth.App/AutofacExt.cs index bf37e6ad..12d19a98 100644 --- a/OpenAuth.App/AutofacExt.cs +++ b/OpenAuth.App/AutofacExt.cs @@ -41,8 +41,8 @@ namespace OpenAuth.App var builder = new ContainerBuilder(); //注册数据库基础操作和工作单元 - services.AddScoped(typeof(IRepository<>), typeof(BaseRepository<>)); - services.AddScoped(typeof(IUnitWork), typeof(UnitWork)); + services.AddScoped(typeof(IRepository<,>), typeof(BaseRepository<,>)); + services.AddScoped(typeof(IUnitWork<>), typeof(UnitWork<>)); //注入授权 builder.RegisterType(typeof(LocalAuth)).As(typeof(IAuth)); @@ -77,8 +77,8 @@ namespace OpenAuth.App { //注册数据库基础操作和工作单元 - builder.RegisterGeneric(typeof(BaseRepository<>)).As(typeof(IRepository<>)); - builder.RegisterType(typeof(UnitWork)).As(typeof(IUnitWork)); + builder.RegisterGeneric(typeof(BaseRepository<,>)).As(typeof(IRepository<,>)); + builder.RegisterGeneric(typeof(UnitWork<>)).As(typeof(IUnitWork<>)); //注入授权 builder.RegisterType(typeof(LocalAuth)).As(typeof(IAuth)); diff --git a/OpenAuth.App/BaseApp.cs b/OpenAuth.App/BaseApp.cs index 173361b1..96238a59 100644 --- a/OpenAuth.App/BaseApp.cs +++ b/OpenAuth.App/BaseApp.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using Infrastructure; +using Microsoft.EntityFrameworkCore; using OpenAuth.App.Interface; using OpenAuth.Repository.Core; using OpenAuth.Repository.Domain; @@ -13,22 +14,22 @@ namespace OpenAuth.App /// 如用户管理:Class UserManagerApp:BaseApp /// /// - public class BaseApp where T : Entity + public class BaseApp where T : Entity where TDbContext: DbContext { /// /// 用于普通的数据库操作 /// - protected IRepository Repository; + protected IRepository Repository; /// /// 用于事务操作 /// 使用详见:http://doc.openauth.me/core/unitwork.html /// - protected IUnitWork UnitWork; + protected IUnitWork UnitWork; protected IAuth _auth; - public BaseApp(IUnitWork unitWork, IRepository repository, IAuth auth) + public BaseApp(IUnitWork unitWork, IRepository repository, IAuth auth) { UnitWork = unitWork; Repository = repository; diff --git a/OpenAuth.App/BaseTreeApp.cs b/OpenAuth.App/BaseTreeApp.cs index 31297c99..099b3c89 100644 --- a/OpenAuth.App/BaseTreeApp.cs +++ b/OpenAuth.App/BaseTreeApp.cs @@ -1,4 +1,5 @@ using System.Linq; +using Microsoft.EntityFrameworkCore; using OpenAuth.App.Interface; using OpenAuth.Repository.Core; using OpenAuth.Repository.Interface; @@ -9,11 +10,11 @@ namespace OpenAuth.App /// 树状结构处理 /// /// - public class BaseTreeApp :BaseApp where T : TreeEntity + public class BaseTreeApp :BaseApp where T : TreeEntity where TDbContext :DbContext { - public BaseTreeApp(IUnitWork unitWork, IRepository repository, IAuth auth) + public BaseTreeApp(IUnitWork unitWork, IRepository repository, IAuth auth) : base(unitWork, repository,auth) { } diff --git a/OpenAuth.App/BuilderTableApp.cs b/OpenAuth.App/BuilderTableApp.cs index 56f7a926..72577765 100644 --- a/OpenAuth.App/BuilderTableApp.cs +++ b/OpenAuth.App/BuilderTableApp.cs @@ -16,6 +16,7 @@ using Microsoft.Extensions.Options; using OpenAuth.App.Interface; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Core; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; @@ -23,7 +24,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class BuilderTableApp : BaseApp + public class BuilderTableApp : BaseApp { private BuilderTableColumnApp _builderTableColumnApp; private CategoryApp _categoryApp; @@ -33,7 +34,7 @@ namespace OpenAuth.App private string _startName = ""; private IOptions _appConfiguration; - public BuilderTableApp(IUnitWork unitWork, IRepository repository, + public BuilderTableApp(IUnitWork unitWork, IRepository repository, RevelanceManagerApp app, IAuth auth, DbExtension dbExtension, BuilderTableColumnApp builderTableColumnApp, IOptions appConfiguration, CategoryApp categoryApp) : base(unitWork, repository, auth) { diff --git a/OpenAuth.App/BuilderTableColumnApp.cs b/OpenAuth.App/BuilderTableColumnApp.cs index 8b7994a8..3dce69ac 100644 --- a/OpenAuth.App/BuilderTableColumnApp.cs +++ b/OpenAuth.App/BuilderTableColumnApp.cs @@ -6,15 +6,16 @@ using Infrastructure; using OpenAuth.App.Interface; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class BuilderTableColumnApp : BaseApp + public class BuilderTableColumnApp : BaseApp { - public BuilderTableColumnApp(IUnitWork unitWork, IRepository repository, + public BuilderTableColumnApp(IUnitWork unitWork, IRepository repository, IAuth auth) : base(unitWork, repository,auth) { } diff --git a/OpenAuth.App/CategoryApp.cs b/OpenAuth.App/CategoryApp.cs index 8b3a1537..cd8bb5e1 100644 --- a/OpenAuth.App/CategoryApp.cs +++ b/OpenAuth.App/CategoryApp.cs @@ -6,13 +6,14 @@ using Infrastructure; using OpenAuth.App.Interface; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class CategoryApp : BaseApp + public class CategoryApp : BaseApp { /// /// 加载列表 @@ -90,7 +91,7 @@ namespace OpenAuth.App return Repository.Find(u => u.TypeId == typeId).ToList(); } - public CategoryApp(IUnitWork unitWork, IRepository repository,IAuth auth) : base(unitWork, repository, auth) + public CategoryApp(IUnitWork unitWork, IRepository repository,IAuth auth) : base(unitWork, repository, auth) { } } diff --git a/OpenAuth.App/CategoryTypeApp.cs b/OpenAuth.App/CategoryTypeApp.cs index f75544d7..079a2084 100644 --- a/OpenAuth.App/CategoryTypeApp.cs +++ b/OpenAuth.App/CategoryTypeApp.cs @@ -6,13 +6,14 @@ using Infrastructure; using OpenAuth.App.Interface; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class CategoryTypeApp : BaseApp + public class CategoryTypeApp : BaseApp { private RevelanceManagerApp _revelanceApp; @@ -71,7 +72,7 @@ namespace OpenAuth.App return UnitWork.Find(null).ToList(); } - public CategoryTypeApp(IUnitWork unitWork, IRepository repository, + public CategoryTypeApp(IUnitWork unitWork, IRepository repository, RevelanceManagerApp app, IAuth auth) : base(unitWork, repository,auth) { _revelanceApp = app; diff --git a/OpenAuth.App/DataPrivilegeRuleApp.cs b/OpenAuth.App/DataPrivilegeRuleApp.cs index 9e3353ae..87544f5c 100644 --- a/OpenAuth.App/DataPrivilegeRuleApp.cs +++ b/OpenAuth.App/DataPrivilegeRuleApp.cs @@ -5,13 +5,14 @@ using Infrastructure; using OpenAuth.App.Interface; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class DataPrivilegeRuleApp : BaseApp + public class DataPrivilegeRuleApp : BaseApp { private RevelanceManagerApp _revelanceApp; /// @@ -78,7 +79,7 @@ namespace OpenAuth.App } - public DataPrivilegeRuleApp(IUnitWork unitWork, IRepository repository, + public DataPrivilegeRuleApp(IUnitWork unitWork, IRepository repository, RevelanceManagerApp app, IAuth auth) : base(unitWork, repository, auth) { _revelanceApp = app; diff --git a/OpenAuth.App/FileApp.cs b/OpenAuth.App/FileApp.cs index 50776e18..14b68273 100644 --- a/OpenAuth.App/FileApp.cs +++ b/OpenAuth.App/FileApp.cs @@ -12,6 +12,7 @@ using Microsoft.Extensions.Options; using OpenAuth.App.Interface; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; @@ -20,14 +21,14 @@ namespace OpenAuth.App /// /// 文件管理 /// - public class FileApp : BaseApp + public class FileApp : BaseApp { private ILogger _logger; private string _filePath; private string _dbFilePath; //数据库中的文件路径 private string _dbThumbnail; //数据库中的缩略图路径 - public FileApp(IOptions setOptions, IUnitWork unitWork, IRepository repository, + public FileApp(IOptions setOptions, IUnitWork unitWork, IRepository repository, ILogger logger, IAuth auth) : base(unitWork, repository, auth) { diff --git a/OpenAuth.App/FlowInstanceApp.cs b/OpenAuth.App/FlowInstanceApp.cs index 78dbbfcb..f03c7229 100644 --- a/OpenAuth.App/FlowInstanceApp.cs +++ b/OpenAuth.App/FlowInstanceApp.cs @@ -26,13 +26,14 @@ using System.Linq.Expressions; using System.Net.Http; using System.Threading.Tasks; using Infrastructure.Helpers; +using OpenAuth.Repository; namespace OpenAuth.App { /// /// 工作流实例表操作 /// - public class FlowInstanceApp : BaseApp + public class FlowInstanceApp : BaseApp { private RevelanceManagerApp _revelanceApp; private FlowSchemeApp _flowSchemeApp; @@ -551,7 +552,7 @@ namespace OpenAuth.App }); } - public FlowInstanceApp(IUnitWork unitWork, IRepository repository + public FlowInstanceApp(IUnitWork unitWork, IRepository repository , RevelanceManagerApp app, FlowSchemeApp flowSchemeApp, FormApp formApp, IHttpClientFactory httpClientFactory,IAuth auth, IServiceProvider serviceProvider) : base(unitWork, repository, auth) { diff --git a/OpenAuth.App/FlowSchemeApp.cs b/OpenAuth.App/FlowSchemeApp.cs index ed166723..a2578ecc 100644 --- a/OpenAuth.App/FlowSchemeApp.cs +++ b/OpenAuth.App/FlowSchemeApp.cs @@ -4,12 +4,13 @@ using System.Threading.Tasks; using OpenAuth.App.Interface; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class FlowSchemeApp :BaseApp + public class FlowSchemeApp :BaseApp { public void Add(FlowScheme flowScheme) { @@ -65,7 +66,7 @@ namespace OpenAuth.App return result; } - public FlowSchemeApp(IUnitWork unitWork, IRepository repository,IAuth auth) : base(unitWork, repository, auth) + public FlowSchemeApp(IUnitWork unitWork, IRepository repository,IAuth auth) : base(unitWork, repository, auth) { } } diff --git a/OpenAuth.App/FormApp.cs b/OpenAuth.App/FormApp.cs index 8f7d1ae6..2b180a7a 100644 --- a/OpenAuth.App/FormApp.cs +++ b/OpenAuth.App/FormApp.cs @@ -6,13 +6,14 @@ using Microsoft.Extensions.Options; using OpenAuth.App.Interface; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class FormApp : BaseApp
+ public class FormApp : BaseApp { private IAuth _auth; private IOptions _appConfiguration; @@ -76,7 +77,7 @@ namespace OpenAuth.App return form.MapTo(); } - public FormApp(IUnitWork unitWork, IRepository repository, + public FormApp(IUnitWork unitWork, IRepository repository, IAuth auth, IOptions appConfiguration) : base(unitWork, repository, auth) { _auth = auth; diff --git a/OpenAuth.App/FrmLeaveReqApp.cs b/OpenAuth.App/FrmLeaveReqApp.cs index f64ca87a..fe2517b3 100644 --- a/OpenAuth.App/FrmLeaveReqApp.cs +++ b/OpenAuth.App/FrmLeaveReqApp.cs @@ -3,13 +3,14 @@ using Infrastructure; using OpenAuth.App.Interface; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class FrmLeaveReqApp : BaseApp, ICustomerForm + public class FrmLeaveReqApp : BaseApp, ICustomerForm { private RevelanceManagerApp _revelanceApp; @@ -39,7 +40,7 @@ namespace OpenAuth.App } - public FrmLeaveReqApp(IUnitWork unitWork, IRepository repository, + public FrmLeaveReqApp(IUnitWork unitWork, IRepository repository, RevelanceManagerApp app,IAuth auth) : base(unitWork, repository, auth) { _revelanceApp = app; diff --git a/OpenAuth.App/ModuleManagerApp.cs b/OpenAuth.App/ModuleManagerApp.cs index bd2f14b7..b4fa303e 100644 --- a/OpenAuth.App/ModuleManagerApp.cs +++ b/OpenAuth.App/ModuleManagerApp.cs @@ -3,12 +3,13 @@ using System.Linq; using Infrastructure; using OpenAuth.App.Interface; using OpenAuth.App.Request; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class ModuleManagerApp : BaseTreeApp + public class ModuleManagerApp : BaseTreeApp { private RevelanceManagerApp _revelanceApp; @@ -172,7 +173,7 @@ namespace OpenAuth.App #endregion - public ModuleManagerApp(IUnitWork unitWork, IRepository repository + public ModuleManagerApp(IUnitWork unitWork, IRepository repository , RevelanceManagerApp app, IAuth auth) : base(unitWork, repository, auth) { _revelanceApp = app; diff --git a/OpenAuth.App/OpenJobApp.cs b/OpenAuth.App/OpenJobApp.cs index 05d51f2d..a753750d 100644 --- a/OpenAuth.App/OpenJobApp.cs +++ b/OpenAuth.App/OpenJobApp.cs @@ -8,6 +8,7 @@ using OpenAuth.App.Interface; using OpenAuth.App.Jobs; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; using Quartz; @@ -15,7 +16,7 @@ using Quartz; namespace OpenAuth.App { - public class OpenJobApp : BaseApp + public class OpenJobApp : BaseApp { private SysLogApp _sysLogApp; private IScheduler _scheduler; @@ -171,7 +172,7 @@ namespace OpenAuth.App #endregion - public OpenJobApp(IUnitWork unitWork, IRepository repository, + public OpenJobApp(IUnitWork unitWork, IRepository repository, IAuth auth, SysLogApp sysLogApp, IScheduler scheduler, ILogger logger) : base(unitWork, repository, auth) { _sysLogApp = sysLogApp; diff --git a/OpenAuth.App/OrgManagerApp.cs b/OpenAuth.App/OrgManagerApp.cs index f0a3cad2..39d42ed4 100644 --- a/OpenAuth.App/OrgManagerApp.cs +++ b/OpenAuth.App/OrgManagerApp.cs @@ -3,12 +3,13 @@ using System.Linq; using Infrastructure; using OpenAuth.App.Interface; using OpenAuth.App.Request; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class OrgManagerApp : BaseTreeApp + public class OrgManagerApp : BaseTreeApp { private RevelanceManagerApp _revelanceApp; /// @@ -81,7 +82,7 @@ namespace OpenAuth.App return result.ToList(); } - public OrgManagerApp(IUnitWork unitWork, IRepository repository,IAuth auth, + public OrgManagerApp(IUnitWork unitWork, IRepository repository,IAuth auth, RevelanceManagerApp revelanceApp) : base(unitWork, repository, auth) { _revelanceApp = revelanceApp; diff --git a/OpenAuth.App/ResourceApp.cs b/OpenAuth.App/ResourceApp.cs index da2946ad..3e3c692b 100644 --- a/OpenAuth.App/ResourceApp.cs +++ b/OpenAuth.App/ResourceApp.cs @@ -6,6 +6,7 @@ using Infrastructure; using OpenAuth.App.Interface; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; @@ -14,7 +15,7 @@ namespace OpenAuth.App /// /// 分类管理 /// - public class ResourceApp:BaseApp + public class ResourceApp:BaseApp { private RevelanceManagerApp _revelanceApp; @@ -85,7 +86,7 @@ namespace OpenAuth.App return result; } - public ResourceApp(IUnitWork unitWork, IRepository repository + public ResourceApp(IUnitWork unitWork, IRepository repository ,RevelanceManagerApp app,IAuth auth) : base(unitWork, repository, auth) { _revelanceApp = app; diff --git a/OpenAuth.App/RevelanceManagerApp.cs b/OpenAuth.App/RevelanceManagerApp.cs index e1940104..46c83595 100644 --- a/OpenAuth.App/RevelanceManagerApp.cs +++ b/OpenAuth.App/RevelanceManagerApp.cs @@ -4,15 +4,16 @@ using System.Linq; using Microsoft.Extensions.Logging; using OpenAuth.App.Interface; using OpenAuth.App.Request; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class RevelanceManagerApp : BaseApp + public class RevelanceManagerApp : BaseApp { private readonly ILogger _logger; - public RevelanceManagerApp(IUnitWork unitWork, IRepository repository, IAuth auth, ILogger logger) : base(unitWork, + public RevelanceManagerApp(IUnitWork unitWork, IRepository repository, IAuth auth, ILogger logger) : base(unitWork, repository, auth) { _logger = logger; diff --git a/OpenAuth.App/RoleApp.cs b/OpenAuth.App/RoleApp.cs index 557985e8..52638a9b 100644 --- a/OpenAuth.App/RoleApp.cs +++ b/OpenAuth.App/RoleApp.cs @@ -6,10 +6,11 @@ using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; using System.Linq; using OpenAuth.App.Request; +using OpenAuth.Repository; namespace OpenAuth.App { - public class RoleApp : BaseApp + public class RoleApp : BaseApp { private RevelanceManagerApp _revelanceApp; @@ -73,7 +74,7 @@ namespace OpenAuth.App } - public RoleApp(IUnitWork unitWork, IRepository repository, + public RoleApp(IUnitWork unitWork, IRepository repository, RevelanceManagerApp app,IAuth auth) : base(unitWork, repository, auth) { _revelanceApp = app; diff --git a/OpenAuth.App/SSO/LoginParse.cs b/OpenAuth.App/SSO/LoginParse.cs index 95678b03..c0ef160e 100644 --- a/OpenAuth.App/SSO/LoginParse.cs +++ b/OpenAuth.App/SSO/LoginParse.cs @@ -4,6 +4,7 @@ */ using System; using Infrastructure.Cache; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; @@ -14,11 +15,11 @@ namespace OpenAuth.App.SSO { //这个地方使用IRepository 而不使用UserManagerApp是防止循环依赖 - public IRepository _app; + public IRepository _app; private ICacheContext _cacheContext; private AppInfoService _appInfoService; - public LoginParse( AppInfoService infoService, ICacheContext cacheContext, IRepository userApp) + public LoginParse( AppInfoService infoService, ICacheContext cacheContext, IRepository userApp) { _appInfoService = infoService; _cacheContext = cacheContext; diff --git a/OpenAuth.App/SysLogApp.cs b/OpenAuth.App/SysLogApp.cs index 8ada043d..bec00b89 100644 --- a/OpenAuth.App/SysLogApp.cs +++ b/OpenAuth.App/SysLogApp.cs @@ -3,13 +3,14 @@ using System.Reflection; using System.Threading.Tasks; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class SysLogApp : BaseApp + public class SysLogApp : BaseApp { /// @@ -47,7 +48,7 @@ namespace OpenAuth.App } - public SysLogApp(IUnitWork unitWork, IRepository repository) : base(unitWork, repository, null) + public SysLogApp(IUnitWork unitWork, IRepository repository) : base(unitWork, repository, null) { } } diff --git a/OpenAuth.App/SysMessageApp.cs b/OpenAuth.App/SysMessageApp.cs index 97102cc7..e96d7084 100644 --- a/OpenAuth.App/SysMessageApp.cs +++ b/OpenAuth.App/SysMessageApp.cs @@ -4,13 +4,14 @@ using Infrastructure; using OpenAuth.App.Interface; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class SysMessageApp : BaseApp + public class SysMessageApp : BaseApp { private RevelanceManagerApp _revelanceApp; @@ -54,7 +55,7 @@ namespace OpenAuth.App } - public SysMessageApp(IUnitWork unitWork, IRepository repository, + public SysMessageApp(IUnitWork unitWork, IRepository repository, RevelanceManagerApp app,IAuth auth) : base(unitWork, repository, auth) { _revelanceApp = app; diff --git a/OpenAuth.App/Test/TestAsync.cs b/OpenAuth.App/Test/TestAsync.cs index 3eb0e335..97ac2718 100644 --- a/OpenAuth.App/Test/TestAsync.cs +++ b/OpenAuth.App/Test/TestAsync.cs @@ -8,6 +8,7 @@ using Moq; using NUnit.Framework; using OpenAuth.App.Request; using OpenAuth.App.SSO; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; @@ -48,7 +49,7 @@ namespace OpenAuth.App.Test private async Task AddOrUpdate() { - var repository = _autofacServiceProvider.GetService>(); + var repository = _autofacServiceProvider.GetService>(); var account = "user_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss"); diff --git a/OpenAuth.App/UserManagerApp.cs b/OpenAuth.App/UserManagerApp.cs index 33a5bd51..100e9900 100644 --- a/OpenAuth.App/UserManagerApp.cs +++ b/OpenAuth.App/UserManagerApp.cs @@ -7,18 +7,19 @@ using Infrastructure.Extensions; using OpenAuth.App.Interface; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class UserManagerApp : BaseApp + public class UserManagerApp : BaseApp { private RevelanceManagerApp _revelanceApp; private OrgManagerApp _orgManagerApp; - public UserManagerApp(IUnitWork unitWork, IRepository repository, + public UserManagerApp(IUnitWork unitWork, IRepository repository, RevelanceManagerApp app,IAuth auth, OrgManagerApp orgManagerApp) : base(unitWork, repository, auth) { _revelanceApp = app; diff --git a/OpenAuth.App/WmsInboundOrderDtblApp.cs b/OpenAuth.App/WmsInboundOrderDtblApp.cs index 3c1b9a1c..57d075b3 100644 --- a/OpenAuth.App/WmsInboundOrderDtblApp.cs +++ b/OpenAuth.App/WmsInboundOrderDtblApp.cs @@ -5,13 +5,14 @@ using Infrastructure; using OpenAuth.App.Interface; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class WmsInboundOrderDtblApp : BaseApp + public class WmsInboundOrderDtblApp : BaseApp { private RevelanceManagerApp _revelanceApp; private DbExtension _dbExtension; @@ -99,7 +100,7 @@ namespace OpenAuth.App } - public WmsInboundOrderDtblApp(IUnitWork unitWork, IRepository repository, + public WmsInboundOrderDtblApp(IUnitWork unitWork, IRepository repository, RevelanceManagerApp app, IAuth auth, DbExtension dbExtension) : base(unitWork, repository,auth) { _dbExtension = dbExtension; diff --git a/OpenAuth.App/WmsInboundOrderTblApp.cs b/OpenAuth.App/WmsInboundOrderTblApp.cs index 7cb88501..9b23ad70 100644 --- a/OpenAuth.App/WmsInboundOrderTblApp.cs +++ b/OpenAuth.App/WmsInboundOrderTblApp.cs @@ -5,13 +5,14 @@ using Infrastructure; using OpenAuth.App.Interface; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class WmsInboundOrderTblApp : BaseApp + public class WmsInboundOrderTblApp : BaseApp { private RevelanceManagerApp _revelanceApp; private WmsInboundOrderDtblApp _wmsInboundOrderDtblApp; @@ -130,7 +131,7 @@ namespace OpenAuth.App }); } - public WmsInboundOrderTblApp(IUnitWork unitWork, IRepository repository, + public WmsInboundOrderTblApp(IUnitWork unitWork, IRepository repository, RevelanceManagerApp app, IAuth auth, WmsInboundOrderDtblApp wmsInboundOrderDtblApp) : base(unitWork, repository, auth) { diff --git a/OpenAuth.Repository/BaseRepository.cs b/OpenAuth.Repository/BaseRepository.cs index f20dd832..d20f9132 100644 --- a/OpenAuth.Repository/BaseRepository.cs +++ b/OpenAuth.Repository/BaseRepository.cs @@ -11,11 +11,11 @@ using Z.EntityFramework.Plus; namespace OpenAuth.Repository { - public class BaseRepository : IRepository where T : BaseEntity + public class BaseRepository : IRepository where T : BaseEntity where TDbContext: DbContext { - private OpenAuthDBContext _context; + private TDbContext _context; - public BaseRepository(OpenAuthDBContext context) + public BaseRepository(TDbContext context) { _context = context; } diff --git a/OpenAuth.Repository/Interface/IRepository.cs b/OpenAuth.Repository/Interface/IRepository.cs index 318a57de..42c4eb91 100644 --- a/OpenAuth.Repository/Interface/IRepository.cs +++ b/OpenAuth.Repository/Interface/IRepository.cs @@ -16,10 +16,11 @@ using System; using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; namespace OpenAuth.Repository.Interface { - public interface IRepository where T : class + public interface IRepository where T : class where TDbContext: DbContext { /// /// 返回一个单独的实体,如果记录多于1个则取第一个 diff --git a/OpenAuth.Repository/Interface/IUnitWork.cs b/OpenAuth.Repository/Interface/IUnitWork.cs index 93aa8798..d85b2e21 100644 --- a/OpenAuth.Repository/Interface/IUnitWork.cs +++ b/OpenAuth.Repository/Interface/IUnitWork.cs @@ -6,13 +6,14 @@ // Last Modified By : yubaolee // Last Modified On : 12-15-2020 // Contact : Microsoft -// File: IUnitWork.cs +// File: IUnitWork.cs // *********************************************************************** using System; using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; using OpenAuth.Repository.Core; namespace OpenAuth.Repository.Interface @@ -25,7 +26,7 @@ namespace OpenAuth.Repository.Interface /// 2 需要多表联合查询 /// 因为架构采用的是EF访问数据库,暂时可以不用考虑采用传统Unit Work的注册机制 /// - public interface IUnitWork + public interface IUnitWork where TDbContext:DbContext { /// /// EF默认情况下,每调用一次SaveChanges()都会执行一个单独的事务 @@ -36,7 +37,7 @@ namespace OpenAuth.Repository.Interface /// 返回DbContext,用于多线程等极端情况 /// /// - OpenAuthDBContext GetDbContext(); + DbContext GetDbContext(); /// /// 返回一个单独的实体,如果记录多于1个则取第一个 /// diff --git a/OpenAuth.Repository/Test/TestBase.cs b/OpenAuth.Repository/Test/TestBase.cs index 1104fad0..a530c210 100644 --- a/OpenAuth.Repository/Test/TestBase.cs +++ b/OpenAuth.Repository/Test/TestBase.cs @@ -22,8 +22,8 @@ namespace OpenAuth.Repository.Test var serviceCollection = GetService(); serviceCollection.AddMemoryCache(); serviceCollection.AddOptions(); - serviceCollection.AddScoped(typeof(IRepository<>), typeof(BaseRepository<>)); - serviceCollection.AddScoped(typeof(IUnitWork), typeof(UnitWork)); + serviceCollection.AddScoped(typeof(IRepository<,>), typeof(BaseRepository<,>)); + serviceCollection.AddScoped(typeof(IUnitWork<>), typeof(UnitWork<>)); serviceCollection.AddDbContext(options => options.UseSqlServer("Data Source=.;Initial Catalog=OpenAuthDB;User=sa;Password=000000;Integrated Security=True")); diff --git a/OpenAuth.Repository/Test/TestDbContext.cs b/OpenAuth.Repository/Test/TestDbContext.cs index 30780b39..97cc9db0 100644 --- a/OpenAuth.Repository/Test/TestDbContext.cs +++ b/OpenAuth.Repository/Test/TestDbContext.cs @@ -83,7 +83,7 @@ namespace OpenAuth.Repository.Test Console.WriteLine(account); - var repository = _autofacServiceProvider.GetService>(); + var repository = _autofacServiceProvider.GetService>(); //新增 repository.Add(new User diff --git a/OpenAuth.Repository/Test/TestTransaction.cs b/OpenAuth.Repository/Test/TestTransaction.cs index fa488d76..72a3f9e6 100644 --- a/OpenAuth.Repository/Test/TestTransaction.cs +++ b/OpenAuth.Repository/Test/TestTransaction.cs @@ -17,7 +17,7 @@ namespace OpenAuth.Repository.Test [Test] public void NormalSubmit() { - var unitWork = _autofacServiceProvider.GetService(); + var unitWork = _autofacServiceProvider.GetService>(); unitWork.ExecuteWithTransaction(() => { var account = "user_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss"); @@ -33,7 +33,7 @@ namespace OpenAuth.Repository.Test [Test] public void SubmitWithRollback() { - var unitWork = _autofacServiceProvider.GetService(); + var unitWork = _autofacServiceProvider.GetService>(); var account = "user_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss"); try { @@ -57,7 +57,7 @@ namespace OpenAuth.Repository.Test /// /// 测试添加,单个修改,Z.EntityFramework.Plus条件修改 /// - private void AddAndUpdate(string account, IUnitWork unitWork) + private void AddAndUpdate(string account, IUnitWork unitWork) { var user = new User { diff --git a/OpenAuth.Repository/UnitWork.cs b/OpenAuth.Repository/UnitWork.cs index 3b4a3468..b1d51f5a 100644 --- a/OpenAuth.Repository/UnitWork.cs +++ b/OpenAuth.Repository/UnitWork.cs @@ -12,11 +12,11 @@ using Z.EntityFramework.Plus; namespace OpenAuth.Repository { - public class UnitWork: IUnitWork + public class UnitWork: IUnitWork where TDbContext: DbContext { - private OpenAuthDBContext _context; + private TDbContext _context; - public UnitWork(OpenAuthDBContext context) + public UnitWork(TDbContext context) { _context = context; } @@ -45,7 +45,7 @@ namespace OpenAuth.Repository /// /// 返回DbContext,用于多线程等极端情况 /// - public OpenAuthDBContext GetDbContext() + public DbContext GetDbContext() { return _context; } diff --git a/OpenAuth.WebApi/Template/BuildApp.html b/OpenAuth.WebApi/Template/BuildApp.html index 303de167..913a2ea8 100644 --- a/OpenAuth.WebApi/Template/BuildApp.html +++ b/OpenAuth.WebApi/Template/BuildApp.html @@ -1,16 +1,18 @@ using System; using System.Linq; +using System.Threading.Tasks; using Infrastructure; using OpenAuth.App.Interface; using OpenAuth.App.Request; using OpenAuth.App.Response; +using OpenAuth.Repository; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class {ModuleCode} : BaseApp<{ClassName}> + public class {ModuleCode} : BaseApp<{ClassName},OpenAuthDBContext> { /// @@ -64,7 +66,7 @@ namespace OpenAuth.App } - public {ModuleCode}(IUnitWork unitWork, IRepository<{ClassName}> repository, IAuth auth) : base(unitWork, repository, auth) + public {ModuleCode}(IUnitWork unitWork, IRepository<{ClassName},OpenAuthDBContext> repository, IAuth auth) : base(unitWork, repository, auth) { } } diff --git a/OpenAuth.WebApi/Template/BuildControllerApi.html b/OpenAuth.WebApi/Template/BuildControllerApi.html index a371084a..b5f0033c 100644 --- a/OpenAuth.WebApi/Template/BuildControllerApi.html +++ b/OpenAuth.WebApi/Template/BuildControllerApi.html @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using Infrastructure; using Microsoft.AspNetCore.Mvc; using OpenAuth.App; diff --git a/OpenAuth.WebApi/appsettings.Production.json b/OpenAuth.WebApi/appsettings.Production.json index 961aabce..9e1f30a5 100644 --- a/OpenAuth.WebApi/appsettings.Production.json +++ b/OpenAuth.WebApi/appsettings.Production.json @@ -1,7 +1,9 @@ { "Logging": { "LogLevel": { - "Default": "Information" + "Default": "Information", + "System": "Error", + "Microsoft": "Error" } }, "AllowedHosts": "*",