mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-08-24 16:18:45 +08:00
同步OpenAuth.Core
修复mvc三级菜单; Reposiroty单元测试读取webapi配置文件; 修复日志打印2次;
This commit is contained in:
parent
ecc32d4173
commit
679dc613c1
@ -126,6 +126,14 @@ namespace OpenAuth.App
|
|||||||
public List<KeyDescription> GetProperties(string moduleCode)
|
public List<KeyDescription> GetProperties(string moduleCode)
|
||||||
{
|
{
|
||||||
var allprops = _dbExtension.GetProperties(moduleCode);
|
var allprops = _dbExtension.GetProperties(moduleCode);
|
||||||
|
|
||||||
|
//如果是系统模块,直接返回所有字段。防止开发者把模块配置成系统模块,还在外层调用loginContext.GetProperties("xxxx");
|
||||||
|
bool? isSysModule = UnitWork.FirstOrDefault<Module>(u => u.Code == moduleCode)?.IsSys;
|
||||||
|
if (isSysModule!= null && isSysModule.Value)
|
||||||
|
{
|
||||||
|
return allprops;
|
||||||
|
}
|
||||||
|
|
||||||
var props =UnitWork.Find<Relevance>(u =>
|
var props =UnitWork.Find<Relevance>(u =>
|
||||||
u.Key == Define.ROLEDATAPROPERTY && _userRoleIds.Contains(u.FirstId) && u.SecondId == moduleCode)
|
u.Key == Define.ROLEDATAPROPERTY && _userRoleIds.Contains(u.FirstId) && u.SecondId == moduleCode)
|
||||||
.Select(u => u.ThirdId);
|
.Select(u => u.ThirdId);
|
||||||
|
@ -98,7 +98,7 @@ namespace OpenAuth.App
|
|||||||
UnitWork.Add(flowInstance);
|
UnitWork.Add(flowInstance);
|
||||||
wfruntime.flowInstanceId = flowInstance.Id;
|
wfruntime.flowInstanceId = flowInstance.Id;
|
||||||
|
|
||||||
if (flowInstance.FrmType == 1)
|
if (flowInstance.FrmType == 1) //如果是开发者自定义的表单
|
||||||
{
|
{
|
||||||
var t = Type.GetType("OpenAuth.App."+ flowInstance.DbName +"App");
|
var t = Type.GetType("OpenAuth.App."+ flowInstance.DbName +"App");
|
||||||
ICustomerForm icf = (ICustomerForm) _serviceProvider.GetService(t);
|
ICustomerForm icf = (ICustomerForm) _serviceProvider.GetService(t);
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
namespace OpenAuth.App.Interface
|
namespace OpenAuth.App.Interface
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 开发者自定义表单的统一接口
|
||||||
|
/// <para>例如:FrmLeaveReqApp为请假表单对应的应用层,实现该接口,可以自动向数据库中插入对应的记录</para>
|
||||||
|
/// </summary>
|
||||||
public interface ICustomerForm
|
public interface ICustomerForm
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 该接口定义自定义表单模式时需实现向数据库写入表单数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="flowInstanceId">表单对应的流程实例ID</param>
|
||||||
|
/// <param name="frmData">表单数据</param>
|
||||||
void Add(string flowInstanceId, string frmData);
|
void Add(string flowInstanceId, string frmData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,6 @@ namespace OpenAuth.Mvc
|
|||||||
.ConfigureLogging((hostingContext, logging) =>
|
.ConfigureLogging((hostingContext, logging) =>
|
||||||
{
|
{
|
||||||
logging.ClearProviders(); //去掉默认的日志
|
logging.ClearProviders(); //去掉默认的日志
|
||||||
logging.AddFilter("System", LogLevel.Error);
|
|
||||||
logging.AddFilter("Microsoft", LogLevel.Error);
|
|
||||||
logging.AddLog4Net();
|
|
||||||
})
|
})
|
||||||
.UseServiceProviderFactory(new AutofacServiceProviderFactory()) //将默认ServiceProviderFactory指定为AutofacServiceProviderFactory
|
.UseServiceProviderFactory(new AutofacServiceProviderFactory()) //将默认ServiceProviderFactory指定为AutofacServiceProviderFactory
|
||||||
.ConfigureWebHostDefaults(webBuilder =>
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
|
@ -109,8 +109,10 @@ namespace OpenAuth.Mvc
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IHostEnvironment env)
|
public void Configure(IApplicationBuilder app, IHostEnvironment env, ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
|
loggerFactory.AddLog4Net();
|
||||||
|
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Debug",
|
"Default": "Debug",
|
||||||
"System": "Information",
|
"System": "Error",
|
||||||
"Microsoft": "Information"
|
"Microsoft": "Error",
|
||||||
|
"Microsoft.EntityFrameworkCore.Database.Command": "Information"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,3 +202,11 @@
|
|||||||
.top_menu .layui-nav-item.showNotice[pc]{ display:none !important; }
|
.top_menu .layui-nav-item.showNotice[pc]{ display:none !important; }
|
||||||
.panel{ width:100%; }
|
.panel{ width:100%; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ol li a {
|
||||||
|
background-color: rgba(0,0,0,1) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.three_this {
|
||||||
|
background-color: #808080 !important;
|
||||||
|
}
|
@ -11,6 +11,22 @@ layui.config({
|
|||||||
url: "/UserSession/GetModulesTree" //获取菜单json地址
|
url: "/UserSession/GetModulesTree" //获取菜单json地址
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".menu_three").on("click", function () {
|
||||||
|
|
||||||
|
$(this).next().toggle();
|
||||||
|
$.each($(this).parent().siblings(), function (i, e) {
|
||||||
|
|
||||||
|
$(e).find("ol").hide();;
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
|
$("ol").on("click", "li a", function () {
|
||||||
|
$.each($(this).parent().siblings(), function (i, e) {
|
||||||
|
$(e).find("a").removeClass('three_this')
|
||||||
|
});
|
||||||
|
$(this).addClass('three_this'); // 添加当前元素的样式
|
||||||
|
})
|
||||||
|
|
||||||
$.get('/UserSession/GetUserName',
|
$.get('/UserSession/GetUserName',
|
||||||
function(data) {
|
function(data) {
|
||||||
$("#username").html(data);
|
$("#username").html(data);
|
||||||
|
@ -32,7 +32,37 @@ function navBar(strData){
|
|||||||
if(data[i].Children[j].Item.IconName != undefined && data[i].Children[j].Item.IconName != ''){
|
if(data[i].Children[j].Item.IconName != undefined && data[i].Children[j].Item.IconName != ''){
|
||||||
ulHtml += '<i class="layui-icon '+ data[i].Children[j].Item.IconName +'"></i>'
|
ulHtml += '<i class="layui-icon '+ data[i].Children[j].Item.IconName +'"></i>'
|
||||||
}
|
}
|
||||||
ulHtml += '<cite>'+data[i].Children[j].Item.Name+'</cite></a></dd>';
|
ulHtml += '<cite>' + data[i].Children[j].Item.Name + '</cite></a>';
|
||||||
|
|
||||||
|
if (data[i].Children[j].Children != undefined && data[i].Children[j].Children.length > 0) {
|
||||||
|
|
||||||
|
let idx = 0;
|
||||||
|
for (var k = 0; k < data[i].Children[j].Children.length; k++) {
|
||||||
|
|
||||||
|
if (data[i].Children[j].Children[k].Item.Status === -1) continue;
|
||||||
|
|
||||||
|
idx++;
|
||||||
|
|
||||||
|
if (idx == 1) {
|
||||||
|
ulHtml += '<ol class="layui-nav-child">';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data[i].Children[j].Children[k].target == "_blank") {
|
||||||
|
ulHtml += '<li><a href="javascript:;" data-url="' + data[i].Children[j].Children[k].Item.Url + '" target="' + data[i].Children[j].Children[k].target + '">';
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ulHtml += '<li><a href="javascript:;" data-url="' + data[i].Children[j].Children[k].Item.Url + '">';
|
||||||
|
}
|
||||||
|
if (data[i].Children[j].Children[k].Item.IconName != undefined && data[i].Children[j].Children[k].Item.IconName != '') {
|
||||||
|
ulHtml += ' <i class="layui-icon ' + data[i].Children[j].Children[k].Item.IconName + '"></i>'
|
||||||
|
}
|
||||||
|
ulHtml += '<cite>' + data[i].Children[j].Children[k].Item.Name + '</cite></a ></li > ';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (idx > 0) {
|
||||||
|
ulHtml += '</ol>';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ulHtml += "</dl>";
|
ulHtml += "</dl>";
|
||||||
}else{
|
}else{
|
||||||
|
@ -105,8 +105,10 @@ namespace OpenAuth.Repository.Domain
|
|||||||
public string FrmData { get; set; }
|
public string FrmData { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 表单类型
|
/// 表单类型
|
||||||
|
/// <para>0:动态表单;1:开发者自定义表单;2:拖动表单</para>
|
||||||
|
/// <para>当类型为1时,流程实例必需有DbName,用于直接向对应数据库表中写入数据</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("表单类型")]
|
[Description("表单类型:0:动态表单;1:开发者自定义表单;2:拖动表单")]
|
||||||
public int FrmType { get; set; }
|
public int FrmType { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 表单中的控件属性描述
|
/// 表单中的控件属性描述
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using System.Reflection;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Extensions.DependencyInjection;
|
using Autofac.Extensions.DependencyInjection;
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
@ -6,6 +8,7 @@ using Microsoft.AspNetCore.Http;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
@ -32,14 +35,27 @@ namespace OpenAuth.Repository.Test
|
|||||||
serviceCollection.AddScoped(typeof(IUnitWork<>), typeof(UnitWork<>));
|
serviceCollection.AddScoped(typeof(IUnitWork<>), typeof(UnitWork<>));
|
||||||
|
|
||||||
//模拟配置文件
|
//模拟配置文件
|
||||||
var optionMock = new Mock<IOptions<AppSetting>>();
|
//读取OpenAuth.WebApi的配置文件用于单元测试
|
||||||
optionMock.Setup(x => x.Value).Returns(new AppSetting { DbType = Define.DBTYPE_MYSQL });
|
var path = AppContext.BaseDirectory;
|
||||||
serviceCollection.AddScoped(x => optionMock.Object);
|
int pos = path.IndexOf("OpenAuth.Repository");
|
||||||
|
var basepath = Path.Combine(path.Substring(0,pos) ,"OpenAuth.WebApi");
|
||||||
|
IConfiguration config = new ConfigurationBuilder()
|
||||||
|
.SetBasePath(basepath)
|
||||||
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||||
|
.AddJsonFile("appsettings.Development.json", optional: true)
|
||||||
|
.AddEnvironmentVariables()
|
||||||
|
.Build();
|
||||||
|
Console.WriteLine($"单元测试数据库信息:{config.GetSection("AppSetting")["DbType"]}/{config.GetSection("ConnectionStrings")["OpenAuthDBContext"]}");
|
||||||
|
|
||||||
|
//添加log4net
|
||||||
|
serviceCollection.AddLogging(builder =>
|
||||||
|
{
|
||||||
|
builder.ClearProviders(); //去掉默认的日志
|
||||||
|
builder.AddConfiguration(config.GetSection("Logging")); //读取配置文件中的Logging配置
|
||||||
|
});
|
||||||
|
//注入OpenAuth.WebApi配置文件
|
||||||
|
serviceCollection.AddScoped(x => config);
|
||||||
|
|
||||||
//模拟多租户id
|
|
||||||
var configMock = new Mock<IConfiguration>();
|
|
||||||
configMock.Setup(x => x.GetSection("ConnectionStrings")[Define.TENANT_ID]).Returns("");
|
|
||||||
serviceCollection.AddScoped(x => configMock.Object);
|
|
||||||
|
|
||||||
var httpContextAccessorMock = new Mock<IHttpContextAccessor>();
|
var httpContextAccessorMock = new Mock<IHttpContextAccessor>();
|
||||||
httpContextAccessorMock.Setup(x => x.HttpContext.Request.Query[Define.TOKEN_NAME]).Returns("tokentest");
|
httpContextAccessorMock.Setup(x => x.HttpContext.Request.Query[Define.TOKEN_NAME]).Returns("tokentest");
|
||||||
@ -47,8 +63,7 @@ namespace OpenAuth.Repository.Test
|
|||||||
|
|
||||||
serviceCollection.AddScoped(x => httpContextAccessorMock.Object);
|
serviceCollection.AddScoped(x => httpContextAccessorMock.Object);
|
||||||
|
|
||||||
serviceCollection.AddDbContext<OpenAuthDBContext>(options =>
|
serviceCollection.AddDbContext<OpenAuthDBContext>();
|
||||||
options.UseSqlServer("Data Source=.;Initial Catalog=OpenAuthDB;User=sa;Password=000000;Integrated Security=True"));
|
|
||||||
|
|
||||||
var builder = new ContainerBuilder();
|
var builder = new ContainerBuilder();
|
||||||
|
|
||||||
|
@ -82,5 +82,22 @@ namespace OpenAuth.Repository.Test
|
|||||||
Account = "Trans2_" + user.Account
|
Account = "Trans2_" + user.Account
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MultiUpdate()
|
||||||
|
{
|
||||||
|
var unitWork = _autofacServiceProvider.GetService<IUnitWork<OpenAuthDBContext>>();
|
||||||
|
|
||||||
|
var users = unitWork.Find<User>(u => u.Account.Contains("test"));
|
||||||
|
foreach (var user in users)
|
||||||
|
{
|
||||||
|
user.Name = "user_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss");
|
||||||
|
unitWork.Update(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
unitWork.Save();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ namespace OpenAuth.WebApi
|
|||||||
.ConfigureLogging((hostingContext, logging) =>
|
.ConfigureLogging((hostingContext, logging) =>
|
||||||
{
|
{
|
||||||
logging.ClearProviders(); //去掉默认的日志
|
logging.ClearProviders(); //去掉默认的日志
|
||||||
logging.AddLog4Net();
|
// logging.AddLog4Net();
|
||||||
})
|
})
|
||||||
.UseServiceProviderFactory(
|
.UseServiceProviderFactory(
|
||||||
new AutofacServiceProviderFactory()) //将默认ServiceProviderFactory指定为AutofacServiceProviderFactory
|
new AutofacServiceProviderFactory()) //将默认ServiceProviderFactory指定为AutofacServiceProviderFactory
|
||||||
|
Loading…
Reference in New Issue
Block a user