diff --git a/Infrastructure/Define.cs b/Infrastructure/Define.cs
index 1e2bc4a5..8101ed5d 100644
--- a/Infrastructure/Define.cs
+++ b/Infrastructure/Define.cs
@@ -10,7 +10,8 @@
public const string ROLEDATAPROPERTY = "RoleDataProperty"; //角色数据字段权限
public const string DBTYPE_SQLSERVER = "SqlServer"; //sql server
- public const string DBTYPE_MYSQL = "MySql"; //sql server
+ public const string DBTYPE_MYSQL = "MySql"; //mysql
+ public const string DBTYPE_ORACLE = "Oracle"; //oracle
public const int INVALID_TOKEN = 50014; //token无效
diff --git a/OpenAuth.App/AppManager/AppManager.cs b/OpenAuth.App/AppManager/AppManager.cs
index 083abbd4..55024252 100644
--- a/OpenAuth.App/AppManager/AppManager.cs
+++ b/OpenAuth.App/AppManager/AppManager.cs
@@ -13,14 +13,19 @@ namespace OpenAuth.App
///
/// 分类管理
///
- public class AppManager : BaseStringApp
+ public class AppManager : BaseStringApp
{
+ public AppManager(IUnitWork unitWork, IRepository repository) : base(unitWork, repository, null)
+ {
+ }
+
public void Add(Application Application)
{
if (string.IsNullOrEmpty(Application.Id))
{
Application.Id = Guid.NewGuid().ToString();
}
+
Repository.Add(Application);
}
@@ -32,13 +37,15 @@ namespace OpenAuth.App
public async Task> GetList(QueryAppListReq request)
{
- var applications = UnitWork.Find(null) ;
-
+ var applications = UnitWork.Find(null);
+
return applications.ToList();
}
- public AppManager(IUnitWork unitWork, IRepository repository,IAuth auth) : base(unitWork, repository, auth)
+
+ public Application GetByAppKey(string modelAppKey)
{
+ return Repository.FirstOrDefault(u => u.AppSecret == modelAppKey);
}
}
}
\ No newline at end of file
diff --git a/OpenAuth.App/SSO/LoginParse.cs b/OpenAuth.App/SSO/LoginParse.cs
index 5e92cd9e..1e5e7bea 100644
--- a/OpenAuth.App/SSO/LoginParse.cs
+++ b/OpenAuth.App/SSO/LoginParse.cs
@@ -18,9 +18,9 @@ namespace OpenAuth.App.SSO
//这个地方使用IRepository 而不使用UserManagerApp是防止循环依赖
public IRepository _app;
private ICacheContext _cacheContext;
- private AppInfoService _appInfoService;
+ private AppManager _appInfoService;
- public LoginParse( AppInfoService infoService, ICacheContext cacheContext, IRepository userApp)
+ public LoginParse( AppManager infoService, ICacheContext cacheContext, IRepository userApp)
{
_appInfoService = infoService;
_cacheContext = cacheContext;
@@ -33,12 +33,12 @@ namespace OpenAuth.App.SSO
try
{
model.Trim();
- //获取应用信息
- var appInfo = _appInfoService.Get(model.AppKey);
- if (appInfo == null)
- {
- throw new Exception("应用不存在");
- }
+ //todo:如果需要判定应用,可以取消该注释
+ // var appInfo = _appInfoService.GetByAppKey(model.AppKey);
+ // if (appInfo == null)
+ // {
+ // throw new Exception("应用不存在");
+ // }
//获取用户信息
User userInfo = null;
if (model.Account == Define.SYSTEM_USERNAME)
@@ -84,7 +84,6 @@ namespace OpenAuth.App.SSO
_cacheContext.Set(currentSession.Token, currentSession, DateTime.Now.AddDays(10));
result.Code = 200;
- result.ReturnUrl = appInfo.ReturnUrl;
result.Token = currentSession.Token;
}
catch (Exception ex)
diff --git a/OpenAuth.App/SSO/PassportLoginRequest.cs b/OpenAuth.App/SSO/PassportLoginRequest.cs
index bda83447..4d25b309 100644
--- a/OpenAuth.App/SSO/PassportLoginRequest.cs
+++ b/OpenAuth.App/SSO/PassportLoginRequest.cs
@@ -9,6 +9,9 @@ namespace OpenAuth.App.SSO
public string Password { get; set; }
+ ///
+ /// 应用的AppSecrect,目前没判定可以随便填一个。如果需要判定请根据注释调整LoginParse.Do方法
+ ///
public string AppKey { get; set; }
public void Trim()
diff --git a/OpenAuth.Identity/Startup.cs b/OpenAuth.Identity/Startup.cs
index 0f1e241a..53302c6c 100644
--- a/OpenAuth.Identity/Startup.cs
+++ b/OpenAuth.Identity/Startup.cs
@@ -77,11 +77,16 @@ namespace OpenAuth.IdentityServer
services.AddDbContext(options =>
options.UseSqlServer(Configuration.GetConnectionString("OpenAuthDBContext")));
}
- else //mysql
+ else if(dbType == Define.DBTYPE_MYSQL) //mysql
{
services.AddDbContext(options =>
options.UseMySql(Configuration.GetConnectionString("OpenAuthDBContext")));
}
+ else //oracle
+ {
+ services.AddDbContext(options =>
+ options.UseOracle(Configuration.GetConnectionString("OpenAuthDBContext")));
+ }
}
diff --git a/OpenAuth.Repository/OpenAuth.Repository.csproj b/OpenAuth.Repository/OpenAuth.Repository.csproj
index 9a8c5188..b6a9d7a0 100644
--- a/OpenAuth.Repository/OpenAuth.Repository.csproj
+++ b/OpenAuth.Repository/OpenAuth.Repository.csproj
@@ -11,6 +11,7 @@
+
@@ -19,6 +20,8 @@
+
+
diff --git a/OpenAuth.Repository/OpenAuthDBContext.cs b/OpenAuth.Repository/OpenAuthDBContext.cs
index 9976fd2a..db8d01b6 100644
--- a/OpenAuth.Repository/OpenAuthDBContext.cs
+++ b/OpenAuth.Repository/OpenAuthDBContext.cs
@@ -70,10 +70,14 @@ namespace OpenAuth.Repository
{
optionsBuilder.UseSqlServer(connect);
}
- else //mysql
+ else if(dbType == Define.DBTYPE_MYSQL) //mysql
{
optionsBuilder.UseMySql(connect);
}
+ else
+ {
+ optionsBuilder.UseOracle(connect);
+ }
}
diff --git a/OpenAuth.Repository/Test/TestTransaction.cs b/OpenAuth.Repository/Test/TestTransaction.cs
index ec5c592e..5a9688e6 100644
--- a/OpenAuth.Repository/Test/TestTransaction.cs
+++ b/OpenAuth.Repository/Test/TestTransaction.cs
@@ -1,4 +1,5 @@
using System;
+using System.Linq;
using NUnit.Framework;
using Microsoft.Extensions.DependencyInjection;
using OpenAuth.Repository.Domain;
@@ -99,5 +100,31 @@ namespace OpenAuth.Repository.Test
unitWork.Save();
}
+
+ [Test]
+ public void MultiUpdate2()
+ {
+ var unitWork = _autofacServiceProvider.GetService>();
+ var users = unitWork.Find(null).ToList();
+ unitWork.ExecuteWithTransaction(()=>
+ {
+ foreach (var req in users)
+ {
+ unitWork.Update(u =>u.Id == req.Id, user => new User
+ {
+ Name = "user_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss")
+ });
+
+
+ unitWork.Update(u => u.Id == "08f41bf6-4388-4b1e-bd3e-2ff538b44b1b", u => new Org
+ {
+ CreateTime = DateTime.Now
+ });
+ }
+
+ unitWork.Save();
+ });
+
+ }
}
}
\ No newline at end of file
diff --git a/OpenAuth.WebApi/appsettings.Production.json b/OpenAuth.WebApi/appsettings.Production.json
index 656d8ba8..7bfa8fc4 100644
--- a/OpenAuth.WebApi/appsettings.Production.json
+++ b/OpenAuth.WebApi/appsettings.Production.json
@@ -14,7 +14,7 @@
"AppSetting": {
"IdentityServerUrl": "", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
//"IdentityServerUrl": "http://demo.openauth.me:12796", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
- "DbType": "MySql", //数据库类型:SqlServer、MySql
+ "DbType": "MySql", //数据库类型:SqlServer、MySql、Oracle
"UploadPath": "", //附件上传的路径,如果为空则保存在站点根目录
"RedisConf": "your_redis_server:6379,password=your_redis_password" //redis配置信息
}
diff --git a/OpenAuth.WebApi/appsettings.json b/OpenAuth.WebApi/appsettings.json
index bc1564f1..de96ba35 100644
--- a/OpenAuth.WebApi/appsettings.json
+++ b/OpenAuth.WebApi/appsettings.json
@@ -8,12 +8,13 @@
"DataProtection": "temp-keys/",
"ConnectionStrings": {
"OpenAuthDBContext": "Data Source=.;Initial Catalog=OpenAuthDB;User=sa;Password=000000"
+ //"OpenAuthDBContext": "DATA SOURCE=192.168.0.118:1521/YUBAO;PASSWORD=000000;Validate Connection=true;PERSIST SECURITY INFO=True;USER ID=yubaolee;" //Oracle
//"OpenAuthDBContext": "server=127.0.0.1;user id=root;database=openauthdb;password=000000" //my sql
},
"AppSetting": {
"IdentityServerUrl": "", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
// "IdentityServerUrl": "http://localhost:12796", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
- "DbType": "SqlServer", //数据库类型:SqlServer、MySql
+ "DbType": "SqlServer", //数据库类型:SqlServer、MySql、Oracle
"UploadPath": "", //附件上传的路径,如果为空则保存在站点根目录
"RedisConf": "redistest.cq-p.com.cn:8001,password=share_redis@123"
}