mirror of
https://github.com/dotnetcore/Util.git
synced 2026-10-27 10:17:03 +08:00
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>` 标签属性.
221 lines
6.7 KiB
C#
221 lines
6.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using Util.Domain;
|
|
using Util.Domain.Auditing;
|
|
using Util.Domain.Entities;
|
|
using Util.Domain.Extending;
|
|
using Util.Tenants;
|
|
using Util.Tests.Events;
|
|
|
|
namespace Util.Tests.Models;
|
|
|
|
/// <summary>
|
|
/// 产品
|
|
/// </summary>
|
|
[Description( "产品" )]
|
|
public class Product : AggregateRoot<Product>, IDelete, ITenant, IAudited, IExtraProperties {
|
|
/// <summary>
|
|
/// 初始化产品
|
|
/// </summary>
|
|
public Product() : this( Guid.Empty ) {
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化产品
|
|
/// </summary>
|
|
/// <param name="id">产品标识</param>
|
|
public Product( Guid id ) : base( id ) {
|
|
TestProperty2 = new ProductItem();
|
|
TestProperty4 = new ProductItem2();
|
|
TestProperties = new List<ProductItem>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 产品编码
|
|
///</summary>
|
|
[Description( "产品编码" )]
|
|
[MaxLength( 50 )]
|
|
public string Code { get; set; }
|
|
/// <summary>
|
|
/// 产品名称
|
|
///</summary>
|
|
[Description( "产品名称" )]
|
|
[MaxLength( 500 )]
|
|
public string Name { get; set; }
|
|
/// <summary>
|
|
/// 价格
|
|
///</summary>
|
|
[Description( "价格" )]
|
|
public decimal Price { get; set; }
|
|
/// <summary>
|
|
/// 价格
|
|
///</summary>
|
|
[Description( "价格" )]
|
|
public int IntPrice { get; set; }
|
|
/// <summary>
|
|
/// 价格
|
|
///</summary>
|
|
[Description( "价格" )]
|
|
public long LongPrice { get; set; }
|
|
/// <summary>
|
|
/// 价格
|
|
///</summary>
|
|
[Description( "价格" )]
|
|
public float FloatPrice { get; set; }
|
|
/// <summary>
|
|
/// 描述
|
|
///</summary>
|
|
[Description( "描述" )]
|
|
public string Description { get; set; }
|
|
/// <summary>
|
|
/// 启用
|
|
///</summary>
|
|
[Description( "启用" )]
|
|
public bool Enabled { get; set; }
|
|
/// <summary>
|
|
/// 创建时间
|
|
///</summary>
|
|
[Description( "创建时间" )]
|
|
public DateTime? CreationTime { get; set; }
|
|
/// <summary>
|
|
/// 创建人
|
|
///</summary>
|
|
[Description( "创建人" )]
|
|
public Guid? CreatorId { get; set; }
|
|
/// <summary>
|
|
/// 最后修改时间
|
|
///</summary>
|
|
[Description( "最后修改时间" )]
|
|
public DateTime? LastModificationTime { get; set; }
|
|
/// <summary>
|
|
/// 最后修改人
|
|
///</summary>
|
|
[Description( "最后修改人" )]
|
|
public Guid? LastModifierId { get; set; }
|
|
/// <summary>
|
|
/// 是否删除
|
|
///</summary>
|
|
[Description( "是否删除" )]
|
|
public bool IsDeleted { get; set; }
|
|
/// <summary>
|
|
/// 租户标识
|
|
///</summary>
|
|
[Description( "租户标识" )]
|
|
public string TenantId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 简单扩展属性
|
|
/// </summary>
|
|
[NotMapped]
|
|
public string TestProperty1 {
|
|
get => ExtraProperties.GetProperty<string>( nameof( TestProperty1 ) );
|
|
set => ExtraProperties.SetProperty( nameof( TestProperty1 ), value );
|
|
}
|
|
|
|
private readonly ExtraProperty<ProductItem> _property2 = new( nameof( TestProperty2 ) );
|
|
/// <summary>
|
|
/// 对象扩展属性
|
|
/// </summary>
|
|
[NotMapped]
|
|
public ProductItem TestProperty2 {
|
|
get => _property2.GetProperty( ExtraProperties );
|
|
set => _property2.SetProperty( ExtraProperties, value );
|
|
}
|
|
|
|
/// <summary>
|
|
/// 枚举扩展属性
|
|
/// </summary>
|
|
[NotMapped]
|
|
public ProductEnum? TestProperty3 {
|
|
get => ExtraProperties.GetProperty<ProductEnum?>( nameof( TestProperty3 ) );
|
|
set => ExtraProperties.SetProperty( nameof( TestProperty3 ), value );
|
|
}
|
|
|
|
private readonly ExtraProperty<ProductItem2> _property4 = new( nameof( TestProperty4 ) );
|
|
/// <summary>
|
|
/// 不可变对象扩展属性
|
|
/// </summary>
|
|
[NotMapped]
|
|
public ProductItem2 TestProperty4 {
|
|
get => _property4.GetProperty( ExtraProperties );
|
|
set => _property4.SetProperty( ExtraProperties, value );
|
|
}
|
|
|
|
private readonly ExtraProperty<List<ProductItem>> _properties = new( nameof( TestProperties ) );
|
|
/// <summary>
|
|
/// 对象集合扩展属性
|
|
/// </summary>
|
|
[NotMapped]
|
|
public List<ProductItem> TestProperties {
|
|
get => _properties.GetProperty( ExtraProperties );
|
|
set => _properties.SetProperty( ExtraProperties, value );
|
|
}
|
|
|
|
private readonly ExtraProperty<ApplicationExtend> _property5 = new( nameof( TestProperty5 ) );
|
|
/// <summary>
|
|
/// 不可变对象扩展属性
|
|
/// </summary>
|
|
[NotMapped]
|
|
public ApplicationExtend TestProperty5 {
|
|
get => _property5.GetProperty( ExtraProperties );
|
|
set => _property5.SetProperty( ExtraProperties, value );
|
|
}
|
|
|
|
/// <summary>
|
|
/// 日期扩展属性
|
|
/// </summary>
|
|
[NotMapped]
|
|
public DateTime TestProperty6 {
|
|
get => ExtraProperties.GetProperty<DateTime>( nameof( TestProperty6 ) );
|
|
set => ExtraProperties.SetProperty( nameof( TestProperty6 ), value );
|
|
}
|
|
|
|
private readonly ExtraProperty<List<TaskRecord>> _property7 = new( nameof( TaskRecordList ) );
|
|
/// <summary>
|
|
/// 执行记录
|
|
/// </summary>
|
|
[NotMapped]
|
|
public List<TaskRecord> TaskRecordList {
|
|
get => _property7.GetProperty( ExtraProperties );
|
|
set => _property7.SetProperty( ExtraProperties, value );
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加变更列表
|
|
/// </summary>
|
|
protected override void AddChanges( Product other ) {
|
|
AddChange( t => t.Code, other.Code );
|
|
AddChange( t => t.Name, other.Name );
|
|
AddChange( t => t.Price, other.Price );
|
|
AddChange( t => t.Description, other.Description );
|
|
AddChange( t => t.Enabled, other.Enabled );
|
|
AddChange( t => t.CreationTime, other.CreationTime );
|
|
AddChange( t => t.CreatorId, other.CreatorId );
|
|
AddChange( t => t.LastModificationTime, other.LastModificationTime );
|
|
AddChange( t => t.LastModifierId, other.LastModifierId );
|
|
}
|
|
|
|
/// <summary>
|
|
/// 测试领域事件方法1 - 添加1个本地事件 TestEvent2
|
|
/// </summary>
|
|
public void TestDomainEvent1() {
|
|
AddDomainEvent( new TestEvent2 { Id = Id, Name = "a" } );
|
|
}
|
|
|
|
/// <summary>
|
|
/// 测试领域事件方法2 - 添加1个集成事件 TestEvent3
|
|
/// </summary>
|
|
public void TestDomainEvent2() {
|
|
AddDomainEvent( new TestEvent3( Id, "a" ) );
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取扩展属性Json
|
|
/// </summary>
|
|
public string GetExtraPropertiesJson() {
|
|
return Util.Helpers.Json.ToJson( ExtraProperties );
|
|
}
|
|
} |