Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat:support postgresql #644

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<MasaFrameworkPackageVersion>1.2.0-preview.2</MasaFrameworkPackageVersion>
<MasaStackSdksPackageVersion>1.2.1-preview.4</MasaStackSdksPackageVersion>
<MasaFrameworkPackageVersion>1.2.0-preview.4</MasaFrameworkPackageVersion>
<MasaStackSdksPackageVersion>1.2.1-preview.8</MasaStackSdksPackageVersion>
</PropertyGroup>
</Project>
38 changes: 38 additions & 0 deletions Masa.Dcc.Infrastructure.Domain.Shared/App/App.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 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.Infrastructure.Domain.Shared;

[NotMapped]
public class App
{
public int Id { get; set; }

public string Name { get; set; } = "";

public string Identity { get; set; } = "";

public AppTypes Type { get; set; }

public ServiceTypes ServiceType { get; set; }

public string Url { get; set; } = "";

public string SwaggerUrl { get; set; } = "";

public string Description { get; set; } = "";

public DateTime CreationTime { get; set; }

public Guid Creator { get; set; }

public DateTime ModificationTime { get; set; }

public Guid Modifier { get; set; }

private readonly List<AppConfigObject> _appConfigObjects = new();
public IReadOnlyCollection<AppConfigObject> AppConfigObjects => _appConfigObjects;

private readonly List<AppSecret> _appSecrets = new();
public IReadOnlyCollection<AppSecret> AppSecrets => _appSecrets;
}
19 changes: 19 additions & 0 deletions Masa.Dcc.Infrastructure.Domain.Shared/App/AppConfigObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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.Infrastructure.Domain.Shared;

[Table("AppConfigObjects")]
public class AppConfigObject : ConfigObjectBase
{
[Comment("AppId")]
[Required]
[Range(1, int.MaxValue)]
public int AppId { get; private set; }

public AppConfigObject(int appId, int environmentClusterId)
{
EnvironmentClusterId = environmentClusterId;
AppId = appId;
}
}
16 changes: 16 additions & 0 deletions Masa.Dcc.Infrastructure.Domain.Shared/App/AppPin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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.Infrastructure.Domain.Shared;

public class AppPin : FullAggregateRoot<int, Guid>
{
[Required]
[Range(1, int.MaxValue)]
public int AppId { get; set; }

public AppPin(int appId)
{
AppId = appId;
}
}
26 changes: 26 additions & 0 deletions Masa.Dcc.Infrastructure.Domain.Shared/App/AppSecret.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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.Infrastructure.Domain.Shared;

[Table("AppSecrets")]
public class AppSecret : FullAggregateRoot<int, Guid>
{
[Required]
[Range(1, int.MaxValue)]
public int AppId { get; private set; }

[Required]
[Range(1, int.MaxValue)]
public int EnvironmentId { get; private set; }

[Required]
[Range(1, int.MaxValue)]
public SecretType Type { get; private set; }

[Required]
public Guid EncryptionSecret { get; private set; }

[Required]
public Guid Secret { get; private set; }
}
28 changes: 28 additions & 0 deletions Masa.Dcc.Infrastructure.Domain.Shared/App/BizConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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.Infrastructure.Domain.Shared;

[Table("BizConfigs")]
public class BizConfig : FullAggregateRoot<int, Guid>
{
[Required]
public string Name { get; private set; }

[Required]
public string Identity { get; private set; }

private readonly List<BizConfigObject> _bizConfigObjects = new();
public IReadOnlyCollection<BizConfigObject> BizConfigObjects => _bizConfigObjects;

public BizConfig(string name, string identity)
{
Name = name;
Identity = identity;
}

public void Update(string name)
{
Name = name;
}
}
20 changes: 20 additions & 0 deletions Masa.Dcc.Infrastructure.Domain.Shared/App/BizConfigObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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.Infrastructure.Domain.Shared;

[Table("BizConfigObjects")]
public class BizConfigObject : ConfigObjectBase
{
[Required]
[Range(1, int.MaxValue)]
public int BizConfigId { get; private set; }

public BizConfig BizConfig { get; private set; } = null!;

public BizConfigObject(int bizConfigId, int environmentClusterId)
{
BizConfigId = bizConfigId;
EnvironmentClusterId = environmentClusterId;
}
}
116 changes: 116 additions & 0 deletions Masa.Dcc.Infrastructure.Domain.Shared/App/ConfigObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// 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.Infrastructure.Domain.Shared;

