-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61d6515
commit 3b007c6
Showing
76 changed files
with
684 additions
and
634 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...frastructure.Domain/App/Aggregates/App.cs → ...c.Infrastructure.Domain.Shared/App/App.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
....Domain/App/Aggregates/AppConfigObject.cs → ...ture.Domain.Shared/App/AppConfigObject.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...structure.Domain/App/Aggregates/AppPin.cs → ...nfrastructure.Domain.Shared/App/AppPin.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ucture.Domain/App/Aggregates/AppSecret.cs → ...astructure.Domain.Shared/App/AppSecret.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ucture.Domain/App/Aggregates/BizConfig.cs → ...astructure.Domain.Shared/App/BizConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
....Domain/App/Aggregates/BizConfigObject.cs → ...ture.Domain.Shared/App/BizConfigObject.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Domain/App/Aggregates/ConfigObjectBase.cs → ...ure.Domain.Shared/App/ConfigObjectBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ure.Domain/App/Aggregates/PublicConfig.cs → ...ructure.Domain.Shared/App/PublicConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...main/App/Aggregates/PublicConfigObject.cs → ...e.Domain.Shared/App/PublicConfigObject.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...tructure.Domain/Label/Aggregates/Label.cs → ...frastructure.Domain.Shared/Label/Label.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
Masa.Dcc.Infrastructure.Domain.Shared/Masa.Dcc.Infrastructure.Domain.Shared.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Masa.BuildingBlocks.Ddd.Domain" Version="$(MasaFrameworkPackageVersion)" /> | ||
<PackageReference Include="Masa.Contrib.Ddd.Domain" Version="$(MasaFrameworkPackageVersion)" /> | ||
<PackageReference Include="Masa.Contrib.StackSdks.Pm" Version="$(MasaStackSdksPackageVersion)" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="6.0.7.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\src\Contracts\Masa.Dcc.Contracts.Admin\Masa.Dcc.Contracts.Admin.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (c) MASA Stack All rights reserved. | ||
// Licensed under the Apache License. See LICENSE.txt in the project root for license information. | ||
|
||
global using System.ComponentModel.DataAnnotations; | ||
global using System.ComponentModel.DataAnnotations.Schema; | ||
global using Masa.BuildingBlocks.Ddd.Domain.Entities.Full; | ||
global using Masa.BuildingBlocks.StackSdks.Pm.Enum; | ||
global using Masa.BuildingBlocks.StackSdks.Pm.Model; | ||
global using Masa.Dcc.Contracts.Admin.App.Enums; | ||
global using Microsoft.EntityFrameworkCore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
// Copyright (c) MASA Stack All rights reserved. | ||
// Licensed under the Apache License. See LICENSE.txt in the project root for license information. | ||
|
||
namespace Masa.Dcc.Service.Admin.Application.App; | ||
|
||
internal class CommandHandler | ||
{ | ||
private readonly IPublicConfigRepository _publicConfigRepository; | ||
private readonly IConfigObjectRepository _configObjectRepository; | ||
private readonly IAppPinRepository _appPinRepository; | ||
private readonly IBizConfigRepository _bizConfigRepository; | ||
private readonly ConfigObjectDomainService _configObjectDomainService; | ||
private readonly IUnitOfWork _unitOfWork; | ||
|
||
public CommandHandler( | ||
IPublicConfigRepository publicConfigRepository, | ||
IConfigObjectRepository configObjectRepository, | ||
IAppPinRepository appPinRepository, | ||
IBizConfigRepository bizConfigRepository, | ||
ConfigObjectDomainService configObjectDomainService, | ||
IUnitOfWork unitOfWork) | ||
{ | ||
_publicConfigRepository = publicConfigRepository; | ||
_configObjectRepository = configObjectRepository; | ||
_appPinRepository = appPinRepository; | ||
_bizConfigRepository = bizConfigRepository; | ||
_configObjectDomainService = configObjectDomainService; | ||
_unitOfWork = unitOfWork; | ||
} | ||
|
||
#region PublicConfig | ||
|
||
[EventHandler] | ||
public async Task AddPublicConfigAsync(AddPublicConfigCommand command) | ||
{ | ||
var publicConfig = command.AddPublicConfigDto; | ||
|
||
var result = await _publicConfigRepository.AddAsync( | ||
new PublicConfig(publicConfig.Name, publicConfig.Identity, publicConfig.Description)); | ||
|
||
command.PublicConfigDto = result.Adapt<PublicConfigDto>(); | ||
} | ||
|
||
[EventHandler] | ||
public async Task UpdatePublicConfigAsync(UpdatePublicConfigCommand command) | ||
{ | ||
var publicConfig = command.UpdatePublicConfigDto; | ||
var publicConfigEntity = await _publicConfigRepository.FindAsync(p => p.Id == publicConfig.Id) | ||
?? throw new UserFriendlyException("Public config does not exist"); | ||
|
||
publicConfigEntity.Update(publicConfig.Name, publicConfig.Description); | ||
await _publicConfigRepository.UpdateAsync(publicConfigEntity); | ||
} | ||
|
||
[EventHandler] | ||
public async Task RemovePublicConfigAsync(RemovePublicConfigCommand command) | ||
{ | ||
var publicConfigEntity = await _publicConfigRepository.FindAsync(p => p.Id == command.PublicConfigId) | ||
?? throw new UserFriendlyException("Public config does not exist"); | ||
|
||
await _publicConfigRepository.RemoveAsync(publicConfigEntity); | ||
} | ||
|
||
#endregion | ||
|
||
#region BizConfig | ||
|
||
[EventHandler] | ||
public async Task AddBizConfigAsync(AddBizConfigCommand command) | ||
{ | ||
var bizConfig = command.AddBizConfigDto; | ||
|
||
var result = await _bizConfigRepository.AddAsync(new BizConfig(bizConfig.Name, bizConfig.Identity)); | ||
|
||
await _unitOfWork.SaveChangesAsync(); | ||
|
||
command.BizConfigDto = result.Adapt<BizConfigDto>(); | ||
} | ||
|
||
[EventHandler] | ||
public async Task UpdateBizConfigAsync(UpdateBizConfigCommand command) | ||
{ | ||
var bizConfig = command.UpdateBizConfigDto; | ||
var bizConfigEntity = await _bizConfigRepository.FindAsync(p => p.Id == bizConfig.Id) | ||
?? throw new UserFriendlyException("biz config does not exist"); | ||
|
||
bizConfigEntity.Update(bizConfig.Name); | ||
var result = await _bizConfigRepository.UpdateAsync(bizConfigEntity); | ||
|
||
command.BizConfigDto = result.Adapt<BizConfigDto>(); | ||
} | ||
|
||
#endregion | ||
|
||
#region ConfigObject | ||
|
||
[EventHandler] | ||
public async Task AddConfigObjectAsync(AddConfigObjectCommand command) | ||
{ | ||
await _configObjectDomainService.AddConfigObjectAsync(command.ConfigObjectDtos); | ||
} | ||
|
||
[EventHandler] | ||
public async Task RemoveConfigObjectAsync(RemoveConfigObjectCommand command) | ||
{ | ||
await _configObjectDomainService.RemoveConfigObjectAsync(command.ConfigObjectDto); | ||
} | ||
|
||
[EventHandler] | ||
public async Task UpdateConfigObjectContentAsync(UpdateConfigObjectContentCommand command) | ||
{ | ||
await _configObjectDomainService.UpdateConfigObjectContentAsync(command.ConfigObjectContent); | ||
} | ||
|
||
[EventHandler] | ||
public async Task RevokeConfigObjectAsync(RevokeConfigObjectCommand command) | ||
{ | ||
var configObject = await _configObjectRepository.FindAsync(configObject => configObject.Id == command.ConfigObjectId); | ||
|
||
if (configObject == null) | ||
{ | ||
throw new UserFriendlyException("Config object does not exist"); | ||
} | ||
|
||
configObject.Revoke(); | ||
|
||
await _configObjectRepository.UpdateAsync(configObject); | ||
} | ||
|
||
[EventHandler] | ||
public async Task CloneConfigObjectAsync(CloneConfigObjectCommand command) | ||
{ | ||
await _configObjectDomainService.CloneConfigObjectAsync(command.CloneConfigObject); | ||
} | ||
|
||
#endregion | ||
|
||
#region Release | ||
|
||
[EventHandler] | ||
public async Task AddConfigObjectRelease(AddConfigObjectReleaseCommand command) | ||
{ | ||
await _configObjectDomainService.AddConfigObjectReleaseAsync(command.ConfigObjectRelease); | ||
} | ||
|
||
[EventHandler] | ||
public async Task RollbackConfigObjectReleaseAsync(RollbackConfigObjectReleaseCommand command) | ||
{ | ||
await _configObjectDomainService.RollbackConfigObjectReleaseAsync(command.RollbackConfigObjectRelease); | ||
} | ||
|
||
#endregion | ||
|
||
#region App | ||
|
||
[EventHandler] | ||
public async Task AddAppPinAsync(AddAppPinCommand command) | ||
{ | ||
await _appPinRepository.AddAsync(new AppPin(command.AppId)); | ||
} | ||
|
||
[EventHandler] | ||
public async Task RemoveAppPinAsync(RemoveAppPinCommand command) | ||
{ | ||
var appPin = await _appPinRepository.FindAsync(appPin => appPin.AppId == command.AppId); | ||
|
||
if (appPin != null) | ||
await _appPinRepository.RemoveAsync(appPin); | ||
} | ||
|
||
#endregion | ||
|
||
[EventHandler] | ||
public async Task UpdateConfigObjectAsync(UpdateConfigAndPublishCommand command) | ||
{ | ||
await _configObjectDomainService.UpdateConfigObjectAsync(command.Environment, command.Cluster, | ||
command.AppId, command.ConfigObject, command.Value); | ||
} | ||
|
||
[EventHandler] | ||
public async Task InitConfigObjectAsync(InitConfigObjectCommand command) | ||
{ | ||
await _configObjectDomainService.InitConfigObjectAsync(command.Environment, command.Cluster, | ||
command.AppId, command.ConfigObjects, command.ConfigObjectType, command.IsEncryption); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...lication/App/Commands/AddAppPinCommand.cs → ...e.Domain/App/Commands/AddAppPinCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ation/App/Commands/AddBizConfigCommand.cs → ...omain/App/Commands/AddBizConfigCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...on/App/Commands/AddConfigObjectCommand.cs → ...in/App/Commands/AddConfigObjectCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.