修复SqlSugarSetup类名修改后,nlog不打印日志问题,日期时间转换类增加格式,暂存区块和字段关联
This commit is contained in:
parent
e6dae7d1e2
commit
28c53b71ce
@ -170,7 +170,7 @@ namespace Infrastructure.Extensions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return bool.Parse(str.ToString());
|
return bool.Parse(str.ToString() ?? string.Empty);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -284,6 +284,9 @@ namespace Infrastructure.Extensions
|
|||||||
return DateTime.ParseExact(str, "yyyyMMddHH", System.Globalization.CultureInfo.CurrentCulture);
|
return DateTime.ParseExact(str, "yyyyMMddHH", System.Globalization.CultureInfo.CurrentCulture);
|
||||||
case 12:
|
case 12:
|
||||||
return DateTime.ParseExact(str, "yyyyMMddHHmm", System.Globalization.CultureInfo.CurrentCulture);
|
return DateTime.ParseExact(str, "yyyyMMddHHmm", System.Globalization.CultureInfo.CurrentCulture);
|
||||||
|
case 13:
|
||||||
|
return DateTime.ParseExact(str, "yyyy.MM.dd ddd",
|
||||||
|
System.Globalization.CultureInfo.CurrentCulture);
|
||||||
case 14:
|
case 14:
|
||||||
return DateTime.ParseExact(str, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);
|
return DateTime.ParseExact(str, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using ZR.Admin.WebApi.Filters;
|
using ZR.Admin.WebApi.Filters;
|
||||||
|
using ZR.ServiceCore.Model;
|
||||||
using ZR.ServiceCore.Model.Dto;
|
using ZR.ServiceCore.Model.Dto;
|
||||||
using ZR.ServiceCore.Services.IService;
|
using ZR.ServiceCore.Services.IService;
|
||||||
|
|
||||||
@ -47,4 +48,27 @@ public class SysFieldController : BaseController
|
|||||||
[FromRoute] long roleId)
|
[FromRoute] long roleId)
|
||||||
=> SUCCESS(await _sysRoleFieldService.InsertOrUpdateSysRoleField(sysFieldDtos, roleId));
|
=> SUCCESS(await _sysRoleFieldService.InsertOrUpdateSysRoleField(sysFieldDtos, roleId));
|
||||||
|
|
||||||
|
[HttpPost("fieldDisplay")]
|
||||||
|
public async Task<IActionResult> FieldDisplay(string blockCode)
|
||||||
|
{
|
||||||
|
var info = JwtUtil.GetLoginUser(HttpContext);
|
||||||
|
var roleIds = info.Roles.Select(it => it.RoleId).ToList();
|
||||||
|
var list = await _sysFieldService.Queryable()
|
||||||
|
.LeftJoin<SysFieldBlock>((sf, sfb) => sf.Id == sfb.FieldId)
|
||||||
|
.LeftJoin<SysBlock>((sf, sfb, sb) => sfb.BlockId == sb.Id )
|
||||||
|
.LeftJoin<SysRoleField>((sf,sfb, sb, srf) => sf.Id == srf.FieldId)
|
||||||
|
.Where((sf,sfb, sb, srf) => roleIds.Contains(srf.RoleId))
|
||||||
|
.Where((sf,sfb, sb, srf) => sb.Code == blockCode)
|
||||||
|
.WithCache(10 * 60)
|
||||||
|
.Select((sf,sfb, sb, srf) => sf.FieldName)
|
||||||
|
.ToListAsync();
|
||||||
|
// var list = await _sysFieldService.Queryable()
|
||||||
|
// .LeftJoin<SysRoleField>((sf, srf) => sf.Id == srf.FieldId)
|
||||||
|
// .Where((sf, srf) => roleIds.Contains(srf.RoleId))
|
||||||
|
// .WithCache(10 * 60)
|
||||||
|
// .Select((sf, srf) => sf.FieldName)
|
||||||
|
// .ToListAsync();
|
||||||
|
return SUCCESS(list);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,9 +1,7 @@
|
|||||||
using Lazy.Captcha.Core;
|
using Lazy.Captcha.Core;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using NETCore.Encrypt;
|
using NETCore.Encrypt;
|
||||||
using ZR.Admin.WebApi.Filters;
|
using ZR.Admin.WebApi.Filters;
|
||||||
using ZR.Model.System;
|
|
||||||
using ZR.Service.System;
|
using ZR.Service.System;
|
||||||
using ZR.Service.System.IService;
|
using ZR.Service.System.IService;
|
||||||
using ZR.ServiceCore.Model;
|
using ZR.ServiceCore.Model;
|
||||||
@ -66,8 +64,11 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
{
|
{
|
||||||
if (loginBody == null) { throw new CustomException("请求参数错误"); }
|
if (loginBody == null) { throw new CustomException("请求参数错误"); }
|
||||||
loginBody.LoginIP = HttpContextExtension.GetClientUserIp(HttpContext);
|
loginBody.LoginIP = HttpContextExtension.GetClientUserIp(HttpContext);
|
||||||
SysConfig sysConfig = sysConfigService.GetSysConfigByKey("sys.account.captchaOnOff");
|
var sysConfig = sysConfigService.GetSysConfigByKey("sys.account.captchaOnOff");
|
||||||
if (sysConfig?.ConfigValue != "off" && !SecurityCodeHelper.Validate(loginBody.Uuid, loginBody.Code))
|
var headers = HttpContext.Request.Headers;
|
||||||
|
var isRemoteInvoke = headers["Remote-Invoke"].FirstOrDefault().ParseToBool();
|
||||||
|
if (sysConfig?.ConfigValue != "off" && !SecurityCodeHelper.Validate(loginBody.Uuid, loginBody.Code)
|
||||||
|
&& !isRemoteInvoke)
|
||||||
{
|
{
|
||||||
return ToResponse(ResultCode.CAPTCHA_ERROR, "验证码错误");
|
return ToResponse(ResultCode.CAPTCHA_ERROR, "验证码错误");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
|
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
|
||||||
autoReload="true"
|
autoReload="true"
|
||||||
internalLogLevel="Info"
|
internalLogLevel="Info"
|
||||||
internalLogFile="nlog-internal.log">
|
internalLogFile="nlog-internal.log">
|
||||||
|
|
||||||
<!--Nlog 文档参考地址:https://github.com/NLog/NLog/wiki/Getting-started-with-ASP.NET-Core-2-->
|
<!--Nlog 文档参考地址:https://github.com/NLog/NLog/wiki/Getting-started-with-ASP.NET-Core-2-->
|
||||||
<!--internalLogLevel Nlog内部日志记录为Off关闭。除非纠错,不可以设为Trace否则速度很慢,起码Debug以上-->
|
<!--internalLogLevel Nlog内部日志记录为Off关闭。除非纠错,不可以设为Trace否则速度很慢,起码Debug以上-->
|
||||||
@ -45,14 +45,14 @@
|
|||||||
|
|
||||||
<!--SQL文件-->
|
<!--SQL文件-->
|
||||||
<target name="sqlfile" xsi:type="File"
|
<target name="sqlfile" xsi:type="File"
|
||||||
fileName="${basedir}/adminlogs/sql.txt"
|
fileName="${basedir}/adminlogs/sql.txt"
|
||||||
archiveFileName="${basedir}/adminlogs/bak/sql/sql{###}.txt"
|
archiveFileName="${basedir}/adminlogs/bak/sql/sql{###}.txt"
|
||||||
archiveEvery="Day"
|
archiveEvery="Day"
|
||||||
archiveNumbering="DateAndSequence"
|
archiveNumbering="DateAndSequence"
|
||||||
archiveAboveSize="20000000"
|
archiveAboveSize="20000000"
|
||||||
maxArchiveFiles="30"
|
maxArchiveFiles="30"
|
||||||
keepFileOpen="false"
|
keepFileOpen="false"
|
||||||
layout="${longdate} | ${uppercase:${level}} | ${aspnet-request-iP} | ${aspnet-request-headers:HeaderNames=userName} | ${aspnet-request-url} ${newline}${message}"/>
|
layout="${longdate} | ${uppercase:${level}} | ${aspnet-request-iP} | ${aspnet-request-headers:HeaderNames=userName} | ${aspnet-request-url} ${newline}${message}"/>
|
||||||
|
|
||||||
<!--写入彩色控制台-->
|
<!--写入彩色控制台-->
|
||||||
<target name="consoleSql" xsi:type="ColoredConsole" useDefaultRowHighlightingRules="false"
|
<target name="consoleSql" xsi:type="ColoredConsole" useDefaultRowHighlightingRules="false"
|
||||||
@ -84,7 +84,7 @@
|
|||||||
<!--<logger name="System.*" writeTo="blackhole" final="true" />-->
|
<!--<logger name="System.*" writeTo="blackhole" final="true" />-->
|
||||||
<!-- Quartz -->
|
<!-- Quartz -->
|
||||||
<logger name="Quartz*" minlevel="Trace" maxlevel="Info" final="true" />
|
<logger name="Quartz*" minlevel="Trace" maxlevel="Info" final="true" />
|
||||||
<logger name="*.SqlSugar.SqlsugarSetup" final="true" writeTo="consoleSql,sqlfile"/>
|
<logger name="*.SqlSugar.SqlSugarSetup" final="true" writeTo="consoleSql,sqlfile"/>
|
||||||
<logger name="*" minLevel="Trace" writeTo="allfile" />
|
<logger name="*" minLevel="Trace" writeTo="allfile" />
|
||||||
<logger name="*.GlobalExceptionMiddleware" final="true" writeTo="consoleSql,errorfile"/>
|
<logger name="*.GlobalExceptionMiddleware" final="true" writeTo="consoleSql,errorfile"/>
|
||||||
<logger name="ZR.Admin.WebApi.Middleware.CustomIpRateLimitMiddleware" final="true" writeTo="ipRateLimit" />
|
<logger name="ZR.Admin.WebApi.Middleware.CustomIpRateLimitMiddleware" final="true" writeTo="ipRateLimit" />
|
||||||
|
|||||||
@ -3,17 +3,13 @@ using Infrastructure.Converter;
|
|||||||
using Microsoft.AspNetCore.DataProtection;
|
using Microsoft.AspNetCore.DataProtection;
|
||||||
using NLog.Web;
|
using NLog.Web;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using BloomFilter;
|
|
||||||
using BloomFilter.CSRedis.Configurations;
|
using BloomFilter.CSRedis.Configurations;
|
||||||
using Microsoft.Extensions.Caching.Distributed;
|
using Microsoft.Extensions.Caching.Distributed;
|
||||||
using Microsoft.Extensions.Caching.Redis;
|
using Microsoft.Extensions.Caching.Redis;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using ZR.Admin.WebApi.Extensions;
|
using ZR.Admin.WebApi.Extensions;
|
||||||
using ZR.Infrastructure.Cache;
|
using ZR.Infrastructure.Cache;
|
||||||
using ZR.Infrastructure.Resolver;
|
|
||||||
using ZR.Infrastructure.WebExtensions;
|
using ZR.Infrastructure.WebExtensions;
|
||||||
using ZR.ServiceCore.Model;
|
|
||||||
using ZR.ServiceCore.Services.IService;
|
using ZR.ServiceCore.Services.IService;
|
||||||
using ZR.ServiceCore.Signalr;
|
using ZR.ServiceCore.Signalr;
|
||||||
using ZR.ServiceCore.SqlSugar;
|
using ZR.ServiceCore.SqlSugar;
|
||||||
@ -184,58 +180,4 @@ using (var serviceScope = app.Services.CreateScope())
|
|||||||
pol.IpRules.AddRange(ipRateLimitPolicies.Adapt<List<IpRateLimitPolicy>>());
|
pol.IpRules.AddRange(ipRateLimitPolicies.Adapt<List<IpRateLimitPolicy>>());
|
||||||
await ipPolicyStore.SetAsync(optionsAccessor.Value.IpPolicyPrefix, pol);
|
await ipPolicyStore.SetAsync(optionsAccessor.Value.IpPolicyPrefix, pol);
|
||||||
}
|
}
|
||||||
|
|
||||||
var serviceCoreModel = AppDomain.CurrentDomain
|
|
||||||
.GetAssemblies()
|
|
||||||
.First(it => it.FullName.Contains("ZR.ServiceCore"))
|
|
||||||
.ExportedTypes
|
|
||||||
.Where(p => p.FullName.StartsWith("ZR.ServiceCore.Model"))
|
|
||||||
.ToList();
|
|
||||||
// var geoEntityTypes = currentAssembly[0].ExportedTypes
|
|
||||||
// .Where(p => p.FullName.StartsWith("ZR.ServiceCore.Model"))
|
|
||||||
// .ToList();
|
|
||||||
var model = AppDomain.CurrentDomain
|
|
||||||
.GetAssemblies()
|
|
||||||
.First(it => it.FullName.Contains("ZR.Model"))
|
|
||||||
.ExportedTypes
|
|
||||||
.ToList();
|
|
||||||
foreach (var assembly in serviceCoreModel)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var user = new SysUser
|
|
||||||
{
|
|
||||||
UserName = "admin",
|
|
||||||
Password = "123456"
|
|
||||||
};
|
|
||||||
var props = new HashSet<string>
|
|
||||||
{
|
|
||||||
"Name",
|
|
||||||
"Children"
|
|
||||||
};
|
|
||||||
var article = new Article
|
|
||||||
{
|
|
||||||
Title = "aadad",
|
|
||||||
ArticleCategoryNav = new ArticleCategory
|
|
||||||
{
|
|
||||||
Name = "adsad",
|
|
||||||
Children = new List<ArticleCategory>
|
|
||||||
{
|
|
||||||
new()
|
|
||||||
{
|
|
||||||
Name = "1213"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var apiResult = new ApiResult(200, "SUCCESS", article);
|
|
||||||
var json = JsonConvert.SerializeObject(apiResult, new JsonSerializerSettings
|
|
||||||
{
|
|
||||||
ContractResolver = new JsonPropertyContractResolver(props)
|
|
||||||
});
|
|
||||||
var provider = builder.Services.BuildServiceProvider();
|
|
||||||
var bf = provider.GetService<IBloomFilter>();
|
|
||||||
bf.Add("Value");
|
|
||||||
Console.WriteLine(bf.Contains("Value"));
|
|
||||||
app.Run();
|
app.Run();
|
||||||
@ -26,7 +26,7 @@ public class DataFieldFilter : ActionFilterAttribute
|
|||||||
|
|
||||||
public Type ResultType { get; set; }
|
public Type ResultType { get; set; }
|
||||||
|
|
||||||
public string RulePath { get; set; }
|
public string Path { get; set; }
|
||||||
|
|
||||||
public override void OnResultExecuting(ResultExecutingContext context)
|
public override void OnResultExecuting(ResultExecutingContext context)
|
||||||
{
|
{
|
||||||
|
|||||||
13
ZR.ServiceCore/Model/SysBlock.cs
Normal file
13
ZR.ServiceCore/Model/SysBlock.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
namespace ZR.ServiceCore.Model;
|
||||||
|
[SugarTable("sys_block")]
|
||||||
|
[Tenant("0")]
|
||||||
|
public class SysBlock
|
||||||
|
{
|
||||||
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
public string Code { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
@ -13,6 +13,4 @@ public class SysField
|
|||||||
public string FullName { get; set; }
|
public string FullName { get; set; }
|
||||||
|
|
||||||
public string FieldType { get; set; }
|
public string FieldType { get; set; }
|
||||||
|
|
||||||
public string IsClass { get; set; }
|
|
||||||
}
|
}
|
||||||
11
ZR.ServiceCore/Model/SysFieldBlock.cs
Normal file
11
ZR.ServiceCore/Model/SysFieldBlock.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace ZR.ServiceCore.Model;
|
||||||
|
[SugarTable("sys_field_block")]
|
||||||
|
[Tenant("0")]
|
||||||
|
public class SysFieldBlock
|
||||||
|
{
|
||||||
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
|
public long BlockId { get; set; }
|
||||||
|
|
||||||
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
|
public long FieldId { get; set; }
|
||||||
|
}
|
||||||
9
ZR.ServiceCore/Services/IService/ISysBlockService.cs
Normal file
9
ZR.ServiceCore/Services/IService/ISysBlockService.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
using ZR.Service;
|
||||||
|
using ZR.ServiceCore.Model;
|
||||||
|
|
||||||
|
namespace ZR.ServiceCore.Services.IService;
|
||||||
|
|
||||||
|
public interface ISysBlockService : IBaseService<SysBlock>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
using ZR.Service;
|
||||||
|
using ZR.ServiceCore.Model;
|
||||||
|
|
||||||
|
namespace ZR.ServiceCore.Services.IService;
|
||||||
|
|
||||||
|
public interface ISysFieldBlockService : IBaseService<SysFieldBlock>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
12
ZR.ServiceCore/Services/SysBlockService.cs
Normal file
12
ZR.ServiceCore/Services/SysBlockService.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using Infrastructure.Attribute;
|
||||||
|
using ZR.Service;
|
||||||
|
using ZR.ServiceCore.Model;
|
||||||
|
using ZR.ServiceCore.Services.IService;
|
||||||
|
|
||||||
|
namespace ZR.ServiceCore.Services;
|
||||||
|
|
||||||
|
[AppService(ServiceType = typeof(ISysBlockService), ServiceLifetime = LifeTime.Transient)]
|
||||||
|
public class SysBlockService : BaseService<SysBlock>, ISysBlockService
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
12
ZR.ServiceCore/Services/SysFieldBlockService.cs
Normal file
12
ZR.ServiceCore/Services/SysFieldBlockService.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using Infrastructure.Attribute;
|
||||||
|
using ZR.Service;
|
||||||
|
using ZR.ServiceCore.Model;
|
||||||
|
using ZR.ServiceCore.Services.IService;
|
||||||
|
|
||||||
|
namespace ZR.ServiceCore.Services;
|
||||||
|
|
||||||
|
[AppService(ServiceType = typeof(ISysFieldBlockService), ServiceLifetime = LifeTime.Transient)]
|
||||||
|
public class SysFieldBlockService : BaseService<SysFieldBlock>, ISysFieldBlockService
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@ -19,11 +19,13 @@ public class SysFieldService : BaseService<SysField>, ISysFieldService
|
|||||||
{
|
{
|
||||||
var fields = await Queryable()
|
var fields = await Queryable()
|
||||||
.Where(it => it.FullName == fullName)
|
.Where(it => it.FullName == fullName)
|
||||||
|
.WithCache(10 * 60)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
var roleFields = await _sysRoleFieldService
|
var roleFields = await _sysRoleFieldService
|
||||||
.Queryable()
|
.Queryable()
|
||||||
.Where(it => it.RoleId == roleId)
|
.Where(it => it.RoleId == roleId)
|
||||||
.Select(it => it.FieldId)
|
.Select(it => it.FieldId)
|
||||||
|
.WithCache()
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
var list = fields.Select(it => new SysFieldDto
|
var list = fields.Select(it => new SysFieldDto
|
||||||
{
|
{
|
||||||
@ -31,7 +33,7 @@ public class SysFieldService : BaseService<SysField>, ISysFieldService
|
|||||||
FieldType = it.FieldType,
|
FieldType = it.FieldType,
|
||||||
FullName = it.FullName,
|
FullName = it.FullName,
|
||||||
Id = it.Id,
|
Id = it.Id,
|
||||||
IsClass = it.IsClass,
|
// IsClass = it.IsClass,
|
||||||
IsPermission = !roleFields.Contains(it.Id)
|
IsPermission = !roleFields.Contains(it.Id)
|
||||||
}).ToList();
|
}).ToList();
|
||||||
return list;
|
return list;
|
||||||
@ -67,7 +69,7 @@ public class SysFieldService : BaseService<SysField>, ISysFieldService
|
|||||||
FieldName = property.FieldName,
|
FieldName = property.FieldName,
|
||||||
FullName = serviceCoreModel.FullName,
|
FullName = serviceCoreModel.FullName,
|
||||||
FieldType = property.FieldType,
|
FieldType = property.FieldType,
|
||||||
IsClass = property.IsClass ? "1" : "0"
|
// IsClass = property.IsClass ? "1" : "0"
|
||||||
}).ToList();
|
}).ToList();
|
||||||
await Deleteable()
|
await Deleteable()
|
||||||
.Where(it =>
|
.Where(it =>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user