Skip to content

Commit

Permalink
1. 实体变更事件 EntityChangedEvent 添加变更值集合属性 ChangeValues.
Browse files Browse the repository at this point in the history
2. EntityFrameworkCore 工作单元更新数据时发布实体变更事件携带变更值集合.
3. Utc日期格式Json转换器 `UtcDateTimeJsonConverter`  默认日期格式字符串支持时区.
4. 重构扩展属性实现.
5. 采用 @for 语法重构 `<util-autocomplete>` 循环方式
6. 采用 @for 语法重构 `<util-tag>` 循环方式
7. 采用 @for 语法重构 `<util-radio>` 循环方式
8. 采用 @for 语法重构 `<util-radio-group>` 循环方式
9. 补齐 `<util-alert>` 标签属性.
10. 补齐 `<util-drawer>` 标签属性.
11. 补齐 `<util-mention>` 标签属性.
12. 补齐 `<util-modal>` 标签属性.
13. 补齐 `<util-radio>` 标签属性.
14. 补齐 `<util-radio-group>` 标签属性.
15. 补齐 `<util-rate>` 标签属性.
16. 补齐 `<util-tree-select>` 标签属性.
17. 补齐 `<util-tree>` 标签属性.
18. 补齐 `<util-tree-view>` 标签属性.
  • Loading branch information