[Table("ConfigObjects")]
public class ConfigObject : FullAggregateRoot<int, Guid>
{
[Comment("Name")]
[Required(ErrorMessage = "Config object name is required")]
[StringLength(100, MinimumLength = 2, ErrorMessage = "Config object name length range is [2-100]")]
public string Name { get; private set; }

[Comment("Format")]
[Required(ErrorMessage = "Format Label Code is required")]
[StringLength(100, MinimumLength = 2, ErrorMessage = "Format Label Code length range is [2-100]")]
public string FormatLabelCode { get; private set; }

[Comment("Type")]
[Range(1, int.MaxValue, ErrorMessage = "Type is required")]
public ConfigObjectType Type { get; private set; }

[Required]
public bool Encryption { get; private set; }

[Required]
public string Content { get; private set; }

[Required]
public string TempContent { get; private set; }

[Comment("Relation config object Id")]
public int RelationConfigObjectId { get; private set; }

public bool FromRelation { get; private set; }

public PublicConfigObject PublicConfigObject { get; private set; } = null!;

public BizConfigObject BizConfigObject { get; set; } = null!;

public AppConfigObject AppConfigObject { get; private set; } = null!;

private readonly List<ConfigObjectRelease> _configObjectRelease = new();
public IReadOnlyCollection<ConfigObjectRelease> ConfigObjectRelease => _configObjectRelease;

public ConfigObject(string name, string formatLabelCode, ConfigObjectType type, string content, string tempContent, int relationConfigObjectId = 0, bool fromRelation = false, bool encryption = false)
{
Name = name;
FormatLabelCode = formatLabelCode;
Type = type;
Content = content;
TempContent = tempContent;
RelationConfigObjectId = relationConfigObjectId;
FromRelation = fromRelation;
Encryption = encryption;
}

public void SetConfigObjectType(ConfigObjectType type)
{
Type = type;
}

public void SetConfigObjectRelease(IEnumerable<ConfigObjectRelease> configObjectReleases)
{
_configObjectRelease.Clear();
_configObjectRelease.TryAddRange(configObjectReleases);
}

public void SetConfigObjectRelease(ConfigObjectRelease configObjectRelease)
{
_configObjectRelease.Clear();
_configObjectRelease.TryAdd(configObjectRelease);
}

public void UpdateContent(string content)
{
Content = content;
}

public void AddContent(string content, string tempContent)
{
Content = content;
TempContent = tempContent;
}

public void SetPublicConfigObject(int publicConfigId, int environmentClusterId)
{
PublicConfigObject = new PublicConfigObject(publicConfigId, environmentClusterId);
}

public void SetBizConfigObject(int bizId, int environmentClusterId)
{
BizConfigObject = new BizConfigObject(bizId, environmentClusterId);
}

public void SetAppConfigObject(int appId, int environmentClusterId)
{
AppConfigObject = new AppConfigObject(appId, environmentClusterId);
}

public void Revoke()
{
Content = TempContent;
}

public void Relation(int relationConfigObjectId)
{
RelationConfigObjectId = relationConfigObjectId;
FromRelation = true;
}

public void UnRelation()
{
RelationConfigObjectId = 0;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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.Domain.App.Aggregates;
namespace Masa.Dcc.Infrastructure.Domain.Shared;

public abstract class ConfigObjectBase : FullAggregateRoot<int, Guid>
{
Expand Down
57 changes: 57 additions & 0 deletions Masa.Dcc.Infrastructure.Domain.Shared/App/ConfigObjectRelease.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// 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.Infrastructure.Domain.Shared;

[Table("ConfigObjectReleases")]
public class ConfigObjectRelease : FullAggregateRoot<int, Guid>
{
[Comment("Release type")]
public ReleaseType Type { get; set; }

[Comment("Config object Id")]
[Required(ErrorMessage = "Config object Id is required")]
[Range(minimum: 1, maximum: int.MaxValue, ErrorMessage = "Config object Id is required")]
public int ConfigObjectId { get; set; }

[Comment("Rollback From Release Id")]
public int FromReleaseId { get; set; }

[Comment("If it is rolled back, it will be true")]
public bool IsInvalid { get; set; }

[Comment("Version format is yyyyMMddHHmmss")]
[Required(ErrorMessage = "Version is required")]
public string Version { get; set; }

[Comment("Name")]
[Required(ErrorMessage = "Name is required", AllowEmptyStrings = true)]
[StringLength(100, MinimumLength = 2, ErrorMessage = "Name length range is [2-100]")]
public string Name { get; set; }

[Comment("Comment")]
[Required(ErrorMessage = "Comment is required", AllowEmptyStrings = true)]
[StringLength(500, MinimumLength = 0, ErrorMessage = "Comment length range is [0-500]")]
public string Comment { get; set; }

[Comment("Content")]
[Required(ErrorMessage = "Content is required", AllowEmptyStrings = true)]
[StringLength(int.MaxValue, MinimumLength = 1, ErrorMessage = "Content length range is [1-2147483647]")]
public string Content { get; set; }

public ConfigObjectRelease(int configObjectId, string name, string comment, string content, string? version = null, int fromReleaseId = 0, ReleaseType type = ReleaseType.MainRelease)
{
ConfigObjectId = configObjectId;
Name = name;
Comment = comment;
Content = content;
Version = version ?? DateTime.UtcNow.ToString("yyyyMMddHHmmss");
FromReleaseId = fromReleaseId;
Type = type;
}

public void Invalid()
{
IsInvalid = true;
}
}
33 changes: 33 additions & 0 deletions Masa.Dcc.Infrastructure.Domain.Shared/App/PublicConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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.Infrastructure.Domain.Shared;

[Table("PublicConfigs")]
public class PublicConfig : FullAggregateRoot<int, Guid>
{
[Required]
public string Name { get; private set; }

[Required]
public string Identity { get; private set; }

[Required]
public string Description { get; private set; }

private readonly List<PublicConfigObject> _publicConfigObjects = new();
public IReadOnlyCollection<PublicConfigObject> PublicConfigObjects => _publicConfigObjects;

public PublicConfig(string name, string identity, string description = "")
{
Name = name;
Identity = identity;
Description = description;
}

public void Update(string name, string description)
{
Name = name;
Description = description;
}
}
Loading
Loading