Skip to content

Commit

Permalink
更新实体审计操作
Browse files Browse the repository at this point in the history
  • Loading branch information
UtilCore committed Jun 9, 2023
1 parent 2a12655 commit 18b1076
Show file tree
Hide file tree
Showing 213 changed files with 3,046 additions and 2,659 deletions.
2 changes: 1 addition & 1 deletion build/version.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<VersionMajor>7</VersionMajor>
<VersionMinor>0</VersionMinor>
<VersionPatch>57</VersionPatch>
<VersionPatch>61</VersionPatch>
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
Expand Down
14 changes: 14 additions & 0 deletions src/Util.Core/Helpers/Thread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,18 @@ public static async Task ParallelForAsync( Func<ValueTask> action, int count = 1
}
await Parallel.ForEachAsync( Enumerable.Range( 1,count ), options, async (i,token)=> await action() );
}

/// <summary>
/// 循环并发执行操作
/// </summary>
/// <param name="action">操作</param>
/// <param name="count">执行次数</param>
/// <param name="options">并发执行配置</param>
public static async Task ParallelForAsync( Func<int,ValueTask> action, int count = 1, ParallelOptions options = null ) {
if ( options == null ) {
await Parallel.ForEachAsync( Enumerable.Range( 1, count ), async ( i, token ) => await action(i) );
return;
}
await Parallel.ForEachAsync( Enumerable.Range( 1, count ), options, async ( i, token ) => await action(i) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Text.Json.Serialization;
using Util.Helpers;

namespace Util.Data.EntityFrameworkCore.ValueConverters.SystemTextJson;
namespace Util.SystemTextJson;

/// <summary>
/// Utc日期格式Json转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Text.Json.Serialization;
using Util.Helpers;

namespace Util.Data.EntityFrameworkCore.ValueConverters.SystemTextJson;
namespace Util.SystemTextJson;

/// <summary>
/// 可空日期格式Json转换器
Expand Down
2 changes: 1 addition & 1 deletion src/Util.Data.Dapper.All/05-Util.Data.Dapper.All.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>$(NetTargetFramework)</TargetFramework>
<PackageIcon>icon.jpg</PackageIcon>
<AssemblyName>Util.Data.Dapper.All</AssemblyName>
<RootNamespace>Util.Data</RootNamespace>
<RootNamespace>Util.Data.Dapper</RootNamespace>
<Description>Util.Data.Dapper.All是Util应用框架基于Dapper的数据访问封装类库,包含所有支持的数据库实现</Description>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Util.Data.Dapper.Metadata;
using Util.Data.Metadata;
using Util.Infrastructure;

namespace Util.Data.Infrastructure;
namespace Util.Data.Dapper.Infrastructure;

/// <summary>
/// Dapper服务注册器
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Util.Infrastructure;

namespace Util.Data.Infrastructure;
namespace Util.Data.Dapper.Infrastructure;

/// <summary>
/// Dapper服务注册器配置扩展
Expand Down
4 changes: 3 additions & 1 deletion src/Util.Data.Dapper.All/Metadata/MetadataServiceFactory.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using Util.Data.Dapper.Sql;
using Util.Data.Metadata;
using Util.Data.Sql;

namespace Util.Data.Metadata;
namespace Util.Data.Dapper.Metadata;

/// <summary>
/// 数据库元数据服务工厂
Expand Down
3 changes: 2 additions & 1 deletion src/Util.Data.Dapper.All/Metadata/TypeConverterFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using Util.Data.Metadata;

namespace Util.Data.Metadata;
namespace Util.Data.Dapper.Metadata;

/// <summary>
/// 数据类型转换器工厂
Expand Down
2 changes: 1 addition & 1 deletion src/Util.Data.Dapper.Core/01-Util.Data.Dapper.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>$(NetTargetFramework)</TargetFramework>
<PackageIcon>icon.jpg</PackageIcon>
<AssemblyName>Util.Data.Dapper.Core</AssemblyName>
<RootNamespace>Util.Data</RootNamespace>
<RootNamespace>Util.Data.Dapper</RootNamespace>
<Description>Util.Data.Dapper.Core是Util应用框架基于Dapper的数据访问封装基础类库</Description>
</PropertyGroup>

Expand Down
35 changes: 35 additions & 0 deletions src/Util.Data.Dapper.Core/Infrastructure/DapperServiceRegistrar.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Dapper;
using System;
using Util.Data.Dapper.TypeHandlers;
using Util.Infrastructure;

namespace Util.Data.Dapper.Infrastructure;

/// <summary>
/// Dapper服务注册器
/// </summary>
public class DapperServiceRegistrar : IServiceRegistrar {
/// <summary>
/// 获取服务名
/// </summary>
public static string ServiceName => "Util.Data.Dapper.Infrastructure.DapperServiceRegistrar";

/// <summary>
/// 排序号
/// </summary>
public int OrderId => 810;

/// <summary>
/// 是否启用
/// </summary>
public bool Enabled => ServiceRegistrarConfig.IsEnabled( ServiceName );

/// <summary>
/// 注册服务
/// </summary>
/// <param name="serviceContext">服务上下文</param>
public Action Register( ServiceContext serviceContext ) {
SqlMapper.AddTypeHandler( new ExtraPropertiesTypeHandler() );
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Util.Infrastructure;

namespace Util.Data.Dapper.Infrastructure;

/// <summary>
/// Dapper服务注册器配置扩展
/// </summary>
public static class ServiceRegistrarConfigExtensions {
/// <summary>
/// 启用Dapper服务注册器
/// </summary>
/// <param name="config">服务注册器配置</param>
public static ServiceRegistrarConfig EnableDapperServiceRegistrar( this ServiceRegistrarConfig config ) {
ServiceRegistrarConfig.Enable( DapperServiceRegistrar.ServiceName );
return config;
}

/// <summary>
///禁用Dapper服务注册器
/// </summary>
/// <param name="config">服务注册器配置</param>
public static ServiceRegistrarConfig DisableDapperServiceRegistrar( this ServiceRegistrarConfig config ) {
ServiceRegistrarConfig.Disable( DapperServiceRegistrar.ServiceName );
return config;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/Util.Data.Dapper.Core/Sql/SqlExecutorBase.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using System.Threading.Tasks;
using Dapper;
using Util.Data.Sql;

namespace Util.Data.Sql;
namespace Util.Data.Dapper.Sql;

/// <summary>
/// Sql执行器
Expand Down
5 changes: 3 additions & 2 deletions src/Util.Data.Dapper.Core/Sql/SqlQueryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Util.Data.Properties;
using Util.Data.Dapper.Properties;
using Util.Data.Sql;
using Util.Data.Sql.Builders;
using Util.Data.Sql.Builders.Clauses;
using Util.Data.Sql.Builders.Core;
Expand All @@ -18,7 +19,7 @@
using Util.Data.Sql.Database;
using Util.Helpers;

namespace Util.Data.Sql;
namespace Util.Data.Dapper.Sql;

/// <summary>
/// Sql查询对象
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System.Data;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Unicode;
using Dapper;
using Util.Domain.Extending;
using Util.SystemTextJson;

namespace Util.Data.Dapper.TypeHandlers;

/// <summary>
/// 扩展属性类型转换器
/// </summary>
public class ExtraPropertiesTypeHandler : SqlMapper.TypeHandler<ExtraPropertyDictionary> {
/// <summary>
/// 设置值
/// </summary>
/// <param name="parameter">参数</param>
/// <param name="value">扩展属性值</param>
public override void SetValue( IDbDataParameter parameter, ExtraPropertyDictionary value ) {
if ( parameter == null )
return;
if ( value == null )
return;
parameter.Value = PropertiesToJson( value );
}

/// <summary>
/// 扩展属性转换为json
/// </summary>
private static string PropertiesToJson( ExtraPropertyDictionary extraProperties ) {
var options = new JsonSerializerOptions {
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
Encoder = JavaScriptEncoder.Create( UnicodeRanges.All ),
Converters = {
new UtcDateTimeJsonConverter(),
new UtcNullableDateTimeJsonConverter()
}
};
return Util.Helpers.Json.ToJson( extraProperties, options );
}

/// <summary>
/// 转换值
/// </summary>
/// <param name="value">json字符串</param>
public override ExtraPropertyDictionary Parse( object value ) {
return JsonToProperties( value.SafeString() );
}

/// <summary>
/// json转换为扩展属性
/// </summary>
private static ExtraPropertyDictionary JsonToProperties( string json ) {
if ( json.IsEmpty() || json == "{}" )
return new ExtraPropertyDictionary();
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
return Util.Helpers.Json.ToObject<ExtraPropertyDictionary>( json, options ) ?? new ExtraPropertyDictionary();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>$(NetTargetFramework)</TargetFramework>
<PackageIcon>icon.jpg</PackageIcon>
<AssemblyName>Util.Data.Dapper.MySql</AssemblyName>
<RootNamespace>Util.Data</RootNamespace>
<RootNamespace>Util.Data.Dapper</RootNamespace>
<Description>Util.Data.Dapper.MySql是Util应用框架基于Dapper的数据访问封装类库,用于处理MySql数据库</Description>
</PropertyGroup>

Expand Down
3 changes: 2 additions & 1 deletion src/Util.Data.Dapper.MySql/Metadata/MySqlMetadataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Util.Data.Metadata;
using Util.Data.Sql;

namespace Util.Data.Metadata;
namespace Util.Data.Dapper.Metadata;

/// <summary>
/// MySql数据库元数据服务
Expand Down
3 changes: 2 additions & 1 deletion src/Util.Data.Dapper.MySql/Metadata/MySqlTypeConverter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using System.Data;
using Util.Data.Metadata;

namespace Util.Data.Metadata;
namespace Util.Data.Dapper.Metadata;

/// <summary>
/// MySql数据类型转换器
Expand Down
6 changes: 4 additions & 2 deletions src/Util.Data.Dapper.MySql/Sql/Builders/MySqlBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Util.Data.Sql.Builders.Caches;
using Util.Data.Sql;
using Util.Data.Sql.Builders;
using Util.Data.Sql.Builders.Caches;
using Util.Data.Sql.Builders.Params;

namespace Util.Data.Sql.Builders;
namespace Util.Data.Dapper.Sql.Builders;

/// <summary>
/// MySql Sql生成器
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Concurrent;
using Util.Data.Sql.Builders.Caches;

namespace Util.Data.Sql.Builders;
namespace Util.Data.Dapper.Sql.Builders;

/// <summary>
/// MySql列缓存
Expand Down
5 changes: 3 additions & 2 deletions src/Util.Data.Dapper.MySql/Sql/Builders/MySqlDialect.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Util.Data.Sql.Builders.Core;
using Util.Data.Sql.Builders;
using Util.Data.Sql.Builders.Core;

namespace Util.Data.Sql.Builders;
namespace Util.Data.Dapper.Sql.Builders;

/// <summary>
/// MySql方言
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Text;
using Util.Data.Sql;
using Util.Data.Sql.Builders;

namespace Util.Data.Sql.Builders;
namespace Util.Data.Dapper.Sql.Builders;

/// <summary>
/// 判断是否存在Sql生成器
Expand Down
2 changes: 1 addition & 1 deletion src/Util.Data.Dapper.MySql/Sql/MySqlDatabaseFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using MySqlConnector;

namespace Util.Data.Sql;
namespace Util.Data.Dapper.Sql;

/// <summary>
/// MySql数据库工厂
Expand Down
3 changes: 2 additions & 1 deletion src/Util.Data.Dapper.MySql/Sql/MySqlExecutor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using Util.Data.Sql;

namespace Util.Data.Sql;
namespace Util.Data.Dapper.Sql;

/// <summary>
/// MySql Sql执行器
Expand Down
4 changes: 3 additions & 1 deletion src/Util.Data.Dapper.MySql/Sql/MySqlExecutorBase.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using Util.Data.Dapper.Sql.Builders;
using Util.Data.Sql;
using Util.Data.Sql.Builders;

namespace Util.Data.Sql;
namespace Util.Data.Dapper.Sql;

/// <summary>
/// MySql Sql执行器
Expand Down
Loading

0 comments on commit 18b1076

Please sign in to comment.