Skip to content

Commit

Permalink
feat: support for postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
Qinyouzeng committed Dec 6, 2024
1 parent e92713b commit 61d6515
Show file tree
Hide file tree
Showing 143 changed files with 3,619 additions and 1,811 deletions.
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/App/Aggregates/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.App.Aggregates;

[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/App/Aggregates/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.App.Aggregates;

[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/App/Aggregates/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.App.Aggregates;

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/App/Aggregates/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.App.Aggregates;

[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/App/Aggregates/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.App.Aggregates;

[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/App/Aggregates/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.App.Aggregates;

[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/App/Aggregates/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.App.Aggregates;

[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.App.Aggregates;

public abstract class ConfigObjectBase : FullAggregateRoot<int, Guid>
{
Expand Down
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.App.Aggregates;

[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/App/Aggregates/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.App.Aggregates;

[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

0 comments on commit 61d6515

Please sign in to comment.