From ece32e7c78c6ec594d194b0f35d4b844cb1ec348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A3=8A=E7=A3=8A?= Date: Thu, 2 Jun 2022 18:46:10 +0800 Subject: [PATCH 1/2] feat:add sdk method for team and permission --- Masa.BuildingBlocks.sln | 7 ++++ .../IEnvironmentProvider.cs | 9 +++++ ...sa.BuildingBlocks.BasicAbility.Auth.csproj | 2 +- .../Model/MenuModel.cs | 19 ++++++++++ .../Model/TeamModel.cs | 11 ++++++ .../Service/IPermissionService.cs | 13 +++++++ .../Service/ITeamService.cs | 2 ++ .../Service/IUserService.cs | 4 +++ .../Mapper.cs | 22 ++++++++++++ .../Masa.BuildingBlocks.Data.Mapping.csproj | 6 +++- .../_Imports.cs | 1 + ...ildingBlocks.Data.MappingExtensions.csproj | 13 +++++++ .../ObjectExtensions.cs | 19 ++++++++++ .../_Imports.cs | 5 +++ .../Enum/SequentialGuidType.cs | 26 ++++++++++++++ .../Enum/TimestampType.cs | 10 ++++++ .../IdGenerator/IGuidGenerator.cs | 8 +++++ .../IdGenerator/IIdGenerator.cs | 11 ++++++ .../IdGenerator/ISequentialGuidGenerator.cs | 9 +++++ .../IdGenerator/ISnowflakeGenerator.cs | 8 +++++ .../IdGenerator/IdGeneratorFactory.cs | 36 +++++++++++++++++++ .../Masa.BuildingBlocks.Data.csproj | 16 +++++---- .../{ => Options}/MasaDbConnectionOptions.cs | 0 .../System/SequentialGuid.cs | 9 +++++ .../System/Snowflake.cs | 9 +++++ src/Data/Masa.BuildingBlocks.Data/_Imports.cs | 1 + .../Entities/AggregateRoot.cs | 10 +++++- .../Entities/Auditing/AuditAggregateRoot.cs | 10 +++++- .../Entities/Auditing/AuditEntity.cs | 10 +++++- .../Entities/Entity.cs | 8 ++++- .../Entities/Full/FullAggregateRoot.cs | 8 +++++ .../Entities/Full/FullEntity.cs | 8 +++++ ...ingBlocks.SearchEngine.AutoComplete.csproj | 2 +- 33 files changed, 319 insertions(+), 13 deletions(-) create mode 100644 src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/IEnvironmentProvider.cs create mode 100644 src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Model/MenuModel.cs create mode 100644 src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Model/TeamModel.cs create mode 100644 src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Service/IPermissionService.cs create mode 100644 src/Data/Masa.BuildingBlocks.Data.Mapping/Mapper.cs create mode 100644 src/Data/Masa.BuildingBlocks.Data.MappingExtensions/Masa.BuildingBlocks.Data.MappingExtensions.csproj create mode 100644 src/Data/Masa.BuildingBlocks.Data.MappingExtensions/ObjectExtensions.cs create mode 100644 src/Data/Masa.BuildingBlocks.Data.MappingExtensions/_Imports.cs create mode 100644 src/Data/Masa.BuildingBlocks.Data/Enum/SequentialGuidType.cs create mode 100644 src/Data/Masa.BuildingBlocks.Data/Enum/TimestampType.cs create mode 100644 src/Data/Masa.BuildingBlocks.Data/IdGenerator/IGuidGenerator.cs create mode 100644 src/Data/Masa.BuildingBlocks.Data/IdGenerator/IIdGenerator.cs create mode 100644 src/Data/Masa.BuildingBlocks.Data/IdGenerator/ISequentialGuidGenerator.cs create mode 100644 src/Data/Masa.BuildingBlocks.Data/IdGenerator/ISnowflakeGenerator.cs create mode 100644 src/Data/Masa.BuildingBlocks.Data/IdGenerator/IdGeneratorFactory.cs rename src/Data/Masa.BuildingBlocks.Data/{ => Options}/MasaDbConnectionOptions.cs (100%) create mode 100644 src/Data/Masa.BuildingBlocks.Data/System/SequentialGuid.cs create mode 100644 src/Data/Masa.BuildingBlocks.Data/System/Snowflake.cs diff --git a/Masa.BuildingBlocks.sln b/Masa.BuildingBlocks.sln index 9c91b28..2968912 100644 --- a/Masa.BuildingBlocks.sln +++ b/Masa.BuildingBlocks.sln @@ -81,6 +81,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.BuildingBlocks.Data", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.BuildingBlocks.Service.Contracts", "src\Service\Masa.BuildingBlocks.Service.Contracts\Masa.BuildingBlocks.Service.Contracts.csproj", "{775797E2-8576-4050-8649-18AAD00D0A87}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.BuildingBlocks.Data.MappingExtensions", "src\Data\Masa.BuildingBlocks.Data.MappingExtensions\Masa.BuildingBlocks.Data.MappingExtensions.csproj", "{42D62996-F3FA-406F-AECD-BEACE557E0DB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -163,6 +165,10 @@ Global {775797E2-8576-4050-8649-18AAD00D0A87}.Debug|Any CPU.Build.0 = Debug|Any CPU {775797E2-8576-4050-8649-18AAD00D0A87}.Release|Any CPU.ActiveCfg = Release|Any CPU {775797E2-8576-4050-8649-18AAD00D0A87}.Release|Any CPU.Build.0 = Release|Any CPU + {42D62996-F3FA-406F-AECD-BEACE557E0DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {42D62996-F3FA-406F-AECD-BEACE557E0DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {42D62996-F3FA-406F-AECD-BEACE557E0DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {42D62996-F3FA-406F-AECD-BEACE557E0DB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -200,6 +206,7 @@ Global {EA5B1CAD-2275-43F3-9A50-7CE1FD94ACDB} = {64FB8703-E922-45DE-9D01-3FE9EFE56727} {4B9BF713-E0BC-4CAB-9D8D-353C18EDC855} = {64FB8703-E922-45DE-9D01-3FE9EFE56727} {775797E2-8576-4050-8649-18AAD00D0A87} = {593A3114-D1E0-47ED-BC37-58E08886175B} + {42D62996-F3FA-406F-AECD-BEACE557E0DB} = {64FB8703-E922-45DE-9D01-3FE9EFE56727} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {40383055-CC50-4600-AD9A-53C14F620D03} diff --git a/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/IEnvironmentProvider.cs b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/IEnvironmentProvider.cs new file mode 100644 index 0000000..63df11e --- /dev/null +++ b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/IEnvironmentProvider.cs @@ -0,0 +1,9 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.BasicAbility.Auth; + +public interface IEnvironmentProvider +{ + string GetEnvironment(); +} diff --git a/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Masa.BuildingBlocks.BasicAbility.Auth.csproj b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Masa.BuildingBlocks.BasicAbility.Auth.csproj index 132c02c..27ac386 100644 --- a/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Masa.BuildingBlocks.BasicAbility.Auth.csproj +++ b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Masa.BuildingBlocks.BasicAbility.Auth.csproj @@ -1,4 +1,4 @@ - + net6.0 diff --git a/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Model/MenuModel.cs b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Model/MenuModel.cs new file mode 100644 index 0000000..b2b4c4e --- /dev/null +++ b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Model/MenuModel.cs @@ -0,0 +1,19 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.BasicAbility.Auth.Model; + +public class MenuModel +{ + public Guid Id { get; set; } + + public string Name { get; set; } + + public string Code { get; set; } + + public string Icon { get; set; } + + public string Url { get; set; } + + public List Children { get; set; } = new(); +} diff --git a/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Model/TeamModel.cs b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Model/TeamModel.cs new file mode 100644 index 0000000..ed7c0a2 --- /dev/null +++ b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Model/TeamModel.cs @@ -0,0 +1,11 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.BasicAbility.Auth.Model; + +public class TeamModel +{ + public Guid Id { get; set; } + + public string Name { get; set; } +} diff --git a/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Service/IPermissionService.cs b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Service/IPermissionService.cs new file mode 100644 index 0000000..43e1509 --- /dev/null +++ b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Service/IPermissionService.cs @@ -0,0 +1,13 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.BasicAbility.Auth.Service; + +public interface IPermissionService +{ + Task> GetMenusAsync(string appId, Guid userId); + + Task> GetElementPermissionsAsync(string appId, Guid userId); + + Task AuthorizedAsync(string appId, string code, Guid userId); +} diff --git a/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Service/ITeamService.cs b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Service/ITeamService.cs index 61459d8..47b9a13 100644 --- a/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Service/ITeamService.cs +++ b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Service/ITeamService.cs @@ -6,5 +6,7 @@ namespace Masa.BuildingBlocks.BasicAbility.Auth.Service; public interface ITeamService { Task GetDetailAsync(Guid id); + + Task> GetListAsync(Guid userId = default); } diff --git a/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Service/IUserService.cs b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Service/IUserService.cs index 3f50fa4..79b337e 100644 --- a/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Service/IUserService.cs +++ b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Service/IUserService.cs @@ -12,5 +12,9 @@ public interface IUserService Task> GetListByDepartmentAsync(Guid departmentId); Task AddAsync(AddUserModel user); + + Task ValidateCredentialsByAccountAsync(string account, string password); + + Task FindByAccountAsync(string account); } diff --git a/src/Data/Masa.BuildingBlocks.Data.Mapping/Mapper.cs b/src/Data/Masa.BuildingBlocks.Data.Mapping/Mapper.cs new file mode 100644 index 0000000..567292c --- /dev/null +++ b/src/Data/Masa.BuildingBlocks.Data.Mapping/Mapper.cs @@ -0,0 +1,22 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.Data.Mapping; + +public sealed class Mapper +{ + public static Mapper? Instance { get; set; } + + private readonly IMapper _mapper; + + public Mapper(IServiceCollection services) => _mapper = services.BuildServiceProvider().GetRequiredService(); + + public TDestination Map(TSource source, MapOptions? options = null) + => _mapper.Map(source, options); + + public TDestination Map(object source, MapOptions? options = null) + => _mapper.Map(source, options); + + public TDestination Map(TSource source, TDestination destination, MapOptions? options = null) + => _mapper.Map(source, destination, options); +} diff --git a/src/Data/Masa.BuildingBlocks.Data.Mapping/Masa.BuildingBlocks.Data.Mapping.csproj b/src/Data/Masa.BuildingBlocks.Data.Mapping/Masa.BuildingBlocks.Data.Mapping.csproj index 0da2a6f..a4d5434 100644 --- a/src/Data/Masa.BuildingBlocks.Data.Mapping/Masa.BuildingBlocks.Data.Mapping.csproj +++ b/src/Data/Masa.BuildingBlocks.Data.Mapping/Masa.BuildingBlocks.Data.Mapping.csproj @@ -5,5 +5,9 @@ enable enable - + + + + + diff --git a/src/Data/Masa.BuildingBlocks.Data.Mapping/_Imports.cs b/src/Data/Masa.BuildingBlocks.Data.Mapping/_Imports.cs index 9fcedca..f9edf00 100644 --- a/src/Data/Masa.BuildingBlocks.Data.Mapping/_Imports.cs +++ b/src/Data/Masa.BuildingBlocks.Data.Mapping/_Imports.cs @@ -3,3 +3,4 @@ global using Masa.BuildingBlocks.Data.Mapping.Options; global using Masa.BuildingBlocks.Data.Mapping.Options.Enum; +global using Microsoft.Extensions.DependencyInjection; diff --git a/src/Data/Masa.BuildingBlocks.Data.MappingExtensions/Masa.BuildingBlocks.Data.MappingExtensions.csproj b/src/Data/Masa.BuildingBlocks.Data.MappingExtensions/Masa.BuildingBlocks.Data.MappingExtensions.csproj new file mode 100644 index 0000000..12c5adf --- /dev/null +++ b/src/Data/Masa.BuildingBlocks.Data.MappingExtensions/Masa.BuildingBlocks.Data.MappingExtensions.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/src/Data/Masa.BuildingBlocks.Data.MappingExtensions/ObjectExtensions.cs b/src/Data/Masa.BuildingBlocks.Data.MappingExtensions/ObjectExtensions.cs new file mode 100644 index 0000000..1a6e92f --- /dev/null +++ b/src/Data/Masa.BuildingBlocks.Data.MappingExtensions/ObjectExtensions.cs @@ -0,0 +1,19 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace System; + +public static class ObjectExtensions +{ + private static Mapper? _mapper; + private static Mapper GetMapper() => _mapper ??= Mapper.Instance ?? throw new Exception("Please use MapperFactory to initialize Mapper"); + + public static TDestination Map(this TSource source, MapOptions? options = null) + => GetMapper().Map(source, options); + + public static TDestination Map(this object obj, MapOptions? options = null) + => GetMapper().Map(obj, options); + + public static TDestination Map(this TSource source, TDestination destination, MapOptions? options = null) + => GetMapper().Map(source, destination, options); +} diff --git a/src/Data/Masa.BuildingBlocks.Data.MappingExtensions/_Imports.cs b/src/Data/Masa.BuildingBlocks.Data.MappingExtensions/_Imports.cs new file mode 100644 index 0000000..e7ac38d --- /dev/null +++ b/src/Data/Masa.BuildingBlocks.Data.MappingExtensions/_Imports.cs @@ -0,0 +1,5 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +global using Masa.BuildingBlocks.Data.Mapping; +global using Masa.BuildingBlocks.Data.Mapping.Options; diff --git a/src/Data/Masa.BuildingBlocks.Data/Enum/SequentialGuidType.cs b/src/Data/Masa.BuildingBlocks.Data/Enum/SequentialGuidType.cs new file mode 100644 index 0000000..40a1554 --- /dev/null +++ b/src/Data/Masa.BuildingBlocks.Data/Enum/SequentialGuidType.cs @@ -0,0 +1,26 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.Data; + +public enum SequentialGuidType +{ + /// + /// The GUID should be sequential when formatted using the + /// Used by MySql and PostgreSql. + /// + SequentialAsString, + + /// + /// The GUID should be sequential when formatted using the + /// Used by Oracle. + /// + SequentialAsBinary, + + /// + /// The sequential portion of the GUID should be located at the end + /// of the Data4 block. + /// Used by SqlServer. + /// + SequentialAtEnd +} diff --git a/src/Data/Masa.BuildingBlocks.Data/Enum/TimestampType.cs b/src/Data/Masa.BuildingBlocks.Data/Enum/TimestampType.cs new file mode 100644 index 0000000..e221896 --- /dev/null +++ b/src/Data/Masa.BuildingBlocks.Data/Enum/TimestampType.cs @@ -0,0 +1,10 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.Data; + +public enum TimestampType +{ + Milliseconds = 1, + Seconds +} diff --git a/src/Data/Masa.BuildingBlocks.Data/IdGenerator/IGuidGenerator.cs b/src/Data/Masa.BuildingBlocks.Data/IdGenerator/IGuidGenerator.cs new file mode 100644 index 0000000..0e6180f --- /dev/null +++ b/src/Data/Masa.BuildingBlocks.Data/IdGenerator/IGuidGenerator.cs @@ -0,0 +1,8 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.Data; + +public interface IGuidGenerator : IIdGenerator +{ +} diff --git a/src/Data/Masa.BuildingBlocks.Data/IdGenerator/IIdGenerator.cs b/src/Data/Masa.BuildingBlocks.Data/IdGenerator/IIdGenerator.cs new file mode 100644 index 0000000..1f365a9 --- /dev/null +++ b/src/Data/Masa.BuildingBlocks.Data/IdGenerator/IIdGenerator.cs @@ -0,0 +1,11 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.Data; + +public interface IIdGenerator + where T : notnull + where TOut : notnull +{ + public TOut Create(); +} diff --git a/src/Data/Masa.BuildingBlocks.Data/IdGenerator/ISequentialGuidGenerator.cs b/src/Data/Masa.BuildingBlocks.Data/IdGenerator/ISequentialGuidGenerator.cs new file mode 100644 index 0000000..cb0c521 --- /dev/null +++ b/src/Data/Masa.BuildingBlocks.Data/IdGenerator/ISequentialGuidGenerator.cs @@ -0,0 +1,9 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.Data; + +public interface ISequentialGuidGenerator : IIdGenerator +{ + Guid Create(SequentialGuidType guidType); +} diff --git a/src/Data/Masa.BuildingBlocks.Data/IdGenerator/ISnowflakeGenerator.cs b/src/Data/Masa.BuildingBlocks.Data/IdGenerator/ISnowflakeGenerator.cs new file mode 100644 index 0000000..3b04cb7 --- /dev/null +++ b/src/Data/Masa.BuildingBlocks.Data/IdGenerator/ISnowflakeGenerator.cs @@ -0,0 +1,8 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.Data; + +public interface ISnowflakeGenerator : IIdGenerator +{ +} diff --git a/src/Data/Masa.BuildingBlocks.Data/IdGenerator/IdGeneratorFactory.cs b/src/Data/Masa.BuildingBlocks.Data/IdGenerator/IdGeneratorFactory.cs new file mode 100644 index 0000000..ac34d99 --- /dev/null +++ b/src/Data/Masa.BuildingBlocks.Data/IdGenerator/IdGeneratorFactory.cs @@ -0,0 +1,36 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.Data; + +public class IdGeneratorFactory +{ + private static IGuidGenerator? _guidGenerator; + public static IGuidGenerator GuidGenerator => _guidGenerator ?? throw new Exception($"Unsupported {nameof(GuidGenerator)}"); + + private static ISequentialGuidGenerator? _sequentialGuidGenerator; + public static ISequentialGuidGenerator SequentialGuidGenerator + => _sequentialGuidGenerator ?? throw new Exception($"Unsupported {nameof(SequentialGuidGenerator)}"); + + private static ISnowflakeGenerator? _snowflakeGenerator; + public static ISnowflakeGenerator SnowflakeGenerator + => _snowflakeGenerator ?? throw new Exception($"Unsupported {nameof(SnowflakeGenerator)}"); + + public static void SetGuidGenerator(IGuidGenerator guidGenerator) + { + ArgumentNullException.ThrowIfNull(guidGenerator, nameof(guidGenerator)); + _guidGenerator = guidGenerator; + } + + public static void SetSequentialGuidGenerator(ISequentialGuidGenerator sequentialGuidGenerator) + { + ArgumentNullException.ThrowIfNull(sequentialGuidGenerator, nameof(sequentialGuidGenerator)); + _sequentialGuidGenerator = sequentialGuidGenerator; + } + + public static void SetSnowflakeGenerator(ISnowflakeGenerator snowflakeGenerator) + { + ArgumentNullException.ThrowIfNull(snowflakeGenerator, nameof(snowflakeGenerator)); + _snowflakeGenerator = snowflakeGenerator; + } +} diff --git a/src/Data/Masa.BuildingBlocks.Data/Masa.BuildingBlocks.Data.csproj b/src/Data/Masa.BuildingBlocks.Data/Masa.BuildingBlocks.Data.csproj index eb2460e..d54911d 100644 --- a/src/Data/Masa.BuildingBlocks.Data/Masa.BuildingBlocks.Data.csproj +++ b/src/Data/Masa.BuildingBlocks.Data/Masa.BuildingBlocks.Data.csproj @@ -1,9 +1,13 @@ - - net6.0 - enable - enable - - + + net6.0 + enable + enable + + + + + + diff --git a/src/Data/Masa.BuildingBlocks.Data/MasaDbConnectionOptions.cs b/src/Data/Masa.BuildingBlocks.Data/Options/MasaDbConnectionOptions.cs similarity index 100% rename from src/Data/Masa.BuildingBlocks.Data/MasaDbConnectionOptions.cs rename to src/Data/Masa.BuildingBlocks.Data/Options/MasaDbConnectionOptions.cs diff --git a/src/Data/Masa.BuildingBlocks.Data/System/SequentialGuid.cs b/src/Data/Masa.BuildingBlocks.Data/System/SequentialGuid.cs new file mode 100644 index 0000000..b0eb7ed --- /dev/null +++ b/src/Data/Masa.BuildingBlocks.Data/System/SequentialGuid.cs @@ -0,0 +1,9 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace System; + +public readonly struct SequentialGuid +{ + +} diff --git a/src/Data/Masa.BuildingBlocks.Data/System/Snowflake.cs b/src/Data/Masa.BuildingBlocks.Data/System/Snowflake.cs new file mode 100644 index 0000000..1e8ff2d --- /dev/null +++ b/src/Data/Masa.BuildingBlocks.Data/System/Snowflake.cs @@ -0,0 +1,9 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace System; + +public readonly struct Snowflake +{ + +} diff --git a/src/Data/Masa.BuildingBlocks.Data/_Imports.cs b/src/Data/Masa.BuildingBlocks.Data/_Imports.cs index 5096951..233c163 100644 --- a/src/Data/Masa.BuildingBlocks.Data/_Imports.cs +++ b/src/Data/Masa.BuildingBlocks.Data/_Imports.cs @@ -2,4 +2,5 @@ // Licensed under the MIT License. See LICENSE.txt in the project root for license information. global using Masa.BuildingBlocks.Data.Options; +global using Microsoft.Extensions.DependencyInjection; global using System.Reflection; diff --git a/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/AggregateRoot.cs b/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/AggregateRoot.cs index ea8d43a..c5c53f9 100644 --- a/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/AggregateRoot.cs +++ b/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/AggregateRoot.cs @@ -37,10 +37,18 @@ public async Task PublishDomainEventsAsync(IDomainEventBus eventBus) } } -public class AggregateRoot : Entity, IAggregateRoot, IGenerateDomainEvents +public abstract class AggregateRoot : Entity, IAggregateRoot, IGenerateDomainEvents { protected readonly List _domainEvents = new(); + public AggregateRoot() : base() + { + } + + public AggregateRoot(TKey id) : base(id) + { + } + public virtual void AddDomainEvent(IDomainEvent domainEvent) { _domainEvents.Add(domainEvent); diff --git a/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Auditing/AuditAggregateRoot.cs b/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Auditing/AuditAggregateRoot.cs index 247c402..7730550 100644 --- a/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Auditing/AuditAggregateRoot.cs +++ b/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Auditing/AuditAggregateRoot.cs @@ -34,7 +34,15 @@ public abstract class AuditAggregateRoot : AggregateRoot, I public DateTime ModificationTime { get; protected set; } - public AuditAggregateRoot() => Initialize(); + public AuditAggregateRoot() : base() + { + Initialize(); + } + + public AuditAggregateRoot(TKey id) : base(id) + { + Initialize(); + } public void Initialize() { diff --git a/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Auditing/AuditEntity.cs b/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Auditing/AuditEntity.cs index 657a5e0..cee548d 100644 --- a/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Auditing/AuditEntity.cs +++ b/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Auditing/AuditEntity.cs @@ -34,7 +34,15 @@ public abstract class AuditEntity : Entity, IAuditEntity Initialize(); + public AuditEntity() : base() + { + Initialize(); + } + + public AuditEntity(TKey id) : base(id) + { + Initialize(); + } public void Initialize() { diff --git a/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Entity.cs b/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Entity.cs index 4fa55b1..125e7a3 100644 --- a/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Entity.cs +++ b/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Entity.cs @@ -61,10 +61,16 @@ public override int GetHashCode() } } -public class Entity : Entity, IEntity +public abstract class Entity : Entity, IEntity { public TKey Id { get; protected set; } = default!; + protected Entity() + { + } + + protected Entity(TKey id) : this() => Id = id; + public override IEnumerable<(string Name, object Value)> GetKeys() { yield return ("Id", Id!); diff --git a/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Full/FullAggregateRoot.cs b/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Full/FullAggregateRoot.cs index 9622a7c..79b0b08 100644 --- a/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Full/FullAggregateRoot.cs +++ b/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Full/FullAggregateRoot.cs @@ -13,4 +13,12 @@ public abstract class FullAggregateRoot : AuditAggregateRoot, IFullAggregateRoot { public bool IsDeleted { get; protected set; } + + public FullAggregateRoot() : base() + { + } + + public FullAggregateRoot(TKey id) : base(id) + { + } } diff --git a/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Full/FullEntity.cs b/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Full/FullEntity.cs index 4de2eb2..86e51d8 100644 --- a/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Full/FullEntity.cs +++ b/src/Ddd/Masa.BuildingBlocks.Ddd.Domain/Entities/Full/FullEntity.cs @@ -13,4 +13,12 @@ public abstract class FullEntity : AuditEntity, IFullEntity { public bool IsDeleted { get; protected set; } + + public FullEntity() : base() + { + } + + public FullEntity(TKey id) : base(id) + { + } } diff --git a/src/SearchEngine/Masa.BuildingBlocks.SearchEngine.AutoComplete/Masa.BuildingBlocks.SearchEngine.AutoComplete.csproj b/src/SearchEngine/Masa.BuildingBlocks.SearchEngine.AutoComplete/Masa.BuildingBlocks.SearchEngine.AutoComplete.csproj index eb2460e..ca62071 100644 --- a/src/SearchEngine/Masa.BuildingBlocks.SearchEngine.AutoComplete/Masa.BuildingBlocks.SearchEngine.AutoComplete.csproj +++ b/src/SearchEngine/Masa.BuildingBlocks.SearchEngine.AutoComplete/Masa.BuildingBlocks.SearchEngine.AutoComplete.csproj @@ -1,4 +1,4 @@ - + net6.0 From 6f51efd26ac36aafe61ec1d78d48151f0eb34a3a Mon Sep 17 00:00:00 2001 From: Mayue Date: Thu, 9 Jun 2022 09:35:12 +0800 Subject: [PATCH 2/2] feat:add team avatar --- .../Masa.BuildingBlocks.BasicAbility.Auth/IAuthClient.cs | 2 ++ .../Masa.BuildingBlocks.BasicAbility.Auth/Model/TeamModel.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/IAuthClient.cs b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/IAuthClient.cs index 8f8ceed..173c0be 100644 --- a/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/IAuthClient.cs +++ b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/IAuthClient.cs @@ -10,5 +10,7 @@ public interface IAuthClient ISubjectService SubjectService { get; } ITeamService TeamService { get; } + + IPermissionService PermissionService { get; } } diff --git a/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Model/TeamModel.cs b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Model/TeamModel.cs index ed7c0a2..b9db79b 100644 --- a/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Model/TeamModel.cs +++ b/src/BasicAbility/Masa.BuildingBlocks.BasicAbility.Auth/Model/TeamModel.cs @@ -8,4 +8,6 @@ public class TeamModel public Guid Id { get; set; } public string Name { get; set; } + + public string Avatar { get; set; } }