UtilCore committed Jul 1, 2024
1 parent f4c8603 commit 19590e5
Show file tree
Hide file tree
Showing 116 changed files with 2,459 additions and 880 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>8</VersionMajor>
<VersionMinor>0</VersionMinor>
<VersionPatch>18</VersionPatch>
<VersionPatch>19</VersionPatch>
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
Expand Down
6 changes: 2 additions & 4 deletions src/Util.Core/SystemTextJson/DateTimeJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ public DateTimeJsonConverter( string format ) {
/// 读取数据
/// </summary>
public override DateTime Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options ) {
if ( reader.TokenType == JsonTokenType.String ) {
if ( reader.TokenType == JsonTokenType.String )
return Time.ToLocalTime( Util.Helpers.Convert.ToDateTime( reader.GetString() ) );
}
if ( reader.TryGetDateTime( out var date ) ) {
if ( reader.TryGetDateTime( out var date ) )
return Time.ToLocalTime( date );
}
return DateTime.MinValue;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Util.Core/SystemTextJson/UtcDateTimeJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public class UtcDateTimeJsonConverter : JsonConverter<DateTime> {
/// <summary>
/// 初始化Utc日期格式Json转换器
/// </summary>
public UtcDateTimeJsonConverter() : this( "yyyy-MM-dd HH:mm:ss" ) {
public UtcDateTimeJsonConverter() : this( "yyyy-MM-ddTHH:mm:sszzzz" ) {
}

/// <summary>
/// 初始化Utc日期格式Json转换器
/// </summary>
/// <param name="format">日期格式,默认值: yyyy-MM-dd HH:mm:ss</param>
/// <param name="format">日期格式,默认值: yyyy-MM-ddTHH:mm:sszzzz</param>
public UtcDateTimeJsonConverter( string format ) {
_format = format;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public class UtcNullableDateTimeJsonConverter : JsonConverter<DateTime?> {
/// <summary>
/// 初始化可空日期格式Json转换器
/// </summary>
public UtcNullableDateTimeJsonConverter() : this( "yyyy-MM-dd HH:mm:ss" ) {
public UtcNullableDateTimeJsonConverter() : this( "yyyy-MM-ddTHH:mm:sszzzz" ) {
}

/// <summary>
/// 初始化可空日期格式Json转换器
/// </summary>
/// <param name="format">日期格式,默认值: yyyy-MM-dd HH:mm:ss</param>
/// <param name="format">日期格式,默认值: yyyy-MM-ddTHH:mm:sszzzz</param>
public UtcNullableDateTimeJsonConverter( string format ) {
_format = format;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Util.Data.Abstractions/Trees/TreeQueryParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class TreeQueryParameter : QueryParameter, ITreeQueryParameter {
/// <summary>
/// 初始化树形查询参数
/// </summary>
protected TreeQueryParameter() {
public TreeQueryParameter() {
Order = "SortId";
}

Expand Down
2 changes: 1 addition & 1 deletion src/Util.Data.Core/01-Util.Data.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.2" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/Util.Data.EntityFrameworkCore/UnitOfWorkBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,9 @@ protected virtual byte[] GetVersion() {
/// <summary>
/// 添加实体变更事件
/// </summary>
protected virtual void AddEntityChangedEvent( object entity, EntityChangeType changeType ) {
protected virtual void AddEntityChangedEvent( object entity, EntityChangeType changeType, ChangeValueCollection changeValues = null ) {
var eventType = typeof( EntityChangedEvent<> ).MakeGenericType( entity.GetType() );
var @event = Reflection.CreateInstance<IEvent>( eventType, entity, changeType );
var @event = Reflection.CreateInstance<IEvent>( eventType, entity, changeType, changeValues );
SaveAfterEvents.Add( @event );
}

Expand Down Expand Up @@ -619,7 +619,7 @@ protected virtual void AddEntityUpdatedEvent( EntityEntry entry ) {
var changeValues = GetChangeValues( entry );
var @event = CreateEntityEvent( typeof( EntityUpdatedEvent<> ), entity, changeValues );
SaveAfterEvents.Add( @event );
AddEntityChangedEvent( entity, EntityChangeType.Updated );
AddEntityChangedEvent( entity, EntityChangeType.Updated, changeValues );
}

#endregion
Expand Down
13 changes: 11 additions & 2 deletions src/Util.Domain/Events/EntityChangedEvent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Util.Domain.Events;
using Util.Domain.Compare;

namespace Util.Domain.Events;

/// <summary>
/// 实体变更事件,当实体新增,修改,删除时均触发
Expand All @@ -10,9 +12,11 @@ public class EntityChangedEvent<TEntity> : IEvent {
/// </summary>
/// <param name="entity">实体</param>
/// <param name="changeType">变更类型</param>
public EntityChangedEvent( TEntity entity, EntityChangeType changeType ) {
/// <param name="changeValues">变更值集合</param>
public EntityChangedEvent( TEntity entity, EntityChangeType changeType, ChangeValueCollection changeValues = null ) {
Entity = entity;
ChangeType = changeType;
ChangeValues = changeValues;
}

/// <summary>
Expand All @@ -24,4 +28,9 @@ public EntityChangedEvent( TEntity entity, EntityChangeType changeType ) {
/// 变更类型
/// </summary>
public EntityChangeType ChangeType { get; }

/// <summary>
/// 变更值集合
/// </summary>
public ChangeValueCollection ChangeValues { get; }
}
21 changes: 7 additions & 14 deletions src/Util.Domain/ExtraPropertyDictionaryExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System.Text.Json;
using Util.Dates;
using Util.Domain.Extending;
using Util.Helpers;

namespace Util.Domain;
namespace Util.Domain;

/// <summary>
/// 扩展属性字典扩展
Expand All @@ -16,16 +15,10 @@ public static class ExtraPropertyDictionaryExtensions {
/// <param name="name">属性名</param>
public static TProperty GetProperty<TProperty>( this ExtraPropertyDictionary source, string name ) {
source.CheckNull( nameof( source ) );
if( source.ContainsKey( name ) == false )
if ( source.TryGetValue( name, out var value ) == false )
return default;
var value = source[name];
if( value is JsonElement element ) {
var date = Util.Helpers.Convert.ToDateTimeOrNull( element.GetRawText().Trim( '"' ) );
if( date != null )
value = date;
}
if ( value is DateTime dateValue && TimeOptions.IsUseUtc )
value = Time.UtcToLocalTime( dateValue );
if ( value is JsonElement element )
return Util.Helpers.Json.ToObject<TProperty>( Util.Helpers.Json.ToJson( element ) );
return Util.Helpers.Convert.To<TProperty>( value );
}

Expand All @@ -40,7 +33,7 @@ public static ExtraPropertyDictionary SetProperty( this ExtraPropertyDictionary
source.RemoveProperty( name );
if ( value == null )
return source;
source[name] = GetPropertyValue(source,value);
source[name] = GetPropertyValue( source, value );
return source;
}

Expand All @@ -50,7 +43,7 @@ public static ExtraPropertyDictionary SetProperty( this ExtraPropertyDictionary
private static object GetPropertyValue( ExtraPropertyDictionary source, object value ) {
if ( value is string && source.IsTrimString )
return value.SafeString();
if ( value is DateTime dateValue && TimeOptions.IsUseUtc )
if ( value is DateTime dateValue )
return Time.Normalize( dateValue );
return value;
}
Expand All @@ -62,7 +55,7 @@ private static object GetPropertyValue( ExtraPropertyDictionary source, object v
/// <param name="name">属性名</param>
public static ExtraPropertyDictionary RemoveProperty( this ExtraPropertyDictionary source, string name ) {
source.CheckNull( nameof( source ) );
if( source.ContainsKey( name ) )
if ( source.ContainsKey( name ) )
source.Remove( name );
return source;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Util.Events.MediatR/03-Util.Events.MediatR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="MediatR" Version="12.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Minio" Version="6.0.2" />
<PackageReference Include="Minio" Version="6.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Util.FileStorage/02-Util.FileStorage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FileSignatures" Version="5.0.1" />
<PackageReference Include="FileSignatures" Version="5.0.2" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Util.IdGenerator/10-Util.IdGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Nanoid" Version="3.0.0" />
<PackageReference Include="Nanoid" Version="3.1.0" />
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions src/Util.Logging.Serilog/02-Util.Logging.Serilog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

<ItemGroup>
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="7.0.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ protected virtual async Task<ServiceResult<TResponse>> ToUnpackResult<TResponse>
return await response.Content.ReadFromJsonAsync<ServiceResult<TResponse>>( Client.JsonSerializerOptions, cancellationToken );
var objResult = await OnResultAction( response, Client.JsonSerializerOptions, cancellationToken );
var result = objResult as ServiceResult<TResponse>;
result.CheckNull( nameof( result ) );
result!.CheckNull( nameof( result ) );
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Polly" Version="8.4.0" />
<PackageReference Include="Polly" Version="8.4.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.12" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.14" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Util.Scheduling.Quartz/02-Util.Scheduling.Quartz.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Quartz" Version="3.9.0" />
<PackageReference Include="Quartz.Extensions.DependencyInjection" Version="3.9.0" />
<PackageReference Include="Quartz" Version="3.10.0" />
<PackageReference Include="Quartz.Extensions.DependencyInjection" Version="3.10.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Util.Templates.Razor/02-Util.Templates.Razor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="6.0.31" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
</ItemGroup>
</Project>
18 changes: 13 additions & 5 deletions src/Util.Ui.NgZorro/Components/Alerts/AlertTagHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public class AlertTagHelper : AngularTagHelperBase {
/// </summary>
private Config _config;
/// <summary>
/// [nzBanner],是否顶部公告,默认值: false
/// [nzBanner],是否顶部公告, 类型: boolean, 默认值: false
/// </summary>
public string Banner { get; set; }
/// <summary>
/// [nzCloseable],是否可关闭
/// [nzCloseable],是否可关闭,类型: boolean, 默认值: false
/// </summary>
public string Closeable { get; set; }
/// <summary>
Expand Down Expand Up @@ -49,18 +49,22 @@ public class AlertTagHelper : AngularTagHelperBase {
/// </summary>
public string BindMessage { get; set; }
/// <summary>
/// [nzShowIcon],是否显示图标,默认值: false,nzBanner 模式下默认值为 true
/// [nzShowIcon],是否显示图标, 类型: boolean, 默认值: false, nzBanner 模式下默认值为 true
/// </summary>
public string ShowIcon { get; set; }
/// <summary>
/// nzIconType,自定义图标类型,nzShowIcon 为 true 时有效
/// nzIconType,自定义图标类型
/// </summary>
public AntDesignIcon IconType { get; set; }
/// <summary>
/// [nzIconType],自定义图标类型,nzShowIcon 为 true 时有效
/// [nzIconType],自定义图标类型
/// </summary>
public string BindIconType { get; set; }
/// <summary>
/// [nzIcon],自定义图标,类型: string | TemplateRef&lt;void>
/// </summary>
public string Icon { get; set; }
/// <summary>
/// nzType,警告类型,指定警告提示的样式,可选值: 'success' | 'info' | 'warning' | 'error',默认值: 'info',nzBanner 模式下默认值为 'warning'
/// </summary>
public AlertType Type { get; set; }
Expand All @@ -69,6 +73,10 @@ public class AlertTagHelper : AngularTagHelperBase {
/// </summary>
public string BindType { get; set; }
/// <summary>
/// [nzAction],自定义操作项,类型: string | TemplateRef&lt;void>
/// </summary>
public string Action { get; set; }
/// <summary>
/// (nzOnClose),关闭事件,类型: EventEmitter&lt;void>
/// </summary>
public string OnClose { get; set; }
Expand Down
23 changes: 19 additions & 4 deletions src/Util.Ui.NgZorro/Components/Alerts/Builders/AlertBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Util.Ui.Angular.Configs;
using Util.Ui.NgZorro.Enums;

namespace Util.Ui.NgZorro.Components.Alerts.Builders;
namespace Util.Ui.NgZorro.Components.Alerts.Builders;

/// <summary>
/// 警告提示标签生成器
Expand Down Expand Up @@ -75,16 +75,23 @@ public AlertBuilder BindMessage( string value ) {
/// 配置是否显示图标
/// </summary>
public AlertBuilder ShowIcon() {
if ( _config.GetValue( UiConst.IconType ).IsEmpty() == false ||
_config.GetValue( AngularConst.BindIconType ).IsEmpty() == false ||
_config.GetValue( UiConst.Icon ).IsEmpty() == false ) {
Attribute( "[nzShowIcon]", "true" );
return this;
}
AttributeIfNotEmpty( "[nzShowIcon]", _config.GetValue( UiConst.ShowIcon ) );
return this;
}

/// <summary>
/// 配置图标类型
/// 配置图标
/// </summary>
public AlertBuilder IconType() {
public AlertBuilder Icon() {
AttributeIfNotEmpty( "nzIconType", _config.GetValue<AntDesignIcon?>( UiConst.IconType )?.Description() );
AttributeIfNotEmpty( "[nzIconType]", _config.GetValue( AngularConst.BindIconType ) );
AttributeIfNotEmpty( "[nzIcon]", _config.GetValue( UiConst.Icon ) );
return this;
}

Expand All @@ -97,6 +104,14 @@ public AlertBuilder Type() {
return this;
}

/// <summary>
/// 配置自定义操作项
/// </summary>
public AlertBuilder Action() {
AttributeIfNotEmpty( "[nzAction]", _config.GetValue( UiConst.Action ) );
return this;
}

/// <summary>
/// 配置事件
/// </summary>
Expand All @@ -111,7 +126,7 @@ public AlertBuilder Events() {
public override void Config() {
base.ConfigBase( _config );
Banner().Closeable().CloseText().Description()
.Message().ShowIcon().IconType().Type()
.Message().ShowIcon().Icon().Type().Action()
.Events();
}
}
Loading

0 comments on commit 19590e5

Please sign in to comment.