diff --git a/Directory.Packages.props b/Directory.Packages.props
index f6010c4..53f66bc 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -2,10 +2,10 @@
true
true
- 8.1.21
+ 8.1.22
-
+
@@ -29,22 +29,22 @@
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
+
+
+
@@ -52,14 +52,14 @@
-
+
-
-
-
-
-
+
+
+
+
+
@@ -72,7 +72,7 @@
-
+
@@ -102,9 +102,9 @@
-
-
-
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/Source/Starfish.Client/Clients/HttpConfigurationClient.cs b/Source/Starfish.Client/Clients/HttpConfigurationClient.cs
index 22054c4..bdf0f49 100644
--- a/Source/Starfish.Client/Clients/HttpConfigurationClient.cs
+++ b/Source/Starfish.Client/Clients/HttpConfigurationClient.cs
@@ -4,16 +4,14 @@ internal class HttpConfigurationClient : IConfigurationClient
{
private readonly HttpClient _httpClient = new();
- private readonly string _app;
+ private readonly string _id;
private readonly string _secret;
- private readonly string _env;
- public HttpConfigurationClient(Uri host, string app, string secret, string env)
+ public HttpConfigurationClient(Uri host, string id, string secret)
{
_httpClient.BaseAddress = host;
- _app = app;
+ _id = id;
_secret = secret;
- _env = env;
// _httpClient.DefaultRequestHeaders.Add(Constants.RequestHeaders.Team, team);
// _httpClient.DefaultRequestHeaders.Add(Constants.RequestHeaders.App, app);
@@ -28,7 +26,7 @@ public async Task GetConfigurationAsync(Action dataAction, Cancella
try
{
attempts++;
- using var request = new HttpRequestMessage(HttpMethod.Get, $"es?app={_app}&secret={_secret}&env={_env}");
+ using var request = new HttpRequestMessage(HttpMethod.Get, $"es?id={_id}&secret={_secret}");
var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
diff --git a/Source/Starfish.Client/Clients/SocketConfigurationClient.cs b/Source/Starfish.Client/Clients/SocketConfigurationClient.cs
index 93b827f..6f43c34 100644
--- a/Source/Starfish.Client/Clients/SocketConfigurationClient.cs
+++ b/Source/Starfish.Client/Clients/SocketConfigurationClient.cs
@@ -7,9 +7,9 @@ internal class SocketConfigurationClient : IConfigurationClient
private readonly ClientWebSocket _client = new();
private readonly Uri _uri;
- public SocketConfigurationClient(Uri host, string app, string secret, string env)
+ public SocketConfigurationClient(Uri host, string id, string secret)
{
- _uri = new Uri($"{host.AbsoluteUri}ws?app={app}&secret={secret}&env={env}");
+ _uri = new Uri($"{host.AbsoluteUri}ws?app={id}&secret={secret}");
// _client.Options.SetRequestHeader(Constants.RequestHeaders.Team, team);
// _client.Options.SetRequestHeader(Constants.RequestHeaders.App, app);
// _client.Options.SetRequestHeader(Constants.RequestHeaders.Secret, secret);
diff --git a/Source/Starfish.Client/ConfigurationClientOptions.cs b/Source/Starfish.Client/ConfigurationClientOptions.cs
index 8591507..6319cf6 100644
--- a/Source/Starfish.Client/ConfigurationClientOptions.cs
+++ b/Source/Starfish.Client/ConfigurationClientOptions.cs
@@ -10,12 +10,7 @@ public class ConfigurationClientOptions
///
/// 应用Id
///
- public string App { get; set; }
-
- ///
- /// 应用环境
- ///
- public string Env { get; set; }
+ public string Id { get; set; }
///
/// 密钥
@@ -67,9 +62,9 @@ public static ConfigurationClientOptions Load(IConfiguration configuration)
throw new InvalidOperationException(Resources.IDS_ERROR_STARFISH_SECTION_NOT_FOUND);
}
- var app = section[nameof(App)];
+ var id = section[nameof(Id)];
- if (string.IsNullOrWhiteSpace(app))
+ if (string.IsNullOrWhiteSpace(id))
{
throw new InvalidOperationException(Resources.IDS_ERROR_APP_SECTION_NOT_FOUND);
}
@@ -83,8 +78,7 @@ public static ConfigurationClientOptions Load(IConfiguration configuration)
var options = new ConfigurationClientOptions
{
Host = host,
- App = app,
- Env = section[nameof(Env)] ?? Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"),
+ Id = id,
Secret = section[nameof(Secret)],
CacheDirectory = section[nameof(CacheDirectory)] ?? AppDomain.CurrentDomain.BaseDirectory
};
diff --git a/Source/Starfish.Client/StarfishConfigurationProvider.cs b/Source/Starfish.Client/StarfishConfigurationProvider.cs
index 5a4a1e2..14dd668 100644
--- a/Source/Starfish.Client/StarfishConfigurationProvider.cs
+++ b/Source/Starfish.Client/StarfishConfigurationProvider.cs
@@ -21,7 +21,7 @@ internal class StarfishConfigurationProvider : ConfigurationProvider, IDisposabl
public StarfishConfigurationProvider(ConfigurationClientOptions options)
{
_options = options;
- _cacheFile = Path.Combine(_options.CacheDirectory, $"{_options.App}.starfish.{_options.Env}.cache");
+ _cacheFile = Path.Combine(_options.CacheDirectory, $"{_options.Id}.starfish.cache");
HostChanged += OnHostChanged;
ConnectionLost += (_, _) =>
{
@@ -58,8 +58,8 @@ private async void OnHostChanged(object sender, HostChangedEventArgs args)
var uri = new Uri(args.Host);
IConfigurationClient client = uri.Scheme switch
{
- "http" or "https" => new HttpConfigurationClient(uri, _options.App, _options.Secret, _options.Env),
- "ws" or "wss" => new SocketConfigurationClient(uri, _options.App, _options.Secret, _options.Env),
+ "http" or "https" => new HttpConfigurationClient(uri, _options.Id, _options.Secret),
+ "ws" or "wss" => new SocketConfigurationClient(uri, _options.Id, _options.Secret),
_ => throw new NotSupportedException(string.Format(Resources.IDS_ERROR_SCHEMA_NOT_SUPPORTED, uri.Scheme)),
};
try
diff --git a/Source/Starfish.Common/PermissionState.cs b/Source/Starfish.Common/PermissionState.cs
new file mode 100644
index 0000000..52d969e
--- /dev/null
+++ b/Source/Starfish.Common/PermissionState.cs
@@ -0,0 +1,8 @@
+namespace Nerosoft.Starfish.Common;
+
+public enum PermissionState
+{
+ None = 0,
+ Read = 1,
+ Edit = 2
+}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/ApplicationServiceModule.cs b/Source/Starfish.Service/Application/ApplicationServiceModule.cs
index cabe786..26e53bc 100644
--- a/Source/Starfish.Service/Application/ApplicationServiceModule.cs
+++ b/Source/Starfish.Service/Application/ApplicationServiceModule.cs
@@ -32,7 +32,6 @@ public override void AheadConfigureServices(ServiceConfigurationContext context)
{
options.AddProfile();
options.AddProfile();
- options.AddProfile();
options.AddProfile();
});
}
diff --git a/Source/Starfish.Service/Application/Commands/Configs/AppInfoCreateCommand.cs b/Source/Starfish.Service/Application/Commands/Configs/AppInfoCreateCommand.cs
deleted file mode 100644
index ca664de..0000000
--- a/Source/Starfish.Service/Application/Commands/Configs/AppInfoCreateCommand.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using Nerosoft.Euonia.Domain;
-using Nerosoft.Starfish.Transit;
-
-namespace Nerosoft.Starfish.Application;
-
-///
-/// 创建应用信息命令
-///
-public class AppInfoCreateCommand : Command
-{
- ///
- /// 构造函数
- ///
- ///
- public AppInfoCreateCommand(AppInfoCreateDto data)
- : base(data)
- {
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Commands/Configs/AppInfoDeleteCommand.cs b/Source/Starfish.Service/Application/Commands/Configs/AppInfoDeleteCommand.cs
deleted file mode 100644
index 22523fa..0000000
--- a/Source/Starfish.Service/Application/Commands/Configs/AppInfoDeleteCommand.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using Nerosoft.Euonia.Domain;
-
-namespace Nerosoft.Starfish.Application;
-
-///
-/// 删除应用信息命令
-///
-public class AppInfoDeleteCommand : Command
-{
- ///
- /// 构造函数
- ///
- ///
- public AppInfoDeleteCommand(string id)
- : base(id)
- {
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Commands/Configs/AppInfoUpdateCommand.cs b/Source/Starfish.Service/Application/Commands/Configs/AppInfoUpdateCommand.cs
deleted file mode 100644
index fb83019..0000000
--- a/Source/Starfish.Service/Application/Commands/Configs/AppInfoUpdateCommand.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using Nerosoft.Euonia.Domain;
-using Nerosoft.Starfish.Transit;
-
-namespace Nerosoft.Starfish.Application;
-
-///
-/// 更新应用信息命令
-///
-public class AppInfoUpdateCommand : Command
-{
- ///
- /// 构造函数
- ///
- ///
- ///
- public AppInfoUpdateCommand(string id, AppInfoUpdateDto model)
- : base(id, model)
- {
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Commands/Configs/ChangeAppStatusCommand.cs b/Source/Starfish.Service/Application/Commands/Configs/ChangeAppStatusCommand.cs
deleted file mode 100644
index ded56f7..0000000
--- a/Source/Starfish.Service/Application/Commands/Configs/ChangeAppStatusCommand.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using Nerosoft.Euonia.Domain;
-using Nerosoft.Starfish.Domain;
-
-namespace Nerosoft.Starfish.Application;
-
-///
-/// 修改应用信息状态命令
-///
-public class ChangeAppStatusCommand : Command
-{
- ///
- /// 构造函数
- ///
- ///
- ///
- public ChangeAppStatusCommand(string id, AppStatus status)
- {
- Id = id;
- Status = status;
- }
-
- public string Id { get; set; }
-
- public AppStatus Status { get; set; }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationAbstractCommand.cs b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationAbstractCommand.cs
deleted file mode 100644
index 1b39777..0000000
--- a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationAbstractCommand.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using Nerosoft.Euonia.Domain;
-
-namespace Nerosoft.Starfish.Application;
-
-public abstract class ConfigurationAbstractCommand : Command
-{
- protected ConfigurationAbstractCommand(string appId, string environment)
- {
- AppId = appId;
- Environment = environment;
- }
-
- ///
- /// 应用Id
- ///
- public string AppId { get; set; }
-
- ///
- /// 应用环境
- ///
- public string Environment { get; set; }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationArchiveCreateCommand.cs b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationArchiveCreateCommand.cs
deleted file mode 100644
index 5ffdc85..0000000
--- a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationArchiveCreateCommand.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using Nerosoft.Euonia.Domain;
-
-namespace Nerosoft.Starfish.Application;
-
-///
-/// 创建配置归档命令
-///
-public class ConfigurationArchiveCreateCommand : Command
-{
- ///
- /// 应用Id
- ///
- public string AppId { get; set; }
-
- ///
- /// 应用环境
- ///
- public string Environment { get; set; }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationCreateCommand.cs b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationCreateCommand.cs
index 2e0d582..c1ef14e 100644
--- a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationCreateCommand.cs
+++ b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationCreateCommand.cs
@@ -1,19 +1,19 @@
-namespace Nerosoft.Starfish.Application;
+using Nerosoft.Euonia.Domain;
-public class ConfigurationCreateCommand : ConfigurationAbstractCommand
+namespace Nerosoft.Starfish.Application;
+
+public class ConfigurationCreateCommand : Command
{
- public ConfigurationCreateCommand(string appId, string environment)
- : base(appId, environment)
+ public ConfigurationCreateCommand(string teamId)
{
+ TeamId = teamId;
}
-
- ///
- /// 描述
- ///
+
+ public string TeamId { get; set; }
+
+ public string Name { get; set; }
+
public string Description { get; set; }
- ///
- /// 配置项内容
- ///
- public IDictionary Data { get; set; }
+ public string Secret { get; set; }
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationDeleteCommand.cs b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationDeleteCommand.cs
index 77624ec..76183bf 100644
--- a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationDeleteCommand.cs
+++ b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationDeleteCommand.cs
@@ -1,17 +1,20 @@
-namespace Nerosoft.Starfish.Application;
+using Nerosoft.Euonia.Domain;
+
+namespace Nerosoft.Starfish.Application;
///
/// 删除配置节点命令
///
-public class ConfigurationDeleteCommand : ConfigurationAbstractCommand
+public class ConfigurationDeleteCommand : Command
{
///
/// 构造函数
///
- /// 应用Id
- ///
- public ConfigurationDeleteCommand(string appId, string environment)
- : base(appId, environment)
+ /// 配置Id
+ public ConfigurationDeleteCommand(string id)
{
+ Id = id;
}
+
+ public string Id { get; set; }
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationDisableCommand.cs b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationDisableCommand.cs
new file mode 100644
index 0000000..7a831c5
--- /dev/null
+++ b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationDisableCommand.cs
@@ -0,0 +1,13 @@
+using Nerosoft.Euonia.Domain;
+
+namespace Nerosoft.Starfish.Application;
+
+public class ConfigurationDisableCommand : Command
+{
+ public ConfigurationDisableCommand(string id)
+ {
+ Id = id;
+ }
+
+ public string Id { get; set; }
+}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationEnableCommand.cs b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationEnableCommand.cs
new file mode 100644
index 0000000..ecd13cc
--- /dev/null
+++ b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationEnableCommand.cs
@@ -0,0 +1,13 @@
+using Nerosoft.Euonia.Domain;
+
+namespace Nerosoft.Starfish.Application;
+
+public class ConfigurationEnableCommand : Command
+{
+ public ConfigurationEnableCommand(string id)
+ {
+ Id = id;
+ }
+
+ public string Id { get; set; }
+}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationItemsUpdateCommand.cs b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationItemsUpdateCommand.cs
new file mode 100644
index 0000000..cd7c293
--- /dev/null
+++ b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationItemsUpdateCommand.cs
@@ -0,0 +1,25 @@
+using Nerosoft.Euonia.Domain;
+
+namespace Nerosoft.Starfish.Application;
+
+public sealed class ConfigurationItemsUpdateCommand : Command
+{
+ public ConfigurationItemsUpdateCommand(string id, string mode, IDictionary items)
+ {
+ Id = id;
+ Mode = mode;
+ Items = items;
+ }
+
+ public string Id { get; set; }
+
+ ///
+ /// 更新方式
+ ///
+ public string Mode { get; set; }
+
+ ///
+ /// 所有配置项
+ ///
+ public IDictionary Items { get; set; }
+}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationPublishCommand.cs b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationPublishCommand.cs
index 14582f6..9391c26 100644
--- a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationPublishCommand.cs
+++ b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationPublishCommand.cs
@@ -1,12 +1,22 @@
-namespace Nerosoft.Starfish.Application;
+using Nerosoft.Euonia.Domain;
+
+namespace Nerosoft.Starfish.Application;
///
/// 配置节点发布命令
///
-public class ConfigurationPublishCommand : ConfigurationAbstractCommand
+public class ConfigurationPublishCommand : Command
{
- public ConfigurationPublishCommand(string appId, string environment)
- : base(appId, environment)
+ public ConfigurationPublishCommand(string id, string version, string comment)
{
+ Id = id;
+ Version = version;
+ Comment = comment;
}
+
+ public string Id { get; set; }
+
+ public string Version { get; set; }
+
+ public string Comment { get; set; }
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationRevisionCreateCommand.cs b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationRevisionCreateCommand.cs
deleted file mode 100644
index cc42978..0000000
--- a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationRevisionCreateCommand.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using Nerosoft.Euonia.Domain;
-
-namespace Nerosoft.Starfish.Application;
-
-///
-/// 创建配置版本命令
-///
-public class ConfigurationRevisionCreateCommand : ConfigurationAbstractCommand
-{
- public ConfigurationRevisionCreateCommand(string appId, string environment)
- : base(appId, environment)
- {
- }
-
- ///
- /// 说明
- ///
- public string Comment { get; set; }
-
- ///
- /// 版本号
- ///
- public string Version { get; set; }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Commands/Configs/AppInfoSetSecretCommand.cs b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationSetSecretCommand.cs
similarity index 67%
rename from Source/Starfish.Service/Application/Commands/Configs/AppInfoSetSecretCommand.cs
rename to Source/Starfish.Service/Application/Commands/Configs/ConfigurationSetSecretCommand.cs
index b70faac..380be73 100644
--- a/Source/Starfish.Service/Application/Commands/Configs/AppInfoSetSecretCommand.cs
+++ b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationSetSecretCommand.cs
@@ -5,9 +5,9 @@ namespace Nerosoft.Starfish.Application;
///
/// 设置App密钥命令
///
-public class AppInfoSetSecretCommand : Command
+public class ConfigurationSetSecretCommand : Command
{
- public AppInfoSetSecretCommand(string id, string secret)
+ public ConfigurationSetSecretCommand(string id, string secret)
{
Id = id;
Secret = secret;
diff --git a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationUpdateCommand.cs b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationUpdateCommand.cs
index 3f816e5..4b63b4d 100644
--- a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationUpdateCommand.cs
+++ b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationUpdateCommand.cs
@@ -1,13 +1,19 @@
-namespace Nerosoft.Starfish.Application;
+using Nerosoft.Euonia.Domain;
-public class ConfigurationUpdateCommand : ConfigurationAbstractCommand
+namespace Nerosoft.Starfish.Application;
+
+public class ConfigurationUpdateCommand : Command
{
- public ConfigurationUpdateCommand(string appId, string environment)
- : base(appId, environment)
+ public ConfigurationUpdateCommand(string id)
{
- AppId = appId;
- Environment = environment;
+ Id = id;
}
- public IDictionary Data { get; set; }
+ public string Id { get; set; }
+
+ public string Name { get; set; }
+
+ public string Description { get; set; }
+
+ public string Secret { get; set; }
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationValueUpdateCommand.cs b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationValueUpdateCommand.cs
index a80ad5a..17b9ab3 100644
--- a/Source/Starfish.Service/Application/Commands/Configs/ConfigurationValueUpdateCommand.cs
+++ b/Source/Starfish.Service/Application/Commands/Configs/ConfigurationValueUpdateCommand.cs
@@ -1,16 +1,18 @@
-namespace Nerosoft.Starfish.Application;
+using Nerosoft.Euonia.Domain;
-public class ConfigurationValueUpdateCommand : ConfigurationAbstractCommand
+namespace Nerosoft.Starfish.Application;
+
+public class ConfigurationValueUpdateCommand : Command
{
- public ConfigurationValueUpdateCommand(string appId, string environment, string key, string value)
- : base(appId, environment)
+ public ConfigurationValueUpdateCommand(string id, string key, string value)
{
- AppId = appId;
- Environment = environment;
+ Id = id;
Key = key;
Value = value;
}
+ public string Id { get; set; }
+
public string Key { get; set; }
public string Value { get; set; }
diff --git a/Source/Starfish.Service/Application/ConnectionContainer.cs b/Source/Starfish.Service/Application/ConnectionContainer.cs
index 334220b..7db40bf 100644
--- a/Source/Starfish.Service/Application/ConnectionContainer.cs
+++ b/Source/Starfish.Service/Application/ConnectionContainer.cs
@@ -22,33 +22,28 @@ public ConnectionContainer(IConfigurationApplicationService service)
private async void OnClientConnected(object sender, ClientConnectedEventArgs e)
{
- var raw = await _service.GetArchiveAsync(e.AppId, e.Environment);
- var key = $"{e.AppId}-{e.Environment}";
- if (_connections.TryGetValue(key, out var connection))
+ var raw = await _service.GetArchiveAsync(e.ConfigId);
+ if (_connections.TryGetValue(e.ConfigId, out var connection))
{
await connection.Channel.Writer.WriteAsync(Tuple.Create(e.ConnectionId, raw));
}
}
- public ConnectionInfo GetOrAdd(string appId, string environment, string connectionId)
+ public ConnectionInfo GetOrAdd(string configId, string connectionId)
{
- var key = $"{appId}-{environment}";
-
- var connection = _connections.AddOrUpdate(key, _ => ConnectionInfo.New(connectionId), (_, info) =>
+ var connection = _connections.AddOrUpdate(configId, _ => ConnectionInfo.New(connectionId), (_, info) =>
{
info.AddClient(connectionId);
return info;
});
- OnConnected?.Invoke(this, new ClientConnectedEventArgs { AppId = appId, Environment = environment, ConnectionId = connectionId });
+ OnConnected?.Invoke(this, new ClientConnectedEventArgs { ConfigId = configId, ConnectionId = connectionId });
return connection;
}
- public void Remove(string appId, string environment, string connectionId)
+ public void Remove(string configId, string connectionId)
{
- var key = $"{appId}-{environment}";
-
- if (!_connections.TryGetValue(key, out var info))
+ if (!_connections.TryGetValue(configId, out var info))
{
return;
}
@@ -56,7 +51,7 @@ public void Remove(string appId, string environment, string connectionId)
info.RemoveClient(connectionId);
if (info.Clients.Count == 0)
{
- _connections.TryRemove(key, out _);
+ _connections.TryRemove(configId, out _);
}
}
@@ -64,8 +59,7 @@ public void Remove(string appId, string environment, string connectionId)
public async Task HandleAsync(ConfigurationArchiveUpdatedEvent @event, MessageContext context, CancellationToken cancellationToken = default)
{
var aggregate = @event.GetAggregate();
- var key = $"{aggregate.AppId}-{aggregate.Environment}";
- if (_connections.TryGetValue(key, out var connection))
+ if (_connections.TryGetValue(aggregate.Id, out var connection))
{
await connection.Channel.Writer.WriteAsync(Tuple.Create("*", aggregate.Data), cancellationToken);
}
@@ -73,10 +67,7 @@ public async Task HandleAsync(ConfigurationArchiveUpdatedEvent @event, MessageCo
public class ClientConnectedEventArgs : EventArgs
{
- public string AppId { get; set; }
-
- public string Environment { get; set; }
-
+ public string ConfigId { get; set; }
public string ConnectionId { get; set; }
}
}
diff --git a/Source/Starfish.Service/Application/Contracts/IAppsApplicationService.cs b/Source/Starfish.Service/Application/Contracts/IAppsApplicationService.cs
deleted file mode 100644
index d44cc92..0000000
--- a/Source/Starfish.Service/Application/Contracts/IAppsApplicationService.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-using Nerosoft.Euonia.Application;
-using Nerosoft.Starfish.Transit;
-
-namespace Nerosoft.Starfish.Application;
-
-///
-/// 应用信息服务接口
-///
-public interface IAppsApplicationService : IApplicationService
-{
- ///
- /// 获取符合条件的应用列表
- ///
- /// 查询条件
- /// 页码
- /// 数量
- ///
- ///
- Task> QueryAsync(AppInfoCriteria criteria, int skip, int count, CancellationToken cancellationToken = default);
-
- ///
- /// 获取符合条件的应用数量
- ///
- ///
- ///
- ///
- Task CountAsync(AppInfoCriteria criteria, CancellationToken cancellationToken = default);
-
- ///
- /// 获取应用详情
- ///
- ///
- ///
- ///
- Task GetAsync(string id, CancellationToken cancellationToken = default);
-
- ///
- /// 应用授权
- ///
- ///
- ///
- ///
- ///
- Task AuthorizeAsync(string id, string secret, CancellationToken cancellationToken = default);
-
- ///
- /// 创建应用
- ///
- ///
- ///
- ///
- Task CreateAsync(AppInfoCreateDto data, CancellationToken cancellationToken = default);
-
- ///
- /// 更新应用
- ///
- ///
- ///
- ///
- ///
- Task UpdateAsync(string id, AppInfoUpdateDto data, CancellationToken cancellationToken = default);
-
- ///
- /// 删除应用
- ///
- ///
- ///
- ///
- Task DeleteAsync(string id, CancellationToken cancellationToken = default);
-
- ///
- /// 启用应用
- ///
- ///
- ///
- ///
- Task EnableAsync(string id, CancellationToken cancellationToken = default);
-
- ///
- /// 禁用应用
- ///
- ///
- ///
- ///
- Task DisableAsync(string id, CancellationToken cancellationToken = default);
-
- ///
- /// 设置应用密钥
- ///
- ///
- ///
- ///
- ///
- Task SetSecretAsync(string id, string secret, CancellationToken cancellationToken = default);
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Contracts/IConfigurationApplicationService.cs b/Source/Starfish.Service/Application/Contracts/IConfigurationApplicationService.cs
index 922c521..1483476 100644
--- a/Source/Starfish.Service/Application/Contracts/IConfigurationApplicationService.cs
+++ b/Source/Starfish.Service/Application/Contracts/IConfigurationApplicationService.cs
@@ -8,105 +8,144 @@ namespace Nerosoft.Starfish.Application;
///
public interface IConfigurationApplicationService : IApplicationService
{
+ Task> QueryAsync(ConfigurationCriteria criteria, int skip, int count, CancellationToken cancellationToken = default);
+
+ Task CountAsync(ConfigurationCriteria criteria, CancellationToken cancellationToken = default);
+
///
/// 获取配置项列表
///
- ///
- ///
+ ///
+ ///
///
///
///
///
- Task> GetItemListAsync(string appId, string environment, int skip, int count, CancellationToken cancellationToken = default);
+ Task> GetItemListAsync(string id, string key, int skip, int count, CancellationToken cancellationToken = default);
///
/// 获取配置项数量
///
- ///
- ///
+ ///
+ ///
///
///
- Task GetItemCountAsync(string appId, string environment, CancellationToken cancellationToken = default);
+ Task GetItemCountAsync(string id, string key, CancellationToken cancellationToken = default);
///
/// 获取配置详情
///
- ///
- ///
+ ///
///
///
- Task GetDetailAsync(string appId, string environment, CancellationToken cancellationToken = default);
+ Task GetDetailAsync(string id, CancellationToken cancellationToken = default);
///
/// 新建配置
///
- /// 应用Id
- /// 应用环境
- ///
+ /// 团队Id
///
///
///
- Task CreateAsync(string appId, string environment, string format, ConfigurationEditDto data, CancellationToken cancellationToken = default);
+ Task CreateAsync(string teamId, ConfigurationEditDto data, CancellationToken cancellationToken = default);
///
/// 更新配置
///
- ///
- ///
- ///
+ ///
///
///
///
- Task UpdateAsync(string appId, string environment, string format, ConfigurationEditDto data, CancellationToken cancellationToken = default);
+ Task UpdateAsync(string id, ConfigurationEditDto data, CancellationToken cancellationToken = default);
///
/// 删除节点
///
- ///
- ///
+ ///
+ ///
+ ///
+ Task DeleteAsync(string id, CancellationToken cancellationToken = default);
+
+ ///
+ /// 设置访问密钥
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task SetSecretAsync(string id, string secret, CancellationToken cancellationToken = default);
+
+ ///
+ /// 禁用配置
+ ///
+ ///
///
///
- Task DeleteAsync(string appId, string environment, CancellationToken cancellationToken = default);
+ Task DisableAsync(string id, CancellationToken cancellationToken = default);
+
+ ///
+ /// 启用配置
+ ///
+ ///
+ ///
+ ///
+ Task EnableAsync(string id, CancellationToken cancellationToken = default);
+
+ ///
+ /// 应用认证
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task AuthorizeAsync(string id, string teamId, string name, string secret, CancellationToken cancellationToken = default);
///
/// 更新配置项
///
- ///
- ///
+ ///
///
///
///
///
- Task UpdateAsync(string appId, string environment, string key, string value, CancellationToken cancellationToken = default);
+ Task UpdateValueAsync(string id, string key, string value, CancellationToken cancellationToken = default);
+
+ ///
+ /// 批量更新配置项
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task UpdateItemsAsync(string id, ConfigurationItemsUpdateDto data, CancellationToken cancellationToken = default);
///
/// 发布配置
///
- ///
- ///
+ ///
///
///
///
- Task PublishAsync(string appId, string environment, ConfigurationPublishDto data, CancellationToken cancellationToken = default);
+ Task PublishAsync(string id, ConfigurationPublishRequestDto data, CancellationToken cancellationToken = default);
///
/// 获取已发布的配置
///
- /// 应用Id
- /// 应用环境
+ ///
///
///
- Task GetArchiveAsync(string appId, string environment, CancellationToken cancellationToken = default);
+ Task GetArchiveAsync(string id, CancellationToken cancellationToken = default);
///
/// 获取指定格式的配置
///
- ///
- ///
+ ///
///
///
///
- Task GetItemsInTextAsync(string appId, string environment, string format, CancellationToken cancellationToken = default);
+ Task GetItemsInTextAsync(string id, string format, CancellationToken cancellationToken = default);
- Task PushRedisAsync(string appId, string environment, PushRedisRequestDto data, CancellationToken cancellationToken = default);
+ Task PushRedisAsync(string id, ConfigurationPushRedisRequestDto data, CancellationToken cancellationToken = default);
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Events/ConfigurationPublishedEvent.cs b/Source/Starfish.Service/Application/Events/ConfigurationPublishedEvent.cs
deleted file mode 100644
index a6d5cb7..0000000
--- a/Source/Starfish.Service/Application/Events/ConfigurationPublishedEvent.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using Nerosoft.Euonia.Domain;
-
-// ReSharper disable MemberCanBePrivate.Global
-
-namespace Nerosoft.Starfish.Application;
-
-///
-/// 配置节点发布完成事件
-///
-public class ConfigurationPublishedEvent : ApplicationEvent
-{
- public ConfigurationPublishedEvent()
- {
- }
-
- public ConfigurationPublishedEvent(string appId, string environment)
- : this()
- {
- AppId = appId;
- Environment = environment;
- }
-
- ///
- /// 根节点Id
- ///
- public string AppId { get; set; }
-
- ///
- /// 应用环境
- ///
- public string Environment { get; set; }
-
- ///
- /// 版本号
- ///
- public string Version { get; set; }
-
- ///
- /// 描述
- ///
- public string Comment { get; set; }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Handlers/AppInfoCommandHandler.cs b/Source/Starfish.Service/Application/Handlers/AppInfoCommandHandler.cs
deleted file mode 100644
index 067ee3a..0000000
--- a/Source/Starfish.Service/Application/Handlers/AppInfoCommandHandler.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-using Nerosoft.Euonia.Bus;
-using Nerosoft.Euonia.Business;
-using Nerosoft.Euonia.Repository;
-using Nerosoft.Starfish.Domain;
-using Nerosoft.Starfish.Service;
-
-namespace Nerosoft.Starfish.Application;
-
-///
-/// 应用信息命令处理器
-///
-public class AppInfoCommandHandler : CommandHandlerBase,
- IHandler,
- IHandler,
- IHandler,
- IHandler,
- IHandler
-{
- ///
- /// 构造函数
- ///
- ///
- ///
- public AppInfoCommandHandler(IUnitOfWorkManager unitOfWork, IObjectFactory factory)
- : base(unitOfWork, factory)
- {
- }
-
- ///
- public Task HandleAsync(AppInfoCreateCommand message, MessageContext context, CancellationToken cancellationToken = default)
- {
- return ExecuteAsync(async () =>
- {
- var business = await Factory.CreateAsync(cancellationToken);
-
- business.TeamId = message.Item1.TeamId;
- business.Name = message.Item1.Name;
- business.Description = message.Item1.Description;
- business.Secret = message.Item1.Secret;
-
- business.MarkAsInsert();
-
- _ = await business.SaveAsync(false, cancellationToken);
-
- return business.Id;
- }, context.Response);
- }
-
- ///
- public Task HandleAsync(AppInfoUpdateCommand message, MessageContext context, CancellationToken cancellationToken = default)
- {
- return ExecuteAsync(async () =>
- {
- var business = await Factory.FetchAsync(message.Item1, cancellationToken);
-
- business.Name = message.Item2.Name;
- business.Description = message.Item2.Description;
-
- business.MarkAsUpdate();
-
- _ = await business.SaveAsync(true, cancellationToken);
- });
- }
-
- ///
- public Task HandleAsync(AppInfoDeleteCommand message, MessageContext context, CancellationToken cancellationToken = default)
- {
- return ExecuteAsync(async () =>
- {
- var business = await Factory.FetchAsync(message.Item1, cancellationToken);
-
- business.MarkAsDelete();
-
- _ = await business.SaveAsync(true, cancellationToken);
- });
- }
-
- ///
- public Task HandleAsync(ChangeAppStatusCommand message, MessageContext context, CancellationToken cancellationToken = default)
- {
- return ExecuteAsync(async () =>
- {
- await Factory.ExecuteAsync(message.Id, message.Status, cancellationToken);
- });
- }
-
- ///
- public Task HandleAsync(AppInfoSetSecretCommand message, MessageContext context, CancellationToken cancellationToken = default)
- {
- return ExecuteAsync(async () =>
- {
- await Factory.ExecuteAsync(message.Id, message.Secret, cancellationToken);
- });
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Handlers/ConfigurationCommandHandler.cs b/Source/Starfish.Service/Application/Handlers/ConfigurationCommandHandler.cs
index 5dd25d4..df1656b 100644
--- a/Source/Starfish.Service/Application/Handlers/ConfigurationCommandHandler.cs
+++ b/Source/Starfish.Service/Application/Handlers/ConfigurationCommandHandler.cs
@@ -10,13 +10,15 @@ namespace Nerosoft.Starfish.Application;
/// 应用配置命令处理器
///
public class ConfigurationCommandHandler : CommandHandlerBase,
- IHandler,
- IHandler,
- IHandler,
- IHandler,
- IHandler,
- IHandler,
- IHandler
+ IHandler,
+ IHandler,
+ IHandler,
+ IHandler,
+ IHandler,
+ IHandler,
+ IHandler,
+ IHandler,
+ IHandler
{
public ConfigurationCommandHandler(IUnitOfWorkManager unitOfWork, IObjectFactory factory)
: base(unitOfWork, factory)
@@ -28,10 +30,13 @@ public Task HandleAsync(ConfigurationCreateCommand message, MessageContext conte
return ExecuteAsync(async () =>
{
var business = await Factory.CreateAsync(cancellationToken);
- business.AppId = message.AppId;
- business.Environment = message.Environment;
- business.Items = message.Data;
+ business.TeamId = message.TeamId;
+ business.Name = message.Name;
+ business.Description = message.Description;
+ business.Secret = message.Secret;
+
_ = await business.SaveAsync(false, cancellationToken);
+
return business.Id;
}, context.Response);
}
@@ -40,8 +45,10 @@ public Task HandleAsync(ConfigurationUpdateCommand message, MessageContext conte
{
return ExecuteAsync(async () =>
{
- var business = await Factory.FetchAsync(message.AppId, message.Environment, cancellationToken);
- business.Items = message.Data;
+ var business = await Factory.FetchAsync(message.Id, cancellationToken);
+ business.Name = message.Name;
+ business.Description = message.Description;
+ business.Secret = message.Secret;
_ = await business.SaveAsync(true, cancellationToken);
});
}
@@ -51,7 +58,7 @@ public Task HandleAsync(ConfigurationDeleteCommand message, MessageContext conte
{
return ExecuteAsync(async () =>
{
- var business = await Factory.FetchAsync(message.AppId, message.Environment, cancellationToken);
+ var business = await Factory.FetchAsync(message.Id, cancellationToken);
business.MarkAsDelete();
await business.SaveAsync(false, cancellationToken);
});
@@ -62,35 +69,52 @@ public Task HandleAsync(ConfigurationPublishCommand message, MessageContext cont
{
return ExecuteAsync(async () =>
{
- await Factory.ExecuteAsync(message.AppId, message.Environment, cancellationToken);
+ await Factory.ExecuteAsync(message.Id, message.Version, message.Comment, cancellationToken);
});
}
+ ///
public Task HandleAsync(ConfigurationValueUpdateCommand message, MessageContext context, CancellationToken cancellationToken = default)
{
return ExecuteAsync(async () =>
{
- var business = await Factory.FetchAsync(message.AppId, message.Environment, cancellationToken);
- business.Key = message.Key;
- business.Value = message.Value;
- _ = await business.SaveAsync(true, cancellationToken);
+ await Factory.ExecuteAsync(message.Id, message.Key, message.Value, cancellationToken);
+ });
+ }
+
+ ///
+ public Task HandleAsync(ConfigurationItemsUpdateCommand message, MessageContext context, CancellationToken cancellationToken = default)
+ {
+ return ExecuteAsync(async () =>
+ {
+ await Factory.ExecuteAsync(message.Id, message.Items, cancellationToken);
+ });
+ }
+
+ ///
+ public Task HandleAsync(ConfigurationSetSecretCommand message, MessageContext context, CancellationToken cancellationToken = default)
+ {
+ return ExecuteAsync(async () =>
+ {
+ await Factory.ExecuteAsync(message.Id, message.Secret, cancellationToken);
});
}
- public Task HandleAsync(ConfigurationRevisionCreateCommand message, MessageContext context, CancellationToken cancellationToken = default)
+ ///
+ public Task HandleAsync(ConfigurationDisableCommand message, MessageContext context, CancellationToken cancellationToken = default)
{
return ExecuteAsync(async () =>
{
- var argument = new ConfigurationRevisionArgument(message.Version, message.Comment, context.User?.Identity?.Name);
- await Factory.ExecuteAsync(message.AppId, message.Environment, argument, cancellationToken);
+ await Factory.ExecuteAsync(message.Id, false, cancellationToken);
});
}
- public Task HandleAsync(ConfigurationArchiveCreateCommand message, MessageContext context, CancellationToken cancellationToken = default)
+ ///
+ public Task HandleAsync(ConfigurationEnableCommand message, MessageContext context, CancellationToken cancellationToken = default)
{
return ExecuteAsync(async () =>
{
- await Factory.ExecuteAsync(message.AppId, message.Environment, context.User?.Identity?.Name, cancellationToken);
+ await Factory.ExecuteAsync(message.Id, true, cancellationToken);
});
}
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Implements/AppsApplicationService.cs b/Source/Starfish.Service/Application/Implements/AppsApplicationService.cs
deleted file mode 100644
index 05bb7b8..0000000
--- a/Source/Starfish.Service/Application/Implements/AppsApplicationService.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-using Nerosoft.Euonia.Application;
-using Nerosoft.Starfish.Domain;
-using Nerosoft.Starfish.Transit;
-using Nerosoft.Starfish.UseCases;
-
-namespace Nerosoft.Starfish.Application;
-
-///
-/// 应用信息服务接口
-///
-public class AppsApplicationService : BaseApplicationService, IAppsApplicationService
-{
- ///
- public Task> QueryAsync(AppInfoCriteria criteria, int skip, int count, CancellationToken cancellationToken = default)
- {
- var input = new AppInfoQueryInput(criteria, skip, count);
- var useCase = LazyServiceProvider.GetRequiredService();
- return useCase.ExecuteAsync(input, cancellationToken)
- .ContinueWith(task => task.Result.Result, cancellationToken);
- }
-
- ///
- public Task CountAsync(AppInfoCriteria criteria, CancellationToken cancellationToken = default)
- {
- var input = new AppInfoCountInput(criteria);
- var useCase = LazyServiceProvider.GetRequiredService();
- return useCase.ExecuteAsync(input, cancellationToken)
- .ContinueWith(task => task.Result.Count, cancellationToken);
- }
-
- ///
- public Task GetAsync(string id, CancellationToken cancellationToken = default)
- {
- var input = new AppInfoDetailInput(id);
- var useCase = LazyServiceProvider.GetRequiredService();
- return useCase.ExecuteAsync(input, cancellationToken)
- .ContinueWith(task => task.Result.Result, cancellationToken);
- }
-
- ///
- public Task AuthorizeAsync(string id, string secret, CancellationToken cancellationToken = default)
- {
- var input = new AppInfoAuthorizeInput(id, secret);
- var useCase = LazyServiceProvider.GetRequiredService();
- return useCase.ExecuteAsync(input, cancellationToken)
- .ContinueWith(task => task.Result.Result, cancellationToken);
- }
-
- ///
- public Task CreateAsync(AppInfoCreateDto data, CancellationToken cancellationToken = default)
- {
- var input = new AppInfoCreateInput(data);
- var useCase = LazyServiceProvider.GetRequiredService();
- return useCase.ExecuteAsync(input, cancellationToken)
- .ContinueWith(task => task.Result.Id, cancellationToken);
- }
-
- ///
- public Task UpdateAsync(string id, AppInfoUpdateDto data, CancellationToken cancellationToken = default)
- {
- var input = new AppInfoUpdateInput(id, data);
- var useCase = LazyServiceProvider.GetRequiredService();
- return useCase.ExecuteAsync(input, cancellationToken);
- }
-
- ///
- public Task DeleteAsync(string id, CancellationToken cancellationToken = default)
- {
- var input = new AppInfoDeleteInput(id);
- var useCase = LazyServiceProvider.GetRequiredService();
- return useCase.ExecuteAsync(input, cancellationToken);
- }
-
- ///
- public Task EnableAsync(string id, CancellationToken cancellationToken = default)
- {
- var input = new ChangeAppInfoStatusInput(id, AppStatus.Enabled);
- var useCase = LazyServiceProvider.GetRequiredService();
- return useCase.ExecuteAsync(input, cancellationToken);
- }
-
- ///
- public Task DisableAsync(string id, CancellationToken cancellationToken = default)
- {
- var input = new ChangeAppInfoStatusInput(id, AppStatus.Disabled);
- var useCase = LazyServiceProvider.GetRequiredService();
- return useCase.ExecuteAsync(input, cancellationToken);
- }
-
- ///
- public Task SetSecretAsync(string id, string secret, CancellationToken cancellationToken = default)
- {
- var input = new AppInfoSetSecretInput(id, secret);
- var useCase = LazyServiceProvider.GetRequiredService();
- return useCase.ExecuteAsync(input, cancellationToken);
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Implements/ConfigurationApplicationService.cs b/Source/Starfish.Service/Application/Implements/ConfigurationApplicationService.cs
index 5bf6886..2217952 100644
--- a/Source/Starfish.Service/Application/Implements/ConfigurationApplicationService.cs
+++ b/Source/Starfish.Service/Application/Implements/ConfigurationApplicationService.cs
@@ -9,89 +9,141 @@ namespace Nerosoft.Starfish.Application;
///
public class ConfigurationApplicationService : BaseApplicationService, IConfigurationApplicationService
{
+ public Task> QueryAsync(ConfigurationCriteria criteria, int skip, int count, CancellationToken cancellationToken = default)
+ {
+ var useCase = LazyServiceProvider.GetRequiredService();
+ var input = new GenericQueryInput(criteria, skip, count);
+ return useCase.ExecuteAsync(input, cancellationToken)
+ .ContinueWith(t => t.Result.Result, cancellationToken);
+ }
+
+ public Task CountAsync(ConfigurationCriteria criteria, CancellationToken cancellationToken = default)
+ {
+ var useCase = LazyServiceProvider.GetRequiredService();
+ var input = new ConfigurationCountInput(criteria);
+ return useCase.ExecuteAsync(input, cancellationToken)
+ .ContinueWith(t => t.Result.Result, cancellationToken);
+ }
+
///
- public Task> GetItemListAsync(string appId, string environment, int skip, int count, CancellationToken cancellationToken = default)
+ public Task> GetItemListAsync(string id, string key, int skip, int count, CancellationToken cancellationToken = default)
{
var useCase = LazyServiceProvider.GetRequiredService();
- var input = new GetConfigurationItemListInput(appId, environment, skip, count);
+ var input = new GetConfigurationItemListInput(id, key, skip, count);
return useCase.ExecuteAsync(input, cancellationToken)
.ContinueWith(t => t.Result.Result, cancellationToken);
}
///
- public Task GetItemCountAsync(string appId, string environment, CancellationToken cancellationToken = default)
+ public Task GetItemCountAsync(string id, string key, CancellationToken cancellationToken = default)
{
var useCase = LazyServiceProvider.GetRequiredService();
- var input = new GetConfigurationItemCountInput(appId, environment);
+ var input = new GetConfigurationItemCountInput(id, key);
return useCase.ExecuteAsync(input, cancellationToken)
.ContinueWith(t => t.Result.Result, cancellationToken);
}
///
- public Task GetDetailAsync(string appId, string environment, CancellationToken cancellationToken = default)
+ public Task GetDetailAsync(string id, CancellationToken cancellationToken = default)
{
var useCase = LazyServiceProvider.GetRequiredService();
- var input = new GetConfigurationDetailInput(appId, environment);
+ var input = new GetConfigurationDetailInput(id);
return useCase.ExecuteAsync(input, cancellationToken)
.ContinueWith(t => t.Result.Result, cancellationToken);
}
///
- public Task CreateAsync(string appId, string environment, string format, ConfigurationEditDto data, CancellationToken cancellationToken = default)
+ public Task CreateAsync(string teamId, ConfigurationEditDto data, CancellationToken cancellationToken = default)
{
var useCase = LazyServiceProvider.GetRequiredService();
- var input = new ConfigurationCreateInput(appId, environment, format, data);
+ var input = new ConfigurationCreateInput(teamId, data);
return useCase.ExecuteAsync(input, cancellationToken)
.ContinueWith(t => t.Result, cancellationToken);
}
///
- public async Task UpdateAsync(string appId, string environment, string format, ConfigurationEditDto data, CancellationToken cancellationToken = default)
+ public async Task UpdateAsync(string id, ConfigurationEditDto data, CancellationToken cancellationToken = default)
{
var useCase = LazyServiceProvider.GetRequiredService();
- var input = new ConfigurationUpdateInput(appId, environment, format, data);
+ var input = new ConfigurationUpdateInput(id, data);
await useCase.ExecuteAsync(input, cancellationToken);
}
///
- public Task DeleteAsync(string appId, string environment, CancellationToken cancellationToken = default)
+ public Task DeleteAsync(string id, CancellationToken cancellationToken = default)
{
var useCase = LazyServiceProvider.GetRequiredService();
- var input = new ConfigurationDeleteInput(appId, environment);
+ var input = new ConfigurationDeleteInput(id);
+ return useCase.ExecuteAsync(input, cancellationToken);
+ }
+
+ public Task SetSecretAsync(string id, string secret, CancellationToken cancellationToken = default)
+ {
+ var input = new SetConfigurationSecretInput(id, secret);
+ var useCase = LazyServiceProvider.GetRequiredService();
return useCase.ExecuteAsync(input, cancellationToken);
}
+ public Task DisableAsync(string id, CancellationToken cancellationToken = default)
+ {
+ var useCase = LazyServiceProvider.GetRequiredService();
+ var input = new ConfigurationDisableInput(id);
+ return useCase.ExecuteAsync(input, cancellationToken);
+ }
+
+ public Task EnableAsync(string id, CancellationToken cancellationToken = default)
+ {
+ var useCase = LazyServiceProvider.GetRequiredService();
+ var input = new ConfigurationEnableInput(id);
+ return useCase.ExecuteAsync(input, cancellationToken);
+ }
+
+ public Task AuthorizeAsync(string id, string teamId, string name, string secret, CancellationToken cancellationToken = default)
+ {
+ var useCase = LazyServiceProvider.GetRequiredService();
+ var input = new ConfigurationAuthorizeInput(id, teamId, name, secret);
+ return useCase.ExecuteAsync(input, cancellationToken)
+ .ContinueWith(t => t.Result.Id, cancellationToken);
+ }
+
///
- public Task UpdateAsync(string appId, string environment, string key, string value, CancellationToken cancellationToken = default)
+ public Task UpdateValueAsync(string id, string key, string value, CancellationToken cancellationToken = default)
{
var useCase = LazyServiceProvider.GetRequiredService();
- var input = new ConfigurationValueUpdateInput(appId, environment, key, value);
+ var input = new ConfigurationValueUpdateInput(id, key, value);
+ return useCase.ExecuteAsync(input, cancellationToken);
+ }
+
+ public Task UpdateItemsAsync(string id, ConfigurationItemsUpdateDto data, CancellationToken cancellationToken = default)
+ {
+ var useCase = LazyServiceProvider.GetRequiredService();
+ var input = new ConfigurationItemsUpdateInput(id, data);
return useCase.ExecuteAsync(input, cancellationToken);
}
///
- public Task PublishAsync(string appId, string environment, ConfigurationPublishDto data, CancellationToken cancellationToken = default)
+ public Task PublishAsync(string id, ConfigurationPublishRequestDto data, CancellationToken cancellationToken = default)
{
var useCase = LazyServiceProvider.GetRequiredService();
- var input = new ConfigurationPublishInput(appId, environment, data);
+ var input = new ConfigurationPublishInput(id, data);
return useCase.ExecuteAsync(input, cancellationToken);
}
///
- public Task GetArchiveAsync(string appId, string environment, CancellationToken cancellationToken = default)
+ public Task GetArchiveAsync(string id, CancellationToken cancellationToken = default)
{
- var useCase = LazyServiceProvider.GetRequiredService();
- var input = new GetConfigurationRawInput(appId, environment);
+ var useCase = LazyServiceProvider.GetRequiredService();
+ var input = new GetConfigurationArchiveInput(id);
return useCase.ExecuteAsync(input, cancellationToken)
.ContinueWith(t => t.Result.Result, cancellationToken);
}
///
- public Task GetItemsInTextAsync(string appId, string environment, string format, CancellationToken cancellationToken = default)
+ public Task GetItemsInTextAsync(string id, string format, CancellationToken cancellationToken = default)
{
var parser = LazyServiceProvider.GetRequiredService()
.GetKeyedService(format.Normalize(TextCaseType.Lower));
- return GetItemListAsync(appId, environment, 0, int.MaxValue, cancellationToken)
+ return GetItemListAsync(id, string.Empty, 0, int.MaxValue, cancellationToken)
.ContinueWith(task =>
{
task.WaitAndUnwrapException(cancellationToken);
@@ -101,10 +153,10 @@ public Task GetItemsInTextAsync(string appId, string environment, string
}, cancellationToken);
}
- public Task PushRedisAsync(string appId, string environment, PushRedisRequestDto data, CancellationToken cancellationToken = default)
- {
- var useCase = LazyServiceProvider.GetRequiredService();
- var input = new PushRedisInput(appId, environment, data);
+ public Task PushRedisAsync(string id, ConfigurationPushRedisRequestDto data, CancellationToken cancellationToken = default)
+ {
+ var useCase = LazyServiceProvider.GetRequiredService();
+ var input = new ConfigurationPushRedisInput(id, data);
return useCase.ExecuteAsync(input, cancellationToken);
}
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Implements/IdentityApplicationService.cs b/Source/Starfish.Service/Application/Implements/IdentityApplicationService.cs
index ceb674a..63f7707 100644
--- a/Source/Starfish.Service/Application/Implements/IdentityApplicationService.cs
+++ b/Source/Starfish.Service/Application/Implements/IdentityApplicationService.cs
@@ -16,16 +16,9 @@ public async Task GrantAsync(string type, Dictionary await LazyServiceProvider.GetService()
- .ExecuteAsync(new GrantWithPasswordUseCaseInput
- {
- UserName = data.GetValueOrDefault("username"),
- Password = data.GetValueOrDefault("password")
- }, cancellationToken),
+ .ExecuteAsync(new GrantWithPasswordUseCaseInput(data.GetValueOrDefault("username"), data.GetValueOrDefault("password")), cancellationToken),
"refresh_token" => await LazyServiceProvider.GetService()
- .ExecuteAsync(new GrantWithRefreshTokenUseCaseInput
- {
- Token = data.GetValueOrDefault("refresh_token")
- }, cancellationToken),
+ .ExecuteAsync(new GrantWithRefreshTokenUseCaseInput(data.GetValueOrDefault("refresh_token")), cancellationToken),
"otp" => throw new NotSupportedException(),
_ => throw new NotSupportedException()
};
diff --git a/Source/Starfish.Service/Application/Implements/LogsApplicationService.cs b/Source/Starfish.Service/Application/Implements/LogsApplicationService.cs
index 99bb812..505ba7a 100644
--- a/Source/Starfish.Service/Application/Implements/LogsApplicationService.cs
+++ b/Source/Starfish.Service/Application/Implements/LogsApplicationService.cs
@@ -13,7 +13,7 @@ public class LogsApplicationService : BaseApplicationService, ILogsApplicationSe
public Task> QueryAsync(OperateLogCriteria criteria, int skip, int count, CancellationToken cancellationToken = default)
{
var useCase = LazyServiceProvider.GetService();
- return useCase.ExecuteAsync(new LogsQueryUseCaseInput(criteria, skip, count), cancellationToken)
+ return useCase.ExecuteAsync(new GenericQueryInput(criteria, skip, count), cancellationToken)
.ContinueWith(task => task.Result.Logs, cancellationToken);
}
diff --git a/Source/Starfish.Service/Application/Implements/TeamApplicationService.cs b/Source/Starfish.Service/Application/Implements/TeamApplicationService.cs
index a835029..f64fbfd 100644
--- a/Source/Starfish.Service/Application/Implements/TeamApplicationService.cs
+++ b/Source/Starfish.Service/Application/Implements/TeamApplicationService.cs
@@ -9,7 +9,7 @@ public class TeamApplicationService : BaseApplicationService, ITeamApplicationSe
public Task> QueryAsync(TeamCriteria criteria, int skip, int count, CancellationToken cancellationToken = default)
{
var userCase = LazyServiceProvider.GetService();
- var input = new TeamQueryInput(criteria, skip, count);
+ var input = new GenericQueryInput(criteria, skip, count);
return userCase.ExecuteAsync(input, cancellationToken)
.ContinueWith(task => task.Result.Result, cancellationToken);
}
diff --git a/Source/Starfish.Service/Application/Implements/UserApplicationService.cs b/Source/Starfish.Service/Application/Implements/UserApplicationService.cs
index 1203c4d..6ccf283 100644
--- a/Source/Starfish.Service/Application/Implements/UserApplicationService.cs
+++ b/Source/Starfish.Service/Application/Implements/UserApplicationService.cs
@@ -30,7 +30,7 @@ public Task UpdateAsync(string id, UserUpdateDto data, CancellationToken cancell
public Task> QueryAsync(UserCriteria criteria, int skip, int count, CancellationToken cancellationToken = default)
{
var useCase = LazyServiceProvider.GetService();
- var input = new UserSearchInput(criteria, skip, count);
+ var input = new GenericQueryInput(criteria, skip, count);
return useCase.ExecuteAsync(input, cancellationToken)
.ContinueWith(task => task.Result.Result, cancellationToken);
}
diff --git a/Source/Starfish.Service/Application/Mappings/AppsMappingProfile.cs b/Source/Starfish.Service/Application/Mappings/AppsMappingProfile.cs
deleted file mode 100644
index 7a91a67..0000000
--- a/Source/Starfish.Service/Application/Mappings/AppsMappingProfile.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using AutoMapper;
-using Nerosoft.Starfish.Domain;
-using Nerosoft.Starfish.Transit;
-using Nerosoft.Starfish.UseCases;
-
-namespace Nerosoft.Starfish.Application;
-
-///
-/// 应用信息映射配置
-///
-internal class AppsMappingProfile : Profile
-{
- ///
- /// 构造函数
- ///
- public AppsMappingProfile()
- {
- CreateMap()
- .ForMember(dest => dest.StatusDescription, opt => opt.MapFrom(src => src.Status.GetDescription(Resources.ResourceManager, Resources.Culture)));
- CreateMap()
- .ForMember(dest => dest.StatusDescription, opt => opt.MapFrom(src => src.Status.GetDescription(Resources.ResourceManager, Resources.Culture)));
- CreateMap()
- .ForMember(dest => dest.StatusDescription, opt => opt.MapFrom(src => src.Status.GetDescription(Resources.ResourceManager, Resources.Culture)));
- }
-
- private static string Mask(string source)
- {
- return $"{source[..3]}******{source[^3..]}";
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Mappings/ConfigurationMappingProfile.cs b/Source/Starfish.Service/Application/Mappings/ConfigurationMappingProfile.cs
index 5677b22..9ccc295 100644
--- a/Source/Starfish.Service/Application/Mappings/ConfigurationMappingProfile.cs
+++ b/Source/Starfish.Service/Application/Mappings/ConfigurationMappingProfile.cs
@@ -13,9 +13,10 @@ internal class ConfigurationMappingProfile : Profile
public ConfigurationMappingProfile()
{
CreateMap();
- CreateMap()
- .ForMember(dest => dest.StatusDescription, options => options.MapFrom(src => GetStatusDescription(src.Status)))
- .ForMember(dest => dest.AppName, options => options.MapFrom(src => src.App.Name));
+ CreateMap()
+ .ForMember(dest => dest.StatusName, options => options.MapFrom(src => GetStatusDescription(src.Status)));
+ CreateMap();
+ CreateMap();
}
private static string GetStatusDescription(ConfigurationStatus status)
diff --git a/Source/Starfish.Service/Application/Mappings/IdentityMappingProfile.cs b/Source/Starfish.Service/Application/Mappings/IdentityMappingProfile.cs
index 3dfcd3b..e5a9b76 100644
--- a/Source/Starfish.Service/Application/Mappings/IdentityMappingProfile.cs
+++ b/Source/Starfish.Service/Application/Mappings/IdentityMappingProfile.cs
@@ -31,4 +31,9 @@ public IdentityMappingProfile()
CreateMap();
CreateMap();
}
+
+ private static string Mask(string source)
+ {
+ return $"{source[..3]}******{source[^3..]}";
+ }
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Subscribers/ConfigurationArchiveEventSubscriber.cs b/Source/Starfish.Service/Application/Subscribers/ConfigurationArchiveEventSubscriber.cs
deleted file mode 100644
index b9a9e61..0000000
--- a/Source/Starfish.Service/Application/Subscribers/ConfigurationArchiveEventSubscriber.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using Nerosoft.Euonia.Bus;
-
-namespace Nerosoft.Starfish.Application;
-
-///
-/// 配置归档事件订阅者
-///
-public class ConfigurationArchiveEventSubscriber : IHandler
-{
- private readonly IBus _bus;
-
- public ConfigurationArchiveEventSubscriber(IBus bus)
- {
- _bus = bus;
- }
-
- ///
- /// 处理配置发布事件
- ///
- ///
- ///
- ///
- ///
- ///
- public Task HandleAsync(ConfigurationPublishedEvent message, MessageContext context, CancellationToken cancellationToken = default)
- {
- var command = new ConfigurationArchiveCreateCommand
- {
- AppId = message.AppId,
- Environment = message.Environment,
- };
-
- return _bus.SendAsync(command, new SendOptions { RequestTraceId = context.RequestTraceId }, null, cancellationToken);
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Subscribers/ConfigurationRevisionEventSubscriber.cs b/Source/Starfish.Service/Application/Subscribers/ConfigurationRevisionEventSubscriber.cs
deleted file mode 100644
index 51e9d4c..0000000
--- a/Source/Starfish.Service/Application/Subscribers/ConfigurationRevisionEventSubscriber.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using Nerosoft.Euonia.Bus;
-
-namespace Nerosoft.Starfish.Application;
-
-///
-/// 配置版本事件订阅者
-///
-public class ConfigurationRevisionEventSubscriber : IHandler
-{
- private readonly IBus _bus;
-
- public ConfigurationRevisionEventSubscriber(IBus bus)
- {
- _bus = bus;
- }
-
- ///
- /// 处理配置发布事件
- ///
- ///
- ///
- ///
- ///
- ///
- public Task HandleAsync(ConfigurationPublishedEvent message, MessageContext context, CancellationToken cancellationToken = default)
- {
- var command = new ConfigurationRevisionCreateCommand(message.AppId, message.Environment)
- {
- Version = message.Version,
- Comment = message.Comment
- };
- return _bus.SendAsync(command, new SendOptions { RequestTraceId = context.RequestTraceId }, null, cancellationToken);
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Application/Subscribers/LoggingEventSubscriber.cs b/Source/Starfish.Service/Application/Subscribers/LoggingEventSubscriber.cs
index 3b2c172..9b90848 100644
--- a/Source/Starfish.Service/Application/Subscribers/LoggingEventSubscriber.cs
+++ b/Source/Starfish.Service/Application/Subscribers/LoggingEventSubscriber.cs
@@ -8,6 +8,8 @@ namespace Nerosoft.Starfish.Application;
///
public sealed class LoggingEventSubscriber
{
+ private const string MODULE_CONFIG = "config";
+
private readonly IBus _bus;
public LoggingEventSubscriber(IBus bus)
@@ -59,22 +61,23 @@ public Task HandleAsync(UserAuthFailedEvent @event, MessageContext context, Canc
return _bus.SendAsync(command, new SendOptions { RequestTraceId = context.RequestTraceId }, null, cancellationToken);
}
-
+
///
- /// 处理应用创建事件
+ /// 处理配置启用事件
///
///
///
///
+ ///
[Subscribe]
- public Task HandleAsync(AppInfoCreatedEvent @event, MessageContext context, CancellationToken cancellationToken = default)
+ public Task HandleAsync(ConfigurationEnabledEvent @event, MessageContext context, CancellationToken cancellationToken = default)
{
- var aggregate = @event.GetAggregate();
+ var aggregate = @event.GetAggregate();
var command = new OperateLogCreateCommand
{
- Module = "apps",
- Type = "create",
- Description = string.Format(Resources.IDS_MESSAGE_LOGS_APPS_CREATE, aggregate.Id, aggregate.Name),
+ Module = MODULE_CONFIG,
+ Type = "status",
+ Description = string.Format(Resources.IDS_MESSAGE_LOGS_CONFIG_ENABLE, aggregate.Id, aggregate.Name),
OperateTime = DateTime.Now,
RequestTraceId = context.RequestTraceId,
UserName = context.User?.Identity?.Name
@@ -84,21 +87,21 @@ public Task HandleAsync(AppInfoCreatedEvent @event, MessageContext context, Canc
}
///
- /// 处理应用启用事件
+ /// 处理配置禁用事件
///
///
///
///
///
[Subscribe]
- public Task HandleAsync(AppInfoEnabledEvent @event, MessageContext context, CancellationToken cancellationToken = default)
+ public Task HandleAsync(ConfigurationDisableEvent @event, MessageContext context, CancellationToken cancellationToken = default)
{
- var aggregate = @event.GetAggregate();
+ var aggregate = @event.GetAggregate();
var command = new OperateLogCreateCommand
{
- Module = "apps",
+ Module = MODULE_CONFIG,
Type = "status",
- Description = string.Format(Resources.IDS_MESSAGE_LOGS_APPS_ENABLE, aggregate.Id, aggregate.Name),
+ Description = string.Format(Resources.IDS_MESSAGE_LOGS_CONFIG_DISABLE, aggregate.Id, aggregate.Name),
OperateTime = DateTime.Now,
RequestTraceId = context.RequestTraceId,
UserName = context.User?.Identity?.Name
@@ -108,38 +111,21 @@ public Task HandleAsync(AppInfoEnabledEvent @event, MessageContext context, Canc
}
///
- /// 处理应用禁用事件
+ /// 处理配置密钥重置事件
///
///
///
///
///
[Subscribe]
- public Task HandleAsync(AppInfoDisableEvent @event, MessageContext context, CancellationToken cancellationToken = default)
+ public Task HandleAsync(ConfigurationSecretChangedEvent @event, MessageContext context, CancellationToken cancellationToken = default)
{
- var aggregate = @event.GetAggregate();
- var command = new OperateLogCreateCommand
- {
- Module = "appinfo",
- Type = "status",
- Description = string.Format(Resources.IDS_MESSAGE_LOGS_APPS_DISABLE, aggregate.Id, aggregate.Name),
- OperateTime = DateTime.Now,
- RequestTraceId = context.RequestTraceId,
- UserName = context.User?.Identity?.Name
- };
-
- return _bus.SendAsync(command, new SendOptions { RequestTraceId = context.RequestTraceId }, null, cancellationToken);
- }
-
- [Subscribe]
- public Task HandleAsync(AppInfoSecretChangedEvent @event, MessageContext context, CancellationToken cancellationToken = default)
- {
- var aggregate = @event.GetAggregate();
+ var aggregate = @event.GetAggregate();
var command = new OperateLogCreateCommand
{
- Module = "apps",
+ Module = MODULE_CONFIG,
Type = "secret",
- Description = string.Format(Resources.IDS_MESSAGE_LOGS_APPS_RESET_SECRET, aggregate.Id, aggregate.Name),
+ Description = string.Format(Resources.IDS_MESSAGE_LOGS_CONFIG_RESET_SECRET, aggregate.Id, aggregate.Name),
OperateTime = DateTime.Now,
RequestTraceId = context.RequestTraceId,
UserName = context.User?.Identity?.Name
@@ -148,15 +134,22 @@ public Task HandleAsync(AppInfoSecretChangedEvent @event, MessageContext context
return _bus.SendAsync(command, new SendOptions { RequestTraceId = context.RequestTraceId }, null, cancellationToken);
}
+ ///
+ /// 处理配置更新事件
+ ///
+ ///
+ ///
+ ///
+ ///
[Subscribe]
- public Task HandleAsync(AppInfoUpdatedEvent @event, MessageContext context, CancellationToken cancellationToken = default)
+ public Task HandleAsync(ConfigurationUpdatedEvent @event, MessageContext context, CancellationToken cancellationToken = default)
{
- var aggregate = @event.GetAggregate();
+ var aggregate = @event.GetAggregate();
var command = new OperateLogCreateCommand
{
- Module = "apps",
+ Module = MODULE_CONFIG,
Type = "update",
- Description = string.Format(Resources.IDS_MESSAGE_LOGS_APPS_UPDATE, aggregate.Id, aggregate.Name),
+ Description = string.Format(Resources.IDS_MESSAGE_LOGS_CONFIG_UPDATE, aggregate.Id, aggregate.Name),
OperateTime = DateTime.Now,
RequestTraceId = context.RequestTraceId,
UserName = context.User?.Identity?.Name
@@ -165,22 +158,6 @@ public Task HandleAsync(AppInfoUpdatedEvent @event, MessageContext context, Canc
return _bus.SendAsync(command, new SendOptions { RequestTraceId = context.RequestTraceId }, null, cancellationToken);
}
- [Subscribe]
- public Task HandleAsync(AppInfoDeletedEvent @event, MessageContext context, CancellationToken cancellationToken = default)
- {
- var aggregate = @event.GetAggregate();
- var command = new OperateLogCreateCommand
- {
- Module = "apps",
- Type = "delete",
- Description = string.Format(Resources.IDS_MESSAGE_LOGS_APPS_DELETE, aggregate.Id, aggregate.Name),
- OperateTime = DateTime.Now,
- RequestTraceId = context.RequestTraceId,
- UserName = context.User?.Identity?.Name
- };
- return _bus.SendAsync(command, new SendOptions { RequestTraceId = context.RequestTraceId }, null, cancellationToken);
- }
-
///
/// 处理配置节点创建事件
///
@@ -191,11 +168,11 @@ public Task HandleAsync(AppInfoDeletedEvent @event, MessageContext context, Canc
[Subscribe]
public Task HandleAsync(ConfigurationCreatedEvent @event, MessageContext context, CancellationToken cancellationToken = default)
{
- var description = string.Format(Resources.IDS_MESSAGE_LOGS_CONFIG_CREATE, @event.Configuration.AppId, @event.Configuration.Environment);
+ var description = string.Format(Resources.IDS_MESSAGE_LOGS_CONFIG_CREATE, @event.Configuration.Id, @event.Configuration.Name);
var command = new OperateLogCreateCommand
{
- Module = "config",
+ Module = MODULE_CONFIG,
Type = "create",
Description = description,
OperateTime = DateTime.Now,
@@ -216,11 +193,11 @@ public Task HandleAsync(ConfigurationCreatedEvent @event, MessageContext context
public Task HandleAsync(ConfigurationDeletedEvent @event, MessageContext context, CancellationToken cancellationToken = default)
{
var aggregate = @event.GetAggregate();
- var description = string.Format(Resources.IDS_MESSAGE_LOGS_CONFIG_DELETE, aggregate.AppId, aggregate.Environment);
+ var description = string.Format(Resources.IDS_MESSAGE_LOGS_CONFIG_DELETE, aggregate.Id, aggregate.Name);
var command = new OperateLogCreateCommand
{
- Module = "config",
+ Module = MODULE_CONFIG,
Type = "delete",
Description = description,
OperateTime = DateTime.Now,
@@ -230,14 +207,22 @@ public Task HandleAsync(ConfigurationDeletedEvent @event, MessageContext context
return _bus.SendAsync(command, new SendOptions { RequestTraceId = context.RequestTraceId }, null, cancellationToken);
}
+ ///
+ /// 处理配置发布事件
+ ///
+ ///
+ ///
+ ///
+ ///
[Subscribe]
public Task HandleAsync(ConfigurationPublishedEvent @event, MessageContext context, CancellationToken cancellationToken = default)
{
- var description = string.Format(Resources.IDS_MESSAGE_LOGS_CONFIG_PUBLISH, @event.AppId, @event.Environment);
+ var aggregate = @event.GetAggregate();
+ var description = string.Format(Resources.IDS_MESSAGE_LOGS_CONFIG_PUBLISH, aggregate.Id, aggregate.Name);
var command = new OperateLogCreateCommand
{
- Module = "config",
+ Module = MODULE_CONFIG,
Type = "publish",
Description = description,
OperateTime = DateTime.Now,
@@ -246,6 +231,4 @@ public Task HandleAsync(ConfigurationPublishedEvent @event, MessageContext conte
};
return _bus.SendAsync(command, new SendOptions { RequestTraceId = context.RequestTraceId }, null, cancellationToken);
}
-
-
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Aggregates/AppInfo.cs b/Source/Starfish.Service/Domain/Aggregates/AppInfo.cs
deleted file mode 100644
index cc97276..0000000
--- a/Source/Starfish.Service/Domain/Aggregates/AppInfo.cs
+++ /dev/null
@@ -1,165 +0,0 @@
-using System.Text.RegularExpressions;
-using Nerosoft.Euonia.Domain;
-
-namespace Nerosoft.Starfish.Domain;
-
-///
-/// 应用信息
-///
-public sealed class AppInfo : Aggregate,
- IHasCreateTime,
- IHasUpdateTime
-{
- private const string PATTERN_SECRET = @"^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,32}$";
-
- ///
- /// 此构造方法仅提供给EntityFramework使用
- ///
- private AppInfo()
- {
- }
-
- private AppInfo(string teamId)
- : this()
- {
- TeamId = teamId;
- }
-
- ///
- /// 团队Id
- ///
- public string TeamId { get; set; }
-
- ///
- /// 名称
- ///
- public string Name { get; set; }
-
- ///
- /// 密钥
- ///
- public string Secret { get; set; }
-
- ///
- /// 描述
- ///
- public string Description { get; set; }
-
- ///
- /// 状态
- ///
- public AppStatus Status { get; set; } = AppStatus.Enabled;
-
- ///
- /// 创建时间
- ///
- public DateTime CreateTime { get; set; }
-
- ///
- /// 更新时间
- ///
- public DateTime UpdateTime { get; set; }
-
- ///
- /// 创建应用
- ///
- ///
- ///
- ///
- ///
- internal static AppInfo Create(string teamId, string name)
- {
- var entity = new AppInfo(teamId);
- entity.SetName(name);
- entity.RaiseEvent(new AppInfoCreatedEvent());
- return entity;
- }
-
- ///
- /// 设置名称
- ///
- ///
- internal void SetName(string name)
- {
- ArgumentNullException.ThrowIfNull(name);
- Name = name;
- }
-
- ///
- /// 设置描述
- ///
- ///
- internal void SetDescription(string description)
- {
- Description = description;
- }
-
- ///
- /// 跟新应用信息
- ///
- ///
- ///
- internal void Update(string name, string description)
- {
- if (string.Equals(Name, name, StringComparison.OrdinalIgnoreCase) && string.Equals(Description, description, StringComparison.OrdinalIgnoreCase))
- {
- return;
- }
-
- Name = name;
- Description = description;
- RaiseEvent(new AppInfoUpdatedEvent());
- }
-
- ///
- /// 设置APP密钥
- ///
- ///
- /// 密钥不符合规则时引发异常
- internal void SetSecret(string secret)
- {
- if (string.IsNullOrWhiteSpace(secret))
- {
- throw new BadRequestException(Resources.IDS_ERROR_APPINFO_SECRET_REQUIRED);
- }
-
- if (!Regex.IsMatch(secret, PATTERN_SECRET))
- {
- throw new BadRequestException(Resources.IDS_ERROR_APPINFO_SECRET_NOT_MATCHES_RULE);
- }
-
- Secret = Cryptography.SHA.Encrypt(secret);
- if (!string.IsNullOrEmpty(Id))
- {
- RaiseEvent(new AppInfoSecretChangedEvent());
- }
- }
-
- ///
- /// 启用
- ///
- internal void Enable()
- {
- if (Status == AppStatus.Enabled)
- {
- return;
- }
-
- Status = AppStatus.Enabled;
- RaiseEvent(new AppInfoEnabledEvent());
- }
-
- ///
- /// 禁用
- ///
- internal void Disable()
- {
- if (Status == AppStatus.Disabled)
- {
- return;
- }
-
- Status = AppStatus.Disabled;
- RaiseEvent(new AppInfoDisableEvent());
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Aggregates/Configuration.cs b/Source/Starfish.Service/Domain/Aggregates/Configuration.cs
index 7d99561..7bfcb9a 100644
--- a/Source/Starfish.Service/Domain/Aggregates/Configuration.cs
+++ b/Source/Starfish.Service/Domain/Aggregates/Configuration.cs
@@ -1,4 +1,5 @@
-using Nerosoft.Euonia.Domain;
+using System.Text.RegularExpressions;
+using Nerosoft.Euonia.Domain;
using Nerosoft.Starfish.Service;
using Newtonsoft.Json;
@@ -7,7 +8,7 @@ namespace Nerosoft.Starfish.Domain;
///
/// 设置聚合根
///
-public sealed class Configuration : Aggregate, IAuditing
+public sealed class Configuration : Aggregate, IAuditing
{
private Configuration()
{
@@ -15,17 +16,47 @@ private Configuration()
{
Status = @event.NewStatus;
});
+ Register(@event =>
+ {
+ Name = @event.NewName;
+ });
+ Register(@event =>
+ {
+ Secret = @event.Secret;
+ });
+ Register(_ =>
+ {
+ SetStatus(ConfigurationStatus.Pending);
+ });
}
+ private Configuration(string teamId, string name)
+ : this()
+ {
+ TeamId = teamId;
+ Name = name;
+ Status = ConfigurationStatus.Pending;
+ }
+
+ ///
+ /// 团队Id
+ ///
+ public string TeamId { get; set; }
+
///
- /// 应用Id
+ /// 配置名称
///
- public string AppId { get; set; }
+ public string Name { get; set; }
///
- /// 应用环境
+ /// 配置描述
///
- public string Environment { get; set; }
+ public string Description { get; set; }
+
+ ///
+ /// 访问密钥
+ ///
+ public string Secret { get; set; }
///
/// 状态
@@ -67,32 +98,56 @@ private Configuration()
public HashSet Revisions { get; set; }
///
- /// 应用信息
+ /// 配置归档
///
- public AppInfo App { get; set; }
+ public ConfigurationArchive Archive { get; set; }
- internal static Configuration Create(string appId, string environment, IDictionary items)
+ internal static Configuration Create(string teamId, string name)
{
- var configuration = new Configuration
- {
- AppId = appId,
- Environment = environment,
- Status = ConfigurationStatus.Pending
- };
-
- configuration.AddOrUpdateItem(items);
-
+ var configuration = new Configuration(teamId, name);
configuration.RaiseEvent(new ConfigurationCreatedEvent(configuration));
return configuration;
}
- internal void AddOrUpdateItem(IDictionary items)
+ internal void SetName(string name)
{
- if (Status == ConfigurationStatus.Disabled)
+ EnsureStatus();
+
+ ArgumentException.ThrowIfNullOrWhiteSpace(name);
+ if (string.Equals(name, Name, StringComparison.OrdinalIgnoreCase))
+ {
+ return;
+ }
+
+ RaiseEvent(new ConfigurationNameChangedEvent(Name, name));
+ }
+
+ ///
+ /// 设置访问密钥
+ ///
+ ///
+ /// 密钥不符合规则时引发异常
+ internal void SetSecret(string secret)
+ {
+ EnsureStatus();
+
+ ArgumentException.ThrowIfNullOrWhiteSpace(secret);
+
+ if (!Regex.IsMatch(secret, Constants.RegexPattern.Secret))
{
- throw new InvalidOperationException(Resources.IDS_ERROR_CONFIG_DISABLED);
+ throw new BadRequestException(Resources.IDS_ERROR_CONFIG_SECRET_NOT_MATCHES_RULE);
}
+ if (!string.IsNullOrEmpty(Id))
+ {
+ RaiseEvent(new ConfigurationSecretChangedEvent(Cryptography.SHA.Encrypt(secret)));
+ }
+ }
+
+ internal void UpdateItem(IDictionary items)
+ {
+ EnsureStatus();
+
Items ??= [];
Items.RemoveAll(t => !items.ContainsKey(t.Key));
foreach (var (key, value) in items)
@@ -109,15 +164,12 @@ internal void AddOrUpdateItem(IDictionary items)
}
}
- Status = ConfigurationStatus.Pending;
+ RaiseEvent(new ConfigurationItemChangedEvent());
}
internal void UpdateItem(string key, string value)
{
- if (Status == ConfigurationStatus.Disabled)
- {
- throw new InvalidOperationException(Resources.IDS_ERROR_CONFIG_DISABLED);
- }
+ EnsureStatus();
Items ??= [];
@@ -128,42 +180,99 @@ internal void UpdateItem(string key, string value)
throw new InvalidOperationException(string.Format(Resources.IDS_ERROR_CONFIG_KEY_NOT_EXISTS, key));
}
+ if (string.Equals(item.Value, value))
+ {
+ return;
+ }
+
item.Value = value;
- Status = ConfigurationStatus.Pending;
+ RaiseEvent(new ConfigurationItemChangedEvent());
}
- internal void SetStatus(ConfigurationStatus status)
+ private void CreateRevision(string version, string comment, string @operator)
{
- if (Status == status)
+ Revisions ??= [];
+
+ if (Revisions.Any(t => string.Equals(t.Version, version, StringComparison.OrdinalIgnoreCase)))
{
- return;
+ throw new InvalidOperationException(string.Format(Resources.IDS_ERROR_CONFIG_VERSION_NUMBER_EXISTS, version));
}
- RaiseEvent(new ConfigurationStatusChangedEvent(Status, status));
+ var data = JsonConvert.SerializeObject(Items, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
+
+ var revision = new ConfigurationRevision(version, comment, data, @operator);
+
+ Revisions.Add(revision);
+ }
+
+ private void CreateArchive(string @operator)
+ {
+ Archive ??= ConfigurationArchive.Create(Id);
+ var data = Items.ToDictionary(t => t.Key, t => t.Value);
+
+ Archive.Update(JsonConvert.SerializeObject(data), @operator);
}
- internal void CreateRevision(string version, string comment, string @operator)
+ internal void Publish(string version, string comment, string @operator)
{
+ EnsureStatus();
+
if (Items == null || Items.Count == 0)
+ {
+ throw new InvalidOperationException(Resources.IDS_ERROR_CONFIG_NO_ITEMS);
+ }
+
+ CreateArchive(@operator);
+ CreateRevision(version, comment, @operator);
+ Version = version;
+ PublishTime = DateTime.Now;
+ SetStatus(ConfigurationStatus.Published);
+ RaiseEvent(new ConfigurationPublishedEvent());
+ }
+
+ internal void Disable()
+ {
+ if (Status == ConfigurationStatus.Disabled)
{
return;
}
- Revisions ??= [];
+ SetStatus(ConfigurationStatus.Disabled);
+ RaiseEvent(new ConfigurationDisableEvent());
+ }
- if (Revisions.Any(t => string.Equals(t.Version, version, StringComparison.OrdinalIgnoreCase)))
+ internal void Enable()
+ {
+ if (Status != ConfigurationStatus.Disabled)
{
- throw new InvalidOperationException(string.Format(Resources.IDS_ERROR_CONFIG_VERSION_NUMBER_EXISTS, version));
+ return;
}
- var data = JsonConvert.SerializeObject(Items, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
+ SetStatus(ConfigurationStatus.Pending);
+ RaiseEvent(new ConfigurationEnabledEvent());
+ }
- var revision = new ConfigurationRevision(version, comment, data, @operator);
+ internal void SetDescription(string description)
+ {
+ Description = description;
+ }
- Revisions.Add(revision);
+ private void EnsureStatus()
+ {
+ if (Status == ConfigurationStatus.Disabled)
+ {
+ throw new ConfigurationDisabledException(Id);
+ }
+ }
- Version = version;
- PublishTime = DateTime.Now;
+ private void SetStatus(ConfigurationStatus status)
+ {
+ if (Status == status)
+ {
+ return;
+ }
+
+ RaiseEvent(new ConfigurationStatusChangedEvent(Status, status));
}
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Aggregates/ConfigurationArchive.cs b/Source/Starfish.Service/Domain/Aggregates/ConfigurationArchive.cs
index bca3528..6d8abf9 100644
--- a/Source/Starfish.Service/Domain/Aggregates/ConfigurationArchive.cs
+++ b/Source/Starfish.Service/Domain/Aggregates/ConfigurationArchive.cs
@@ -5,20 +5,11 @@ namespace Nerosoft.Starfish.Domain;
///
/// 配置归档
///
-public sealed class ConfigurationArchive : Aggregate
+public sealed class ConfigurationArchive : Aggregate
{
private ConfigurationArchive()
- { }
-
- ///
- /// 应用Id
- ///
- public string AppId { get; set; }
-
- ///
- /// 应用环境
- ///
- public string Environment { get; set; }
+ {
+ }
///
/// 配置数据
@@ -35,12 +26,13 @@ private ConfigurationArchive()
///
public DateTime ArchiveTime { get; set; }
- internal static ConfigurationArchive Create(string appId, string environment)
+ public Configuration Configuration { get; set; }
+
+ internal static ConfigurationArchive Create(string configId)
{
var entity = new ConfigurationArchive()
{
- AppId = appId,
- Environment = environment
+ Id = configId
};
return entity;
diff --git a/Source/Starfish.Service/Domain/Aggregates/ConfigurationItem.cs b/Source/Starfish.Service/Domain/Aggregates/ConfigurationItem.cs
index d848602..657eb6f 100644
--- a/Source/Starfish.Service/Domain/Aggregates/ConfigurationItem.cs
+++ b/Source/Starfish.Service/Domain/Aggregates/ConfigurationItem.cs
@@ -25,7 +25,7 @@ internal ConfigurationItem(string key, string value)
Value = value;
}
- public long ConfigurationId { get; set; }
+ public string ConfigurationId { get; set; }
public string Key { get; set; }
diff --git a/Source/Starfish.Service/Domain/Aggregates/ConfigurationRevision.cs b/Source/Starfish.Service/Domain/Aggregates/ConfigurationRevision.cs
index 12c8241..977387c 100644
--- a/Source/Starfish.Service/Domain/Aggregates/ConfigurationRevision.cs
+++ b/Source/Starfish.Service/Domain/Aggregates/ConfigurationRevision.cs
@@ -20,7 +20,7 @@ internal ConfigurationRevision(string version, string comment, string data, stri
Operator = @operator;
}
- public long ConfigurationId { get; set; }
+ public string ConfigurationId { get; set; }
///
/// 配置数据
diff --git a/Source/Starfish.Service/Domain/Business/AppInfoGeneralBusiness.cs b/Source/Starfish.Service/Domain/Business/AppInfoGeneralBusiness.cs
deleted file mode 100644
index 5ab46f6..0000000
--- a/Source/Starfish.Service/Domain/Business/AppInfoGeneralBusiness.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-using Nerosoft.Euonia.Business;
-using Nerosoft.Euonia.Domain;
-using Nerosoft.Starfish.Service;
-
-// ReSharper disable MemberCanBePrivate.Global
-
-namespace Nerosoft.Starfish.Domain;
-
-public class AppInfoGeneralBusiness : EditableObjectBase, IDomainService
-{
- [Inject]
- public IAppInfoRepository AppInfoRepository { get; set; }
-
- [Inject]
- public ITeamRepository TeamRepository { get; set; }
-
- internal AppInfo Aggregate { get; private set; }
-
- public static readonly PropertyInfo IdProperty = RegisterProperty(p => p.Id);
- public static readonly PropertyInfo TeamIdProperty = RegisterProperty(p => p.TeamId);
- public static readonly PropertyInfo NameProperty = RegisterProperty(p => p.Name);
- public static readonly PropertyInfo SecretProperty = RegisterProperty(p => p.Secret);
- public static readonly PropertyInfo DescriptionProperty = RegisterProperty(p => p.Description);
-
- public string Id
- {
- get => ReadProperty(IdProperty);
- set => LoadProperty(IdProperty, value);
- }
-
- public string TeamId
- {
- get => GetProperty(TeamIdProperty);
- set => SetProperty(TeamIdProperty, value);
- }
-
- public string Name
- {
- get => GetProperty(NameProperty);
- set => SetProperty(NameProperty, value);
- }
-
- public string Secret
- {
- get => GetProperty(SecretProperty);
- set => SetProperty(SecretProperty, value);
- }
-
- public string Description
- {
- get => GetProperty(DescriptionProperty);
- set => SetProperty(DescriptionProperty, value);
- }
-
- [FactoryCreate]
- protected override Task CreateAsync(CancellationToken cancellationToken = default)
- {
- return Task.CompletedTask;
- }
-
- [FactoryFetch]
- protected async Task FetchAsync(string id, CancellationToken cancellationToken = default)
- {
- var aggregate = await AppInfoRepository.GetAsync(id, true, [], cancellationToken);
-
- Aggregate = aggregate ?? throw new AppInfoNotFoundException(id);
-
- using (BypassRuleChecks)
- {
- Id = aggregate.Id;
- TeamId = aggregate.TeamId;
- Name = aggregate.Name;
- Description = aggregate.Description;
- }
- }
-
- [FactoryInsert]
- protected override async Task InsertAsync(CancellationToken cancellationToken = default)
- {
- await CheckPermissionAsync(TeamId, cancellationToken);
-
- Aggregate = AppInfo.Create(TeamId, Name);
- Aggregate.SetSecret(Secret);
- if (!string.IsNullOrWhiteSpace(Description))
- {
- Aggregate.SetDescription(Description);
- }
-
- await AppInfoRepository.InsertAsync(Aggregate, true, cancellationToken);
- Id = Aggregate.Id;
- }
-
- [FactoryUpdate]
- protected override async Task UpdateAsync(CancellationToken cancellationToken = default)
- {
- await CheckPermissionAsync(Aggregate.TeamId, cancellationToken);
-
- if (!HasChangedProperties)
- {
- return;
- }
-
- if (ChangedProperties.Contains(NameProperty))
- {
- Aggregate.SetName(Name);
- }
-
- if (ChangedProperties.Contains(DescriptionProperty))
- {
- Aggregate.SetDescription(Description);
- }
-
- await AppInfoRepository.UpdateAsync(Aggregate, true, cancellationToken);
- }
-
- [FactoryDelete]
- protected override async Task DeleteAsync(CancellationToken cancellationToken = default)
- {
- await CheckPermissionAsync(Aggregate.TeamId, cancellationToken);
- Aggregate.RaiseEvent(new AppInfoDeletedEvent());
- await AppInfoRepository.DeleteAsync(Aggregate, true, cancellationToken);
- }
-
- private async Task CheckPermissionAsync(string teamId, CancellationToken cancellationToken = default)
- {
- var team = await TeamRepository.GetAsync(teamId, false, cancellationToken);
- if (team.OwnerId != Identity.UserId)
- {
- throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
- }
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Business/AppInfoSecretBusiness.cs b/Source/Starfish.Service/Domain/Business/AppInfoSecretBusiness.cs
deleted file mode 100644
index 7029beb..0000000
--- a/Source/Starfish.Service/Domain/Business/AppInfoSecretBusiness.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using Nerosoft.Euonia.Business;
-using Nerosoft.Euonia.Claims;
-using Nerosoft.Euonia.Domain;
-
-namespace Nerosoft.Starfish.Domain;
-
-public class AppInfoSecretBusiness : CommandObject, IDomainService
-{
- [Inject]
- public IAppInfoRepository AppsRepository { get; set; }
-
- [Inject]
- public ITeamRepository TeamRepository { get; set; }
-
- [Inject]
- private UserPrincipal Identity { get; set; }
-
- [FactoryExecute]
- protected async Task ExecuteAsync(string id, string secret, CancellationToken cancellationToken = default)
- {
- var aggregate = await AppsRepository.GetAsync(id, true, cancellationToken);
- if (aggregate == null)
- {
- throw new AppInfoNotFoundException(id);
- }
-
- var team = await TeamRepository.GetAsync(aggregate.TeamId, false, cancellationToken);
- if (team.OwnerId != Identity.UserId)
- {
- throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
- }
-
- aggregate.SetSecret(secret);
-
- await AppsRepository.UpdateAsync(aggregate, true, cancellationToken);
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Business/AppInfoStatusBusiness.cs b/Source/Starfish.Service/Domain/Business/AppInfoStatusBusiness.cs
deleted file mode 100644
index fc21963..0000000
--- a/Source/Starfish.Service/Domain/Business/AppInfoStatusBusiness.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using Nerosoft.Euonia.Business;
-using Nerosoft.Euonia.Claims;
-using Nerosoft.Euonia.Domain;
-
-namespace Nerosoft.Starfish.Domain;
-
-public class AppInfoStatusBusiness : CommandObject, IDomainService
-{
- [Inject]
- public IAppInfoRepository AppInfoRepository { get; set; }
-
- [Inject]
- public ITeamRepository TeamRepository { get; set; }
-
- [Inject]
- private UserPrincipal Identity { get; set; }
-
- [FactoryExecute]
- protected async Task ExecuteAsync(string id, AppStatus status, CancellationToken cancellationToken = default)
- {
- var aggregate = await AppInfoRepository.GetAsync(id, true, cancellationToken);
- if (aggregate == null)
- {
- throw new AppInfoNotFoundException(id);
- }
-
- var team = await TeamRepository.GetAsync(aggregate.TeamId, false, cancellationToken);
- if (team.OwnerId != Identity.UserId)
- {
- throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
- }
-
- switch (status)
- {
- case AppStatus.Disabled:
- aggregate.Disable();
- break;
- case AppStatus.Enabled:
- aggregate.Enable();
- break;
- case AppStatus.None:
- default:
- throw new ArgumentOutOfRangeException(Resources.IDS_ERROR_APPINFO_STATUS_INVALID);
- }
-
- await AppInfoRepository.UpdateAsync(aggregate, true, cancellationToken);
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Business/ConfigurationArchiveBusiness.cs b/Source/Starfish.Service/Domain/Business/ConfigurationArchiveBusiness.cs
deleted file mode 100644
index d78be29..0000000
--- a/Source/Starfish.Service/Domain/Business/ConfigurationArchiveBusiness.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using Nerosoft.Euonia.Business;
-using Nerosoft.Euonia.Domain;
-using Newtonsoft.Json;
-
-namespace Nerosoft.Starfish.Domain;
-
-public class ConfigurationArchiveBusiness : CommandObject, IDomainService
-{
- [Inject]
- public IConfigurationRepository ConfigurationRepository { get; set; }
-
- [Inject]
- public IConfigurationArchiveRepository ArchiveRepository { get; set; }
-
- [FactoryExecute]
- protected async Task ExecuteAsync(string appId, string environment, string userName, CancellationToken cancellationToken = default)
- {
- var aggregate = await ConfigurationRepository.GetAsync(appId, environment, false, [nameof(Configuration.Items)], cancellationToken);
-
- if (aggregate == null)
- {
- throw new ConfigurationNotFoundException(appId, environment);
- }
-
- var data = aggregate.Items.ToDictionary(t => t.Key, t => t.Value);
- var json = JsonConvert.SerializeObject(data);
-
- var archive = await ArchiveRepository.GetAsync(appId, environment, cancellationToken);
-
- archive ??= ConfigurationArchive.Create(appId, environment);
-
- archive.Update(GzipHelper.CompressToBase64(json), userName);
-
- if (archive.Id > 0)
- {
- await ArchiveRepository.UpdateAsync(archive, true, cancellationToken);
- }
- else
- {
- await ArchiveRepository.InsertAsync(archive, true, cancellationToken);
- }
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Business/ConfigurationGeneralBusiness.cs b/Source/Starfish.Service/Domain/Business/ConfigurationGeneralBusiness.cs
index 6768e64..a17bf6e 100644
--- a/Source/Starfish.Service/Domain/Business/ConfigurationGeneralBusiness.cs
+++ b/Source/Starfish.Service/Domain/Business/ConfigurationGeneralBusiness.cs
@@ -8,54 +8,47 @@ namespace Nerosoft.Starfish.Domain;
internal class ConfigurationGeneralBusiness : EditableObjectBase
{
[Inject]
- public IAppInfoRepository AppInfoRepository { get; set; }
+ public ITeamRepository TeamRepository { get; set; }
[Inject]
public IConfigurationRepository ConfigurationRepository { get; set; }
internal Configuration Aggregate { get; private set; }
- public static readonly PropertyInfo IdProperty = RegisterProperty(p => p.Id);
- public static readonly PropertyInfo AppIdProperty = RegisterProperty(p => p.AppId);
- public static readonly PropertyInfo EnvironmentProperty = RegisterProperty(p => p.Environment);
- public static readonly PropertyInfo> ItemsProperty = RegisterProperty>(p => p.Items);
- public static readonly PropertyInfo KeyProperty = RegisterProperty(p => p.Key);
- public static readonly PropertyInfo ValueProperty = RegisterProperty(p => p.Value);
+ public static readonly PropertyInfo IdProperty = RegisterProperty(p => p.Id);
+ public static readonly PropertyInfo TeamIdProperty = RegisterProperty(p => p.TeamId);
+ public static readonly PropertyInfo NameProperty = RegisterProperty(p => p.Name);
+ public static readonly PropertyInfo DescriptionProperty = RegisterProperty(p => p.Description);
+ public static readonly PropertyInfo SecretProperty = RegisterProperty(p => p.Secret);
- public long Id
+ public string Id
{
get => ReadProperty(IdProperty);
set => LoadProperty(IdProperty, value);
}
- public string AppId
+ public string TeamId
{
- get => GetProperty(AppIdProperty);
- set => SetProperty(AppIdProperty, value);
+ get => GetProperty(TeamIdProperty);
+ set => SetProperty(TeamIdProperty, value);
}
- public string Environment
+ public string Name
{
- get => GetProperty(EnvironmentProperty);
- set => SetProperty(EnvironmentProperty, value);
+ get => GetProperty(NameProperty);
+ set => SetProperty(NameProperty, value);
}
- public IDictionary Items
+ public string Description
{
- get => GetProperty(ItemsProperty);
- set => SetProperty(ItemsProperty, value);
+ get => GetProperty(DescriptionProperty);
+ set => SetProperty(DescriptionProperty, value);
}
- public string Key
+ public string Secret
{
- get => GetProperty(KeyProperty);
- set => SetProperty(KeyProperty, value);
- }
-
- public string Value
- {
- get => GetProperty(ValueProperty);
- set => SetProperty(ValueProperty, value);
+ get => GetProperty(SecretProperty);
+ set => SetProperty(SecretProperty, value);
}
protected override void AddRules()
@@ -70,49 +63,39 @@ protected override async Task CreateAsync(CancellationToken cancellationToken =
}
[FactoryFetch]
- protected async Task FetchAsync(string appId, string environment, CancellationToken cancellationToken = default)
+ protected async Task FetchAsync(string id, CancellationToken cancellationToken = default)
{
- var aggregate = await ConfigurationRepository.GetAsync(appId, environment, true, [nameof(Configuration.Items)], cancellationToken);
+ var aggregate = await ConfigurationRepository.GetAsync(id, true, [nameof(Configuration.Items)], cancellationToken);
- Aggregate = aggregate ?? throw new ConfigurationNotFoundException(appId, environment);
+ Aggregate = aggregate ?? throw new ConfigurationNotFoundException(id);
using (BypassRuleChecks)
{
Id = aggregate.Id;
- AppId = aggregate.AppId;
- Environment = aggregate.Environment;
+ TeamId = aggregate.TeamId;
+ Name = aggregate.Name;
+ Description = aggregate.Description;
}
}
[FactoryInsert]
protected override async Task InsertAsync(CancellationToken cancellationToken = default)
{
- var permission = await AppInfoRepository.CheckPermissionAsync(AppId, Identity.UserId, cancellationToken);
+ var permission = await TeamRepository.CheckPermissionAsync(TeamId, Identity.UserId, cancellationToken);
switch (permission)
{
- case 0:
+ case PermissionState.None: // 无权限
throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
- case 1:
- case 2:
+ case PermissionState.Edit:
break;
+ case PermissionState.Read:
+ throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
default:
throw new ArgumentOutOfRangeException();
}
- var appInfo = await AppInfoRepository.GetAsync(AppId, cancellationToken);
-
- if (appInfo == null)
- {
- throw new AppInfoNotFoundException(AppId);
- }
-
- if (appInfo.Status != AppStatus.Enabled)
- {
- throw new AppInfoNotEnabledException(AppId);
- }
-
- var aggregate = Configuration.Create(AppId, Environment, Items);
+ var aggregate = Configuration.Create(TeamId, Name);
await ConfigurationRepository.InsertAsync(aggregate, true, cancellationToken);
Id = aggregate.Id;
}
@@ -120,15 +103,16 @@ protected override async Task InsertAsync(CancellationToken cancellationToken =
[FactoryUpdate]
protected override async Task UpdateAsync(CancellationToken cancellationToken = default)
{
- var permission = await AppInfoRepository.CheckPermissionAsync(AppId, Identity.UserId, cancellationToken);
+ var permission = await TeamRepository.CheckPermissionAsync(Aggregate.TeamId, Identity.UserId, cancellationToken);
switch (permission)
{
- case 0:
- throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
- case 1:
- case 2:
+ case PermissionState.None: // 无权限
+ throw new ConfigurationNotFoundException(Id);
+ case PermissionState.Edit:
break;
+ case PermissionState.Read:
+ throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
default:
throw new ArgumentOutOfRangeException();
}
@@ -138,30 +122,39 @@ protected override async Task UpdateAsync(CancellationToken cancellationToken =
return;
}
- if (ChangedProperties.Contains(ItemsProperty))
+ if (ChangedProperties.Contains(NameProperty))
+ {
+ Aggregate.SetName(Name);
+ }
+
+ if (ChangedProperties.Contains(SecretProperty))
{
- Aggregate.AddOrUpdateItem(Items);
+ Aggregate.SetSecret(Secret);
}
- else if (ChangedProperties.Contains(KeyProperty) && ChangedProperties.Contains(ValueProperty))
+
+ if (ChangedProperties.Contains(DescriptionProperty))
{
- Aggregate.UpdateItem(Key, Value);
+ Aggregate.SetDescription(Description);
}
+ Aggregate.RaiseEvent(new ConfigurationUpdatedEvent());
+
await ConfigurationRepository.UpdateAsync(Aggregate, true, cancellationToken);
}
[FactoryDelete]
protected override async Task DeleteAsync(CancellationToken cancellationToken = default)
{
- var permission = await AppInfoRepository.CheckPermissionAsync(AppId, Identity.UserId, cancellationToken);
+ var permission = await TeamRepository.CheckPermissionAsync(Aggregate.TeamId, Identity.UserId, cancellationToken);
switch (permission)
{
- case 0:
- throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
- case 1:
- case 2:
+ case PermissionState.None: // 无权限
+ throw new ConfigurationNotFoundException(Id);
+ case PermissionState.Edit:
break;
+ case PermissionState.Read:
+ throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
default:
throw new ArgumentOutOfRangeException();
}
@@ -180,10 +173,10 @@ public override async Task ExecuteAsync(IRuleContext context, CancellationToken
return;
}
- var exists = await target.ConfigurationRepository.ExistsAsync(target.AppId, target.Environment, cancellationToken);
+ var exists = await target.ConfigurationRepository.ExistsAsync(target.TeamId, target.Name, cancellationToken);
if (exists)
{
- context.AddErrorResult(string.Format(Resources.IDS_ERROR_CONFIG_DUPLICATE, target.AppId, target.Environment));
+ context.AddErrorResult(string.Format(Resources.IDS_ERROR_CONFIG_DUPLICATE, target.TeamId, target.Name));
}
}
}
diff --git a/Source/Starfish.Service/Domain/Business/ConfigurationItemsBusiness.cs b/Source/Starfish.Service/Domain/Business/ConfigurationItemsBusiness.cs
new file mode 100644
index 0000000..f8438fe
--- /dev/null
+++ b/Source/Starfish.Service/Domain/Business/ConfigurationItemsBusiness.cs
@@ -0,0 +1,72 @@
+using Nerosoft.Euonia.Business;
+using Nerosoft.Euonia.Domain;
+using Nerosoft.Starfish.Service;
+
+namespace Nerosoft.Starfish.Domain;
+
+public class ConfigurationItemsBusiness : CommandObjectBase, IDomainService
+{
+ [Inject]
+ public ITeamRepository TeamRepository { get; set; }
+
+ [Inject]
+ public IConfigurationRepository ConfigurationRepository { get; set; }
+
+ [FactoryExecute]
+ protected async Task ExecuteAsync(string id, IDictionary items, CancellationToken cancellationToken = default)
+ {
+ var aggregate = await ConfigurationRepository.GetAsync(id, true, cancellationToken);
+
+ if (aggregate == null)
+ {
+ throw new ConfigurationNotFoundException(id);
+ }
+
+ var permission = await TeamRepository.CheckPermissionAsync(aggregate.TeamId, Identity.UserId, cancellationToken);
+
+ switch (permission)
+ {
+ case PermissionState.None: // 无权限
+ throw new ConfigurationNotFoundException(id);
+ case PermissionState.Edit:
+ break;
+ case PermissionState.Read:
+ throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+
+ aggregate.UpdateItem(items);
+
+ await ConfigurationRepository.UpdateAsync(aggregate, true, cancellationToken);
+ }
+
+ [FactoryExecute]
+ protected async Task ExecuteAsync(string id, string key, string value, CancellationToken cancellationToken = default)
+ {
+ var aggregate = await ConfigurationRepository.GetAsync(id, true, cancellationToken);
+
+ if (aggregate == null)
+ {
+ throw new ConfigurationNotFoundException(id);
+ }
+
+ var permission = await TeamRepository.CheckPermissionAsync(id, Identity.UserId, cancellationToken);
+
+ switch (permission)
+ {
+ case PermissionState.None: // 无权限
+ throw new ConfigurationNotFoundException(id);
+ case PermissionState.Edit:
+ break;
+ case PermissionState.Read:
+ throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+
+ aggregate.UpdateItem(key, value);
+
+ await ConfigurationRepository.UpdateAsync(aggregate, true, cancellationToken);
+ }
+}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Business/ConfigurationPublishBusiness.cs b/Source/Starfish.Service/Domain/Business/ConfigurationPublishBusiness.cs
index b34b51c..88f937d 100644
--- a/Source/Starfish.Service/Domain/Business/ConfigurationPublishBusiness.cs
+++ b/Source/Starfish.Service/Domain/Business/ConfigurationPublishBusiness.cs
@@ -1,6 +1,7 @@
using Nerosoft.Euonia.Business;
using Nerosoft.Euonia.Claims;
using Nerosoft.Euonia.Domain;
+using Nerosoft.Starfish.Service;
// ReSharper disable UnusedMember.Global
@@ -9,47 +10,41 @@ namespace Nerosoft.Starfish.Domain;
///
/// 应用配置发布领域服务
///
-public class ConfigurationPublishBusiness : CommandObject, IDomainService
+public class ConfigurationPublishBusiness : CommandObjectBase, IDomainService
{
[Inject]
- public IAppInfoRepository AppInfoRepository { get; set; }
+ public ITeamRepository TeamRepository { get; set; }
[Inject]
public IConfigurationRepository ConfigurationRepository { get; set; }
- [Inject]
- public UserPrincipal Identity { get; set; }
-
[FactoryExecute]
- protected async Task ExecuteAsync(string appId, string environment, CancellationToken cancellationToken = default)
+ protected async Task ExecuteAsync(string id, string version, string comment, CancellationToken cancellationToken = default)
{
- var permission = await AppInfoRepository.CheckPermissionAsync(appId, Identity.UserId, cancellationToken);
+ string[] includeProperties = [nameof(Configuration.Items), nameof(Configuration.Revisions), nameof(Configuration.Archive)];
- switch(permission)
- {
- case 0:
- throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
- case 1:
- break;
- case 2:
- throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
- default:
- throw new ArgumentOutOfRangeException();
- }
-
- var aggregate = await ConfigurationRepository.GetAsync(appId, environment, true, [], cancellationToken);
+ var aggregate = await ConfigurationRepository.GetAsync(id, true, includeProperties, cancellationToken);
if (aggregate == null)
{
- throw new ConfigurationNotFoundException(appId, environment);
+ throw new ConfigurationNotFoundException(id);
}
- if (aggregate.Status == ConfigurationStatus.Disabled)
+ var permission = await TeamRepository.CheckPermissionAsync(id, Identity.UserId, cancellationToken);
+
+ switch (permission)
{
- throw new ConfigurationDisabledException(appId, environment);
+ case PermissionState.None: // 无权限
+ throw new ConfigurationNotFoundException(id);
+ case PermissionState.Edit:
+ break;
+ case PermissionState.Read:
+ throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
+ default:
+ throw new ArgumentOutOfRangeException();
}
- aggregate.SetStatus(ConfigurationStatus.Published);
+ aggregate.Publish(version, comment, Identity.Username);
await ConfigurationRepository.UpdateAsync(aggregate, true, cancellationToken);
}
diff --git a/Source/Starfish.Service/Domain/Business/ConfigurationRevisionBusiness.cs b/Source/Starfish.Service/Domain/Business/ConfigurationRevisionBusiness.cs
deleted file mode 100644
index 79d1c82..0000000
--- a/Source/Starfish.Service/Domain/Business/ConfigurationRevisionBusiness.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using Nerosoft.Euonia.Business;
-using Nerosoft.Euonia.Domain;
-
-namespace Nerosoft.Starfish.Domain;
-
-public class ConfigurationRevisionBusiness : CommandObject, IDomainService
-{
- private readonly IConfigurationRepository _repository;
-
- public ConfigurationRevisionBusiness(IConfigurationRepository repository)
- {
- _repository = repository;
- }
-
- [FactoryExecute]
- protected async Task ExecuteAsync(string appId, string environment, ConfigurationRevisionArgument argument, CancellationToken cancellationToken = default)
- {
- var aggregate = await _repository.GetAsync(appId, environment, true, [nameof(Configuration.Items), nameof(Configuration.Revisions)], cancellationToken);
-
- if (aggregate == null)
- {
- throw new ConfigurationNotFoundException(appId, environment);
- }
-
- aggregate.CreateRevision(argument.Version, argument.Comment, argument.Username);
- await _repository.UpdateAsync(aggregate, true, cancellationToken);
- }
-}
-
-public record ConfigurationRevisionArgument(string Version, string Comment, string Username);
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Business/ConfigurationSecretBusiness.cs b/Source/Starfish.Service/Domain/Business/ConfigurationSecretBusiness.cs
new file mode 100644
index 0000000..52a98f8
--- /dev/null
+++ b/Source/Starfish.Service/Domain/Business/ConfigurationSecretBusiness.cs
@@ -0,0 +1,43 @@
+using Nerosoft.Euonia.Business;
+using Nerosoft.Euonia.Domain;
+using Nerosoft.Starfish.Service;
+
+namespace Nerosoft.Starfish.Domain;
+
+public class ConfigurationSecretBusiness : CommandObjectBase, IDomainService
+{
+ [Inject]
+ public ITeamRepository TeamRepository { get; set; }
+
+ [Inject]
+ public IConfigurationRepository ConfigurationRepository { get; set; }
+
+ [FactoryExecute]
+ protected async Task ExecuteAsync(string id, string secret, CancellationToken cancellationToken = default)
+ {
+ var aggregate = await ConfigurationRepository.GetAsync(id, true, cancellationToken);
+
+ if (aggregate == null)
+ {
+ throw new ConfigurationNotFoundException(id);
+ }
+
+ var permission = await TeamRepository.CheckPermissionAsync(id, Identity.UserId, cancellationToken);
+
+ switch (permission)
+ {
+ case PermissionState.None: // 无权限
+ throw new ConfigurationNotFoundException(id);
+ case PermissionState.Edit:
+ break;
+ case PermissionState.Read:
+ throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+
+ aggregate.SetSecret(secret);
+
+ await ConfigurationRepository.UpdateAsync(aggregate, true, cancellationToken);
+ }
+}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Business/ConfigurationStatusBusiness.cs b/Source/Starfish.Service/Domain/Business/ConfigurationStatusBusiness.cs
new file mode 100644
index 0000000..e39c49a
--- /dev/null
+++ b/Source/Starfish.Service/Domain/Business/ConfigurationStatusBusiness.cs
@@ -0,0 +1,50 @@
+using Nerosoft.Euonia.Business;
+using Nerosoft.Euonia.Domain;
+using Nerosoft.Starfish.Service;
+
+namespace Nerosoft.Starfish.Domain;
+
+public class ConfigurationStatusBusiness : CommandObjectBase, IDomainService
+{
+ [Inject]
+ public ITeamRepository TeamRepository { get; set; }
+
+ [Inject]
+ public IConfigurationRepository ConfigurationRepository { get; set; }
+
+ [FactoryExecute]
+ protected async Task ExecuteAsync(string id, bool availability, CancellationToken cancellationToken = default)
+ {
+ var aggregate = await ConfigurationRepository.GetAsync(id, true, cancellationToken);
+
+ if (aggregate == null)
+ {
+ throw new ConfigurationNotFoundException(id);
+ }
+
+ var permission = await TeamRepository.CheckPermissionAsync(id, Identity.UserId, cancellationToken);
+
+ switch (permission)
+ {
+ case PermissionState.None: // 无权限
+ throw new ConfigurationNotFoundException(id);
+ case PermissionState.Edit:
+ break;
+ case PermissionState.Read:
+ throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+
+ if (availability)
+ {
+ aggregate.Enable();
+ }
+ else
+ {
+ aggregate.Disable();
+ }
+
+ await ConfigurationRepository.UpdateAsync(aggregate, true, cancellationToken);
+ }
+}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Business/ConfigurationValueBusiness.cs b/Source/Starfish.Service/Domain/Business/ConfigurationValueBusiness.cs
new file mode 100644
index 0000000..ba902e9
--- /dev/null
+++ b/Source/Starfish.Service/Domain/Business/ConfigurationValueBusiness.cs
@@ -0,0 +1,43 @@
+using Nerosoft.Euonia.Business;
+using Nerosoft.Euonia.Domain;
+using Nerosoft.Starfish.Service;
+
+namespace Nerosoft.Starfish.Domain;
+
+public class ConfigurationValueBusiness : CommandObjectBase, IDomainService
+{
+ [Inject]
+ public ITeamRepository TeamRepository { get; set; }
+
+ [Inject]
+ public IConfigurationRepository ConfigurationRepository { get; set; }
+
+ [FactoryExecute]
+ protected async Task ExecuteAsync(string id, string key, string value, CancellationToken cancellationToken = default)
+ {
+ var aggregate = await ConfigurationRepository.GetAsync(id, true, cancellationToken);
+
+ if (aggregate == null)
+ {
+ throw new ConfigurationNotFoundException(id);
+ }
+
+ var permission = await TeamRepository.CheckPermissionAsync(id, Identity.UserId, cancellationToken);
+
+ switch (permission)
+ {
+ case PermissionState.None: // 无权限
+ throw new ConfigurationNotFoundException(id);
+ case PermissionState.Edit:
+ break;
+ case PermissionState.Read:
+ throw new UnauthorizedAccessException(Resources.IDS_ERROR_COMMON_UNAUTHORIZED_ACCESS);
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+
+ aggregate.UpdateItem(key, value);
+
+ await ConfigurationRepository.UpdateAsync(aggregate, true, cancellationToken);
+ }
+}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Enums/AppStatus.cs b/Source/Starfish.Service/Domain/Enums/AppStatus.cs
deleted file mode 100644
index 884c542..0000000
--- a/Source/Starfish.Service/Domain/Enums/AppStatus.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System.ComponentModel;
-
-namespace Nerosoft.Starfish.Domain;
-
-///
-/// 应用状态枚举
-///
-public enum AppStatus
-{
- ///
- ///
- ///
- None = 0,
-
- ///
- /// 启用
- ///
- [Description(nameof(Resources.IDS_ENUM_APPINFO_STATUS_ENABLED))]
- Enabled = 1,
-
- ///
- /// 禁用
- ///
- [Description(nameof(Resources.IDS_ENUM_APPINFO_STATUS_DISABLED))]
- Disabled = 2
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Events/AppInfoCreatedEvent.cs b/Source/Starfish.Service/Domain/Events/AppInfoCreatedEvent.cs
deleted file mode 100644
index e4fb6d0..0000000
--- a/Source/Starfish.Service/Domain/Events/AppInfoCreatedEvent.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using Nerosoft.Euonia.Domain;
-
-namespace Nerosoft.Starfish.Domain;
-
-///
-/// 应用创建领域事件
-///
-public class AppInfoCreatedEvent : DomainEvent
-{
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Events/AppInfoDeletedEvent.cs b/Source/Starfish.Service/Domain/Events/AppInfoDeletedEvent.cs
deleted file mode 100644
index b3e4e43..0000000
--- a/Source/Starfish.Service/Domain/Events/AppInfoDeletedEvent.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using Nerosoft.Euonia.Domain;
-
-namespace Nerosoft.Starfish.Domain;
-
-///
-/// 应用信息删除事件
-///
-public class AppInfoDeletedEvent : DomainEvent
-{
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Events/AppInfoSecretChangedEvent.cs b/Source/Starfish.Service/Domain/Events/AppInfoSecretChangedEvent.cs
deleted file mode 100644
index 6fa87b7..0000000
--- a/Source/Starfish.Service/Domain/Events/AppInfoSecretChangedEvent.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using Nerosoft.Euonia.Domain;
-
-namespace Nerosoft.Starfish.Domain;
-
-///
-/// 应用信息密钥重置事件
-///
-public class AppInfoSecretChangedEvent : DomainEvent
-{
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Events/AppInfoDisableEvent.cs b/Source/Starfish.Service/Domain/Events/ConfigurationDisableEvent.cs
similarity index 71%
rename from Source/Starfish.Service/Domain/Events/AppInfoDisableEvent.cs
rename to Source/Starfish.Service/Domain/Events/ConfigurationDisableEvent.cs
index 422326f..4cfc779 100644
--- a/Source/Starfish.Service/Domain/Events/AppInfoDisableEvent.cs
+++ b/Source/Starfish.Service/Domain/Events/ConfigurationDisableEvent.cs
@@ -5,6 +5,6 @@ namespace Nerosoft.Starfish.Domain;
///
/// 应用禁用领域事件
///
-public class AppInfoDisableEvent : DomainEvent
+public class ConfigurationDisableEvent : DomainEvent
{
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Events/AppInfoEnabledEvent.cs b/Source/Starfish.Service/Domain/Events/ConfigurationEnabledEvent.cs
similarity index 71%
rename from Source/Starfish.Service/Domain/Events/AppInfoEnabledEvent.cs
rename to Source/Starfish.Service/Domain/Events/ConfigurationEnabledEvent.cs
index a5e4791..7c1231a 100644
--- a/Source/Starfish.Service/Domain/Events/AppInfoEnabledEvent.cs
+++ b/Source/Starfish.Service/Domain/Events/ConfigurationEnabledEvent.cs
@@ -5,6 +5,6 @@ namespace Nerosoft.Starfish.Domain;
///
/// 应用启用领域事件
///
-public class AppInfoEnabledEvent : DomainEvent
+public class ConfigurationEnabledEvent : DomainEvent
{
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Events/ConfigurationItemChangedEvent.cs b/Source/Starfish.Service/Domain/Events/ConfigurationItemChangedEvent.cs
new file mode 100644
index 0000000..83ccbe3
--- /dev/null
+++ b/Source/Starfish.Service/Domain/Events/ConfigurationItemChangedEvent.cs
@@ -0,0 +1,7 @@
+using Nerosoft.Euonia.Domain;
+
+namespace Nerosoft.Starfish.Domain;
+
+public class ConfigurationItemChangedEvent : DomainEvent
+{
+}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Events/ConfigurationNameChangedEvent.cs b/Source/Starfish.Service/Domain/Events/ConfigurationNameChangedEvent.cs
new file mode 100644
index 0000000..24ee3f6
--- /dev/null
+++ b/Source/Starfish.Service/Domain/Events/ConfigurationNameChangedEvent.cs
@@ -0,0 +1,16 @@
+using Nerosoft.Euonia.Domain;
+
+namespace Nerosoft.Starfish.Domain;
+
+public class ConfigurationNameChangedEvent : DomainEvent
+{
+ public ConfigurationNameChangedEvent(string oldName, string newName)
+ {
+ OldName = oldName;
+ NewName = newName;
+ }
+
+ public string OldName { get; set; }
+
+ public string NewName { get; set; }
+}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Events/ConfigurationPublishedEvent.cs b/Source/Starfish.Service/Domain/Events/ConfigurationPublishedEvent.cs
new file mode 100644
index 0000000..4375792
--- /dev/null
+++ b/Source/Starfish.Service/Domain/Events/ConfigurationPublishedEvent.cs
@@ -0,0 +1,7 @@
+using Nerosoft.Euonia.Domain;
+
+namespace Nerosoft.Starfish.Domain;
+
+public class ConfigurationPublishedEvent : DomainEvent
+{
+}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Events/ConfigurationSecretChangedEvent.cs b/Source/Starfish.Service/Domain/Events/ConfigurationSecretChangedEvent.cs
new file mode 100644
index 0000000..1fd5432
--- /dev/null
+++ b/Source/Starfish.Service/Domain/Events/ConfigurationSecretChangedEvent.cs
@@ -0,0 +1,13 @@
+using Nerosoft.Euonia.Domain;
+
+namespace Nerosoft.Starfish.Domain;
+
+public class ConfigurationSecretChangedEvent : DomainEvent
+{
+ public ConfigurationSecretChangedEvent(string secret)
+ {
+ Secret = secret;
+ }
+
+ public string Secret { get; set; }
+}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Events/AppInfoUpdatedEvent.cs b/Source/Starfish.Service/Domain/Events/ConfigurationUpdatedEvent.cs
similarity index 71%
rename from Source/Starfish.Service/Domain/Events/AppInfoUpdatedEvent.cs
rename to Source/Starfish.Service/Domain/Events/ConfigurationUpdatedEvent.cs
index 263ee98..d5b91bd 100644
--- a/Source/Starfish.Service/Domain/Events/AppInfoUpdatedEvent.cs
+++ b/Source/Starfish.Service/Domain/Events/ConfigurationUpdatedEvent.cs
@@ -5,6 +5,6 @@ namespace Nerosoft.Starfish.Domain;
///
/// 应用信息更新事件
///
-public class AppInfoUpdatedEvent : DomainEvent
+public class ConfigurationUpdatedEvent : DomainEvent
{
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Exceptions/AppInfoNotEnabledException.cs b/Source/Starfish.Service/Domain/Exceptions/AppInfoNotEnabledException.cs
deleted file mode 100644
index 635ca23..0000000
--- a/Source/Starfish.Service/Domain/Exceptions/AppInfoNotEnabledException.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace Nerosoft.Starfish.Domain;
-
-public class AppInfoNotEnabledException : BadRequestException
-{
- public AppInfoNotEnabledException(string appId)
- : base(string.Format(Resources.IDS_ERROR_APPINFO_NOT_ENABLED, appId))
- {
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Exceptions/AppInfoNotFoundException.cs b/Source/Starfish.Service/Domain/Exceptions/AppInfoNotFoundException.cs
deleted file mode 100644
index 3caf232..0000000
--- a/Source/Starfish.Service/Domain/Exceptions/AppInfoNotFoundException.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-namespace Nerosoft.Starfish.Domain;
-
-///
-/// 应用信息不存在异常
-///
-public class AppInfoNotFoundException : NotFoundException
-{
- ///
- /// 构造函数
- ///
- ///
- public AppInfoNotFoundException(string id)
- : base(string.Format(Resources.IDS_ERROR_APPINFO_NOT_EXISTS, id))
- {
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Exceptions/ConfigurationDisabledException.cs b/Source/Starfish.Service/Domain/Exceptions/ConfigurationDisabledException.cs
index 8308fe3..cd1ce7e 100644
--- a/Source/Starfish.Service/Domain/Exceptions/ConfigurationDisabledException.cs
+++ b/Source/Starfish.Service/Domain/Exceptions/ConfigurationDisabledException.cs
@@ -2,8 +2,8 @@
public class ConfigurationDisabledException : BadRequestException
{
- public ConfigurationDisabledException(string appId, string environment)
- : base(string.Format(Resources.IDS_ERROR_CONFIG_DISABLED, appId, environment))
+ public ConfigurationDisabledException(string id)
+ : base(string.Format(Resources.IDS_ERROR_CONFIG_DISABLED, id))
{
}
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Exceptions/ConfigurationNotFoundException.cs b/Source/Starfish.Service/Domain/Exceptions/ConfigurationNotFoundException.cs
index 00bd293..de42b28 100644
--- a/Source/Starfish.Service/Domain/Exceptions/ConfigurationNotFoundException.cs
+++ b/Source/Starfish.Service/Domain/Exceptions/ConfigurationNotFoundException.cs
@@ -5,13 +5,13 @@
///
public class ConfigurationNotFoundException : NotFoundException
{
- ///
- /// 构造函数
- ///
- /// 应用Id
- /// 应用环境
- public ConfigurationNotFoundException(string appId, string environment)
- : base(string.Format(Resources.IDS_ERROR_CONFIG_NOT_EXISTS, appId, environment))
+ public ConfigurationNotFoundException()
+ : base(Resources.IDS_ERROR_CONFIG_NOT_EXISTS)
+ {
+ }
+
+ public ConfigurationNotFoundException(string id)
+ : base(string.Format(Resources.IDS_ERROR_CONFIG_NOT_EXISTS_OF_ID, id))
{
}
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Exceptions/InvalidAppInfoStatusException.cs b/Source/Starfish.Service/Domain/Exceptions/InvalidAppInfoStatusException.cs
deleted file mode 100644
index 7ff95d2..0000000
--- a/Source/Starfish.Service/Domain/Exceptions/InvalidAppInfoStatusException.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace Nerosoft.Starfish.Domain;
-
-///
-/// 应用状态无效异常
-///
-public class InvalidAppInfoStatusException : BadRequestException
-{
- public InvalidAppInfoStatusException()
- : base(Resources.IDS_ERROR_APPINFO_STATUS_INVALID)
- {
- }
-
- public InvalidAppInfoStatusException(string message)
- : base(message)
- {
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Repositories/IAppInfoRepository.cs b/Source/Starfish.Service/Domain/Repositories/IAppInfoRepository.cs
deleted file mode 100644
index 1ce6b09..0000000
--- a/Source/Starfish.Service/Domain/Repositories/IAppInfoRepository.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using Nerosoft.Starfish.Repository;
-using Nerosoft.Starfish.Service;
-
-namespace Nerosoft.Starfish.Domain;
-
-///
-/// 应用信息仓储接口
-///
-public interface IAppInfoRepository : IBaseRepository
-{
- Task CheckPermissionAsync(string appId, string userId, CancellationToken cancellationToken = default);
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Repositories/IConfigurationArchiveRepository.cs b/Source/Starfish.Service/Domain/Repositories/IConfigurationArchiveRepository.cs
deleted file mode 100644
index 66374f0..0000000
--- a/Source/Starfish.Service/Domain/Repositories/IConfigurationArchiveRepository.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using Nerosoft.Starfish.Repository;
-using Nerosoft.Starfish.Service;
-
-namespace Nerosoft.Starfish.Domain;
-
-public interface IConfigurationArchiveRepository : IBaseRepository
-{
- Task GetAsync(string appId, string environment, CancellationToken cancellationToken = default);
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Repositories/IConfigurationRepository.cs b/Source/Starfish.Service/Domain/Repositories/IConfigurationRepository.cs
index 80322d6..96bd4af 100644
--- a/Source/Starfish.Service/Domain/Repositories/IConfigurationRepository.cs
+++ b/Source/Starfish.Service/Domain/Repositories/IConfigurationRepository.cs
@@ -3,20 +3,18 @@
namespace Nerosoft.Starfish.Domain;
-public interface IConfigurationRepository : IBaseRepository
+public interface IConfigurationRepository : IBaseRepository
{
///
/// 检查配置是否存在
///
- ///
- ///
+ ///
+ ///
///
///
- Task ExistsAsync(string appId, string environment, CancellationToken cancellationToken = default);
+ Task ExistsAsync(string teamId, string name, CancellationToken cancellationToken = default);
- Task GetAsync(string appId, string environment, bool tracking, string[] properties, CancellationToken cancellationToken = default);
-
- Task> GetItemListAsync(string appId, string environment, int skip, int count, CancellationToken cancellationToken = default);
+ Task> GetItemListAsync(string id, string key, int skip, int count, CancellationToken cancellationToken = default);
- Task GetItemCountAsync(string appId, string environment, CancellationToken cancellationToken = default);
+ Task GetItemCountAsync(string id, string key, CancellationToken cancellationToken = default);
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Repositories/IConfigurationRevisionRepository.cs b/Source/Starfish.Service/Domain/Repositories/IConfigurationRevisionRepository.cs
deleted file mode 100644
index 370a52d..0000000
--- a/Source/Starfish.Service/Domain/Repositories/IConfigurationRevisionRepository.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-using Nerosoft.Starfish.Repository;
-using Nerosoft.Starfish.Service;
-
-namespace Nerosoft.Starfish.Domain;
-
-public interface IConfigurationRevisionRepository : IBaseRepository
-{
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Domain/Repositories/ITeamRepository.cs b/Source/Starfish.Service/Domain/Repositories/ITeamRepository.cs
index b9a7df1..24bd400 100644
--- a/Source/Starfish.Service/Domain/Repositories/ITeamRepository.cs
+++ b/Source/Starfish.Service/Domain/Repositories/ITeamRepository.cs
@@ -14,4 +14,6 @@ public interface ITeamRepository : IBaseRepository
Task> GetTeamsOfUserAsync(string userId, CancellationToken cancellationToken = default);
Task> GetMembersAsync(string id, CancellationToken cancellationToken = default);
+
+ Task CheckPermissionAsync(string id, string userId, CancellationToken cancellationToken = default);
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Properties/Resources.resx b/Source/Starfish.Service/Properties/Resources.resx
index c0dda26..10f0254 100644
--- a/Source/Starfish.Service/Properties/Resources.resx
+++ b/Source/Starfish.Service/Properties/Resources.resx
@@ -138,12 +138,6 @@
System administrator
-
- Disabled
-
-
- Enabled
-
Disabled
@@ -153,21 +147,6 @@
Published
-
- App not enabled, [Id]:{0}.
-
-
- App not exists, [Id]:{0}.
-
-
- The secret not matches rule.
-
-
- App secret is required.
-
-
- Invalid app status.
-
Authorize failed.
@@ -181,10 +160,10 @@
Data format required.
- Configuration was disabled, [App]:{0}, [Env]:{1}.
+ Configuration was disabled, [Id]:{0}.
- Configuration was duplicated, [App]:{0}, [Env]:{1}.
+ Configuration was duplicated.
Configuration key '{0}' exists.
@@ -193,11 +172,26 @@
Configuration key '{0}' not exists.
- Configuration not exists, [App]:{0}, [Env]:{1}.
+ Configuration not exists.
+
+
+ Configuration not exists, [Id]:{0}.
+
+
+ No configuration items were found.
No pending item to publish.
+
+ The secret not matches rule.
+
+
+ App secret is required.
+
+
+ Invalid app status.
+
Version number '{0}' already exists.
@@ -264,24 +258,6 @@
UserName '{0}' not available.
-
- Create app {0}({1}).
-
-
- Delete app {0}({1}).
-
-
- Disable app {0}({1}).
-
-
- Enable app {0}({1}).
-
-
- Reset app secret {0}({1}).
-
-
- Update app {0}({1}).
-
User authenticate failed.
@@ -289,15 +265,24 @@
User authenticate successfully.
- Create configuration, [App]:{0}, [Env]:{1}.
+ Create configuration, [Id]:{0}, [Name]:{1}.
- Delete configuration, [App]:{0}, [Env]:{1}.
+ Delete configuration, [Id]:{0}, [Name]:{1}.
+
+
+ Disable configuration, [Id]:{0}, [Name]:{1}.
+
+
+ Enable configuration, [Id]:{0}, [Name]:{1}.
- Publish configuration, [App]:{0}, [Env]:{1}.
+ Publish configuration, [Id]:{0}, [Name]:{1}.
+
+
+ Reset configuration secret, [Id]:{0}, [Name]:{1}.
- Update configuration, [App]:{0}, [Env]:{1}.
+ Update configuration, [Id]:{0}, [Name]:{1}.
\ No newline at end of file
diff --git a/Source/Starfish.Service/Properties/Resources.zh-Hans.resx b/Source/Starfish.Service/Properties/Resources.zh-Hans.resx
index 66f115d..42dc9ad 100644
--- a/Source/Starfish.Service/Properties/Resources.zh-Hans.resx
+++ b/Source/Starfish.Service/Properties/Resources.zh-Hans.resx
@@ -1,17 +1,17 @@
-
@@ -119,185 +119,224 @@
开发环境
+
性能评估测试
+
生产环境
+
模拟测试
+
系统集成测试
+
用户验收测试
+
系统管理员
-
-
- 禁用
-
-
- 启用
+
禁用
+
待发布
+
已发布
-
-
- 应用没有启用,[Id]:{0}。
-
-
- 应用不存在,[Id]:{0}。
-
-
- 密钥不符合规则。
-
-
- 应用访问密钥必须提供。
-
-
- 无效的应用状态。
+
认证失败。
+
您无权进行此操作。
+
不支持的数据格式 '{0}'。
+
数据格式不能为空。
+
- 配置已被禁用,[应用]:{0},[环境]:{1}。
+ 配置已被禁用,[Id]:{0}。
+
- 配置重复,[应用]:{0},[环境]:{1}。
+ 配置重复。
+
配置项 '{0}' 已经存在。
+
配置项 '{0}' 不存在。
+
- 配置不存在,[应用]:{0},[环境]:{1}。
+ 配置不存在。
+
+
+ 配置不存在,[Id]:{0}。
+
+
+
+ 没有找到配置项。
没有待发布的配置。
+
+
+
+ 密钥不符合规则。
+
+
+
+ 应用访问密钥必须提供。
+
+
+
+ 无效的应用状态。
+
版本号 '{0}' 已经存在。
+
请求参数'count'必须大于0。
+
请求参数'skip'不能是负数。
+
密码不正确。
+
刷新令牌已过期。
+
刷新令牌无效。
+
Token不能为空。
+
团队不存在,[Id]:{0}。
+
不能移除团队负责人。
+
用户Id(s)不能为空。
+
不支持的缓存提供程序'{0}'。
+
不支持的数据库提供程序'{0}'。
+
不支持的服务总线提供程序'{0}'。
+
邮箱 '{0}' 不可用。
+
用户已锁定。
+
预留账号不允许设置角色。
+
预留账号不允许删除。
+
用户不存在,[Id]:{0}。
+
密码长度为8 ~ 32个字符,至少包含一个大写字母和一个小写字母。
+
密码不能为空。
+
用户名或密码错误。
+
用户名'{0}'不可用。
-
-
- 新增应用 {0}({1})。
-
-
- 删除应用 {0}({1})。
-
-
- 禁用应用 {0}({1})。
-
-
- 启用应用 {0}({1})。
-
-
- 重置应用密钥 {0}({1})。
-
-
- 更新应用 {0}({1})。
+
用户认证失败。
+
用户认证成功。
+
- 新增配置,[应用]:{0},[环境]:{1}。
+ 新增配置,[Id]:{0},[名称]:{1}。
+
- 删除配置,[应用]:{0},[环境]:{1}。
+ 删除配置,[Id]:{0},[名称]:{1}。
+
+
+
+ 禁用配置,[Id]:{0},[名称]:{1}。
+
+
+
+ 启用配置,[Id]:{0},[名称]:{1}。
+
- 发布配置,[应用]:{0},[环境]:{1}。
+ 发布配置,[Id]:{0},[名称]:{1}。
+
+
+
+ 重置访问密钥,[Id]:{0},[名称]:{1}。
+
- 更新配置,[应用]:{0},[环境]:{1}。
+ 更新配置,[Id]:{0},[名称]:{1}。
+
\ No newline at end of file
diff --git a/Source/Starfish.Service/Properties/Resources.zh-Hant.resx b/Source/Starfish.Service/Properties/Resources.zh-Hant.resx
index 787d1a9..c810ce7 100644
--- a/Source/Starfish.Service/Properties/Resources.zh-Hant.resx
+++ b/Source/Starfish.Service/Properties/Resources.zh-Hant.resx
@@ -1,76 +1,96 @@
-
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
@@ -89,195 +109,234 @@
text/microsoft-resx
- 1.3
+ 2.0
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
開發環境
+
性能評估測試
+
生產環境
+
模擬測試
+
系統整合測試
+
用戶驗收測試
+
系統管理員
-
-
- 停用
-
-
- 啟用
+
停用
+
待發表
+
已發表
-
-
- 應用程式沒有啟用,[Id]:{0}。
-
-
- 應用程式不存在,[Id]:{0}。
-
-
- 密鑰不符合規則。
-
-
- 需要應用程式密鑰。
-
-
- 應用程式狀態無效。
+
認證失敗。
+
您無權進行此操作。
+
不支援資料格式“{0}”。
+
資料格式不能為空。
+
- 設置已停用,[應用程式]:{0},[環境]:{1}。
+ 配置已停用,[Id]:{0}。
+
- 設置重複,[應用程式]:{0},[環境]:{1}。
+ 配置重複。
+
- 設置項目“{0}”已經存在。
+ 配置項“{0}”已經存在。
+
- 設置項目“{0}”不存在。
+ 配置項“{0}”不存在。
+
- 設定不存在,[應用程式]:{0},[環境]:{1}。
+ 配置不存在。
+
+
+ 配置不存在,[Id]:{0}。
+
+
+
+ 沒有找到配置項。
沒有待發布的設定。
+
+
+
+ 密鑰不符合規則。
+
+
+
+ 需要應用程式密鑰。
+
+
+
+ 應用程式狀態無效。
+
版本號碼“{0}”已存在。
+
請求參數“count”必須大於0。
+
請求參數“skip”不能為負數。
+
密碼不正確。
+
刷新令牌已過期。
+
刷新令牌無效。
+
刷新令牌不能為空。
+
團隊不存在,[Id]:{0}。
+
不能移除團隊負責人。
+
用戶Id(s)不能為空。
+
不支援的緩存提供者“{0}”。
+
不支援的資料庫提供者“{0}”。
+
不支援的服務總線提供者“{0}”。
+
電子郵件“{0}”不可用。
+
用戶被鎖定。
+
預留帳號不允許設定角色。
+
預留帳號不允許刪除。
+
用戶不存在,[Id]:{0}。
+
密碼長度必須為8-32個字符,至少包含1個大寫字母,1個小寫字母。
+
密碼不能為空。
+
用戶名或密碼錯誤。
+
用戶名“{0}”不可用。
-
-
- 新增應用程式 {0}({1})。
-
-
- 刪除應用程式 {0}({1})。
-
-
- 停用應用程式 {0}({1})。
-
-
- 啟用應用程式 {0}({1})。
-
-
- 重設應用程式密鑰 {0}({1})。
-
-
- 更新應用程式 {0}({1})。
+
用戶身份驗證失敗。
+
用戶身份驗證成功。
+
- 建立設置,[應用程式]:{0},[環境]:{1}。
+ 建立配置,[Id]:{0},[名稱]:{1}。
+
- 刪除設置,[應用程式]:{0},[環境]:{1}。
+ 刪除配置,[Id]:{0},[名稱]:{1}。
+
+
+
+ 停用配置,[Id]:{0},[名稱]:{1}。
+
+
+
+ 啟用配置,[Id]:{0},[名稱]:{1}。
+
- 發佈設置,[應用程式]:{0},[環境]:{1}。
+ 發佈配置,[Id]:{0},[名稱]:{1}。
+
+
+
+ 重設訪問密鑰,[Id]:{0},[名稱]:{1}。
+
- 更新設置,[應用程式]:{0},[環境]:{1}。
+ 更新配置,[Id]:{0},[名稱]:{1}。
+
\ No newline at end of file
diff --git a/Source/Starfish.Service/Repository/Contexts/AbstractDatabaseModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/AbstractDatabaseModelBuilder.cs
index 0488a1d..3e8c7dd 100644
--- a/Source/Starfish.Service/Repository/Contexts/AbstractDatabaseModelBuilder.cs
+++ b/Source/Starfish.Service/Repository/Contexts/AbstractDatabaseModelBuilder.cs
@@ -11,7 +11,6 @@ public virtual void Configure(ModelBuilder modelBuilder)
ConfigureAdministrator(modelBuilder);
ConfigureTeam(modelBuilder);
ConfigureTeamMember(modelBuilder);
- ConfigureApplication(modelBuilder);
ConfigureConfiguration(modelBuilder);
ConfigureConfigurationItem(modelBuilder);
ConfigureConfigurationArchive(modelBuilder);
@@ -28,8 +27,6 @@ public virtual void Configure(ModelBuilder modelBuilder)
protected abstract ModelBuilder ConfigureTeamMember(ModelBuilder modelBuilder);
- protected abstract ModelBuilder ConfigureApplication(ModelBuilder modelBuilder);
-
protected abstract ModelBuilder ConfigureConfiguration(ModelBuilder modelBuilder);
protected abstract ModelBuilder ConfigureConfigurationItem(ModelBuilder modelBuilder);
diff --git a/Source/Starfish.Service/Repository/Contexts/DataContext.cs b/Source/Starfish.Service/Repository/Contexts/DataContext.cs
index 6273d3b..dd44186 100644
--- a/Source/Starfish.Service/Repository/Contexts/DataContext.cs
+++ b/Source/Starfish.Service/Repository/Contexts/DataContext.cs
@@ -78,8 +78,10 @@ public override async Task SaveChangesAsync(bool acceptAllChangesOnSuccess,
}
}
- var events = GetTrackedEvents();
var result = await base.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken);
+
+ var events = GetTrackedEvents();
+
if (result > 0 && events.Count > 0)
{
var options = new PublishOptions
diff --git a/Source/Starfish.Service/Repository/Contexts/RelationalDatabaseModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/RelationalDatabaseModelBuilder.cs
index 06d6bd0..60f1a0f 100644
--- a/Source/Starfish.Service/Repository/Contexts/RelationalDatabaseModelBuilder.cs
+++ b/Source/Starfish.Service/Repository/Contexts/RelationalDatabaseModelBuilder.cs
@@ -15,20 +15,20 @@ protected override ModelBuilder ConfigureUser(ModelBuilder modelBuilder)
entity.HasKey(t => t.Id);
entity.HasIndex(t => t.UserName)
- .HasDatabaseName("IDX_USER_NAME")
- .IsUnique();
+ .HasDatabaseName("IDX_USER_NAME")
+ .IsUnique();
entity.HasIndex(t => t.Email)
- .HasDatabaseName("IDX_USER_EMAIL")
- .IsUnique();
+ .HasDatabaseName("IDX_USER_EMAIL")
+ .IsUnique();
entity.HasIndex(t => t.Phone)
- .HasDatabaseName("IDX_USER_PHONE")
- .IsUnique();
+ .HasDatabaseName("IDX_USER_PHONE")
+ .IsUnique();
entity.Property(t => t.Id)
- .IsRequired()
- .HasValueGenerator();
+ .IsRequired()
+ .HasValueGenerator();
});
}
@@ -41,15 +41,15 @@ protected override ModelBuilder ConfigureAdministrator(ModelBuilder modelBuilder
entity.HasKey(t => t.Id);
entity.HasIndex(t => t.UserId).HasDatabaseName("IDX_ADMIN_USER_ID")
- .IsUnique();
+ .IsUnique();
entity.Property(t => t.Id)
- .IsRequired()
- .HasValueGenerator();
+ .IsRequired()
+ .HasValueGenerator();
entity.HasOne(t => t.User)
- .WithMany()
- .HasForeignKey(t => t.UserId);
+ .WithMany()
+ .HasForeignKey(t => t.UserId);
});
}
@@ -64,12 +64,12 @@ protected override ModelBuilder ConfigureTeam(ModelBuilder modelBuilder)
entity.HasIndex(t => t.OwnerId).HasDatabaseName("IDX_TEAM_OWNER");
entity.Property(t => t.Id)
- .IsRequired()
- .HasValueGenerator();
+ .IsRequired()
+ .HasValueGenerator();
entity.HasMany(t => t.Members)
- .WithOne(t => t.Team)
- .HasForeignKey(t => t.TeamId);
+ .WithOne(t => t.Team)
+ .HasForeignKey(t => t.TeamId);
});
}
@@ -81,35 +81,19 @@ protected override ModelBuilder ConfigureTeamMember(ModelBuilder modelBuilder)
entity.HasKey(t => t.Id);
entity.HasIndex([nameof(TeamMember.TeamId), nameof(TeamMember.UserId)], "IDX_TEAM_MEMBER_UNIQUE")
- .IsUnique();
+ .IsUnique();
entity.Property(t => t.Id)
- .IsRequired()
- .HasValueGenerator();
+ .IsRequired()
+ .HasValueGenerator();
entity.HasOne(t => t.Team)
- .WithMany(t => t.Members)
- .HasForeignKey(t => t.TeamId);
+ .WithMany(t => t.Members)
+ .HasForeignKey(t => t.TeamId);
entity.HasOne(t => t.User)
- .WithMany()
- .HasForeignKey(t => t.UserId);
- });
- }
-
- protected override ModelBuilder ConfigureApplication(ModelBuilder modelBuilder)
- {
- return modelBuilder.Entity(entity =>
- {
- entity.ToTable("app_info");
- entity.HasKey(t => t.Id);
-
- entity.HasIndex(t => t.TeamId).HasDatabaseName("IDX_APP_TEAM_ID");
- entity.HasIndex(t => t.Status).HasDatabaseName("IDX_APP_INFO_TEAM_ID");
-
- entity.Property(t => t.Id)
- .IsRequired()
- .HasValueGenerator();
+ .WithMany()
+ .HasForeignKey(t => t.UserId);
});
}
@@ -121,30 +105,31 @@ protected override ModelBuilder ConfigureConfiguration(ModelBuilder modelBuilder
entity.HasKey(t => t.Id);
- entity.HasIndex(t => t.AppId).HasDatabaseName("IDX_CONFIG_APP_ID");
+ entity.HasIndex(t => t.TeamId).HasDatabaseName("IDX_CONFIG_TEAM_ID");
entity.HasIndex(t => t.Status).HasDatabaseName("IDX_CONFIG_STATUS");
+ entity.HasIndex(t => t.Name).HasDatabaseName("IDX_CONFIG_NAME");
- entity.HasIndex([nameof(Configuration.AppId), nameof(Configuration.Environment)], "IDX_CONFIG_UNIQUE")
- .IsUnique();
+ entity.HasIndex([nameof(Configuration.TeamId), nameof(Configuration.Name)], "IDX_CONFIG_UNIQUE")
+ .IsUnique();
entity.Property(t => t.Id)
- .IsRequired()
- .HasValueGenerator();
-
- entity.HasOne(t => t.App)
- .WithMany()
- .HasForeignKey(t => t.AppId)
- .OnDelete(DeleteBehavior.Cascade);
+ .IsRequired()
+ .HasValueGenerator();
entity.HasMany(t => t.Items)
- .WithOne()
- .HasForeignKey(t => t.ConfigurationId)
- .OnDelete(DeleteBehavior.Cascade);
+ .WithOne()
+ .HasForeignKey(t => t.ConfigurationId)
+ .OnDelete(DeleteBehavior.Cascade);
entity.HasMany(t => t.Revisions)
- .WithOne()
- .HasForeignKey(t => t.ConfigurationId)
- .OnDelete(DeleteBehavior.Cascade);
+ .WithOne()
+ .HasForeignKey(t => t.ConfigurationId)
+ .OnDelete(DeleteBehavior.Cascade);
+
+ entity.HasOne(t => t.Archive)
+ .WithOne()
+ .HasForeignKey()
+ .OnDelete(DeleteBehavior.Cascade);
});
}
@@ -158,16 +143,16 @@ protected override ModelBuilder ConfigureConfigurationItem(ModelBuilder modelBui
entity.HasIndex(t => t.ConfigurationId).HasDatabaseName("IDX_CONFIG_ITEM_FK");
entity.HasIndex([nameof(ConfigurationItem.ConfigurationId), nameof(ConfigurationItem.Key)], "IDX_CONFIG_ITEM_UNIQUE")
- .IsUnique();
+ .IsUnique();
entity.Property(t => t.Id)
- .IsRequired()
- .HasValueGenerator();
+ .IsRequired()
+ .HasValueGenerator();
entity.HasOne(t => t.Configuration)
- .WithMany(t => t.Items)
- .HasForeignKey(t => t.ConfigurationId)
- .OnDelete(DeleteBehavior.Cascade);
+ .WithMany(t => t.Items)
+ .HasForeignKey(t => t.ConfigurationId)
+ .OnDelete(DeleteBehavior.Cascade);
});
}
@@ -179,13 +164,8 @@ protected override ModelBuilder ConfigureConfigurationArchive(ModelBuilder model
entity.HasKey(t => t.Id);
- entity.HasIndex(t => t.AppId).HasDatabaseName("IDX_CONFIG_ARCHIVE_APP_ID");
- entity.HasIndex([nameof(ConfigurationArchive.AppId), nameof(ConfigurationArchive.Environment)], "IDX_CONFIG_ARCHIVE_UNIQUE")
- .IsUnique();
-
entity.Property(t => t.Id)
- .IsRequired()
- .HasValueGenerator();
+ .IsRequired();
});
}
@@ -200,13 +180,13 @@ protected override ModelBuilder ConfigureConfigurationRevision(ModelBuilder mode
entity.HasIndex(t => t.ConfigurationId).HasDatabaseName("IDS_CONFIG_REVISION_FK");
entity.Property(t => t.Id)
- .IsRequired()
- .HasValueGenerator();
+ .IsRequired()
+ .HasValueGenerator();
entity.HasOne(t => t.Configuration)
- .WithMany(t => t.Revisions)
- .HasForeignKey(t => t.ConfigurationId)
- .OnDelete(DeleteBehavior.Cascade);
+ .WithMany(t => t.Revisions)
+ .HasForeignKey(t => t.ConfigurationId)
+ .OnDelete(DeleteBehavior.Cascade);
});
}
@@ -222,8 +202,8 @@ protected override ModelBuilder ConfigureToken(ModelBuilder modelBuilder)
entity.HasIndex(t => t.Expires).HasDatabaseName("IDX_TOKEN_EXPIRES");
entity.Property(t => t.Id)
- .IsRequired()
- .HasValueGenerator();
+ .IsRequired()
+ .HasValueGenerator();
});
}
@@ -240,8 +220,8 @@ protected override ModelBuilder ConfigureOperationLog(ModelBuilder modelBuilder)
entity.HasIndex(t => t.UserName).HasDatabaseName("IDX_OPERATE_LOG_USER_NAME");
entity.Property(t => t.Id)
- .IsRequired()
- .HasValueGenerator();
+ .IsRequired()
+ .HasValueGenerator();
});
}
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Repository/CriteriaExtensions.cs b/Source/Starfish.Service/Repository/CriteriaExtensions.cs
index 50a4ab8..8be5e46 100644
--- a/Source/Starfish.Service/Repository/CriteriaExtensions.cs
+++ b/Source/Starfish.Service/Repository/CriteriaExtensions.cs
@@ -52,56 +52,35 @@ public static Specification GetSpecification(this OperateLogCriteria
}
///
- /// 获取应用信息查询规约
+ /// 获取配置节点查询规约
///
///
///
- public static Specification GetSpecification(this AppInfoCriteria criteria)
+ public static Specification GetSpecification(this ConfigurationCriteria criteria)
{
- Specification specification = new TrueSpecification();
+ Specification specification = new TrueSpecification();
if (criteria == null)
{
return specification;
}
- if (criteria.Status > 0)
- {
- var status = (AppStatus)criteria.Status;
- if (status != AppStatus.None && Enum.IsDefined(status))
- {
- specification &= AppInfoSpecification.StatusEquals(status);
- }
- }
-
- if (!string.IsNullOrEmpty(criteria.TeamId))
+ if (!string.IsNullOrWhiteSpace(criteria.TeamId))
{
- specification &= AppInfoSpecification.TeamIdEquals(criteria.TeamId);
+ specification &= ConfigurationSpecification.TeamIdEquals(criteria.TeamId);
}
if (!string.IsNullOrWhiteSpace(criteria.Keyword))
{
- specification &= AppInfoSpecification.NameContains(criteria.Keyword);
- }
-
- return specification;
- }
-
- ///
- /// 获取配置节点查询规约
- ///
- ///
- ///
- public static Specification GetSpecification(this ConfigurationCriteria criteria)
- {
- Specification specification = new TrueSpecification();
- if (criteria == null)
- {
- return specification;
+ specification &= ConfigurationSpecification.Matches(criteria.Keyword);
}
- if (!string.IsNullOrWhiteSpace(criteria.Environment))
+ if (criteria.Status > 0)
{
- specification &= ConfigurationSpecification.EnvironmentEquals(criteria.Environment);
+ var status = (ConfigurationStatus)criteria.Status;
+ if (status != ConfigurationStatus.None && Enum.IsDefined(status))
+ {
+ specification &= ConfigurationSpecification.StatusEquals(status);
+ }
}
return specification;
diff --git a/Source/Starfish.Service/Repository/Repositories/AppInfoRepository.cs b/Source/Starfish.Service/Repository/Repositories/AppInfoRepository.cs
deleted file mode 100644
index cdea743..0000000
--- a/Source/Starfish.Service/Repository/Repositories/AppInfoRepository.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using Nerosoft.Euonia.Repository;
-using Nerosoft.Starfish.Domain;
-using Nerosoft.Starfish.Service;
-
-namespace Nerosoft.Starfish.Repository;
-
-///
-/// 应用信息仓储
-///
-public class AppInfoRepository : BaseRepository, IAppInfoRepository
-{
- ///
- /// 构造函数
- ///
- ///
- public AppInfoRepository(IContextProvider provider)
- : base(provider)
- {
- }
-
- public async Task CheckPermissionAsync(string appId, string userId, CancellationToken cancellationToken = default)
- {
- var query = from app in Context.Set()
- join team in Context.Set() on app.TeamId equals team.Id
- join member in Context.Set() on team.Id equals member.TeamId
- where app.Id == appId
- select new
- {
- member.UserId,
- IsOwner = member.UserId == team.OwnerId
- };
-
- var result = await query.ToListAsync(cancellationToken);
-
- var user = result.FirstOrDefault(x => x.UserId == userId);
- if (user == null)
- {
- return 0;
- }
-
- return user.IsOwner ? 1 : 2;
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Repository/Repositories/ConfigurationArchiveRepository.cs b/Source/Starfish.Service/Repository/Repositories/ConfigurationArchiveRepository.cs
deleted file mode 100644
index 96250df..0000000
--- a/Source/Starfish.Service/Repository/Repositories/ConfigurationArchiveRepository.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using Nerosoft.Euonia.Linq;
-using Nerosoft.Euonia.Repository;
-using Nerosoft.Starfish.Domain;
-using Nerosoft.Starfish.Service;
-
-namespace Nerosoft.Starfish.Repository;
-
-public class ConfigurationArchiveRepository : BaseRepository, IConfigurationArchiveRepository
-{
- public ConfigurationArchiveRepository(IContextProvider provider)
- : base(provider)
- {
- }
-
- public Task GetAsync(string appId, string environment, CancellationToken cancellationToken = default)
- {
- ISpecification[] specs =
- [
- ConfigurationArchiveSpecification.AppIdEquals(appId),
- ConfigurationArchiveSpecification.EnvironmentEquals(environment)
- ];
-
- var specification = new CompositeSpecification(PredicateOperator.AndAlso, specs);
-
- var predicate = specification.Satisfy();
-
- return GetAsync(predicate, true, cancellationToken);
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Repository/Repositories/ConfigurationRepository.cs b/Source/Starfish.Service/Repository/Repositories/ConfigurationRepository.cs
index abad83a..2e9aa70 100644
--- a/Source/Starfish.Service/Repository/Repositories/ConfigurationRepository.cs
+++ b/Source/Starfish.Service/Repository/Repositories/ConfigurationRepository.cs
@@ -1,4 +1,5 @@
-using Microsoft.EntityFrameworkCore;
+using System.Linq.Expressions;
+using Microsoft.EntityFrameworkCore;
using Nerosoft.Euonia.Linq;
using Nerosoft.Euonia.Repository;
using Nerosoft.Starfish.Domain;
@@ -6,70 +7,64 @@
namespace Nerosoft.Starfish.Repository;
-public class ConfigurationRepository : BaseRepository, IConfigurationRepository
+public class ConfigurationRepository : BaseRepository, IConfigurationRepository
{
public ConfigurationRepository(IContextProvider provider)
: base(provider)
{
}
- public Task ExistsAsync(string appId, string environment, CancellationToken cancellationToken = default)
+ public Task ExistsAsync(string teamId, string name, CancellationToken cancellationToken = default)
{
ISpecification[] specifications =
[
- ConfigurationSpecification.AppIdEquals(appId),
- ConfigurationSpecification.EnvironmentEquals(environment)
+ ConfigurationSpecification.TeamIdEquals(teamId),
+ ConfigurationSpecification.NameEquals(name)
];
var predicate = new CompositeSpecification(PredicateOperator.AndAlso, specifications).Satisfy();
return AnyAsync(predicate, null, cancellationToken);
}
- public Task GetAsync(string appId, string environment, bool tracking, string[] properties, CancellationToken cancellationToken = default)
+ public Task> GetItemListAsync(string id, string key, int skip, int count, CancellationToken cancellationToken = default)
{
- ISpecification[] specifications =
- [
- ConfigurationSpecification.AppIdEquals(appId),
- ConfigurationSpecification.EnvironmentEquals(environment)
- ];
-
- var predicate = new CompositeSpecification(PredicateOperator.AndAlso, specifications).Satisfy();
-
- return GetAsync(predicate, tracking, properties, cancellationToken);
- }
+ var query = Context.Set()
+ .AsQueryable()
+ .AsNoTracking();
+ var expressions = new List>>
+ {
+ t=>t.ConfigurationId == id
+ };
- public Task> GetItemListAsync(string appId, string environment, int skip, int count, CancellationToken cancellationToken = default)
- {
- ISpecification[] specifications =
- [
- ConfigurationSpecification.ConfigurationAppIdEquals(appId),
- ConfigurationSpecification.ConfigurationAppEnvironmentEquals(environment)
- ];
+ if (!string.IsNullOrWhiteSpace(key))
+ {
+ expressions.Add(t => t.Key.Contains(key));
+ }
- var predicate = new CompositeSpecification(PredicateOperator.AndAlso, specifications).Satisfy();
+ var predicate = expressions.Compose();
- var query = Context.Set()
- .AsQueryable()
- .Include(t => t.Configuration);
return query.Where(predicate)
.Skip(skip)
.Take(count)
.ToListAsync(cancellationToken);
}
- public Task GetItemCountAsync(string appId, string environment, CancellationToken cancellationToken = default)
+ public Task GetItemCountAsync(string id, string key, CancellationToken cancellationToken = default)
{
- ISpecification[] specifications =
- [
- ConfigurationSpecification.ConfigurationAppIdEquals(appId),
- ConfigurationSpecification.ConfigurationAppEnvironmentEquals(environment)
- ];
+ var query = Context.Set()
+ .AsQueryable();
+ var expressions = new List>>
+ {
+ t=>t.ConfigurationId == id
+ };
- var predicate = new CompositeSpecification(PredicateOperator.AndAlso, specifications).Satisfy();
+ if (!string.IsNullOrWhiteSpace(key))
+ {
+ expressions.Add(t => t.Key.Contains(key));
+ }
+
+ var predicate = expressions.Compose();
- var query = Context.Set()
- .AsQueryable()
- .Include(t => t.Configuration);
return query.Where(predicate).CountAsync(cancellationToken);
}
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Repository/Repositories/ConfigurationRevisionRepository.cs b/Source/Starfish.Service/Repository/Repositories/ConfigurationRevisionRepository.cs
deleted file mode 100644
index 074d822..0000000
--- a/Source/Starfish.Service/Repository/Repositories/ConfigurationRevisionRepository.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using Nerosoft.Euonia.Repository;
-using Nerosoft.Starfish.Domain;
-using Nerosoft.Starfish.Service;
-
-namespace Nerosoft.Starfish.Repository;
-
-public class ConfigurationRevisionRepository : BaseRepository, IConfigurationRevisionRepository
-{
- public ConfigurationRevisionRepository(IContextProvider provider)
- : base(provider)
- {
- }
-}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Repository/Repositories/TeamRepository.cs b/Source/Starfish.Service/Repository/Repositories/TeamRepository.cs
index 93f900c..e6b5904 100644
--- a/Source/Starfish.Service/Repository/Repositories/TeamRepository.cs
+++ b/Source/Starfish.Service/Repository/Repositories/TeamRepository.cs
@@ -30,4 +30,26 @@ public Task> GetMembersAsync(string id, CancellationToken cance
.Where(x => x.TeamId == id);
return query.ToListAsync(cancellationToken);
}
+
+ public async Task CheckPermissionAsync(string id, string userId, CancellationToken cancellationToken = default)
+ {
+ var query = from team in Context.Set()
+ join member in Context.Set() on team.Id equals member.TeamId
+ where team.Id == id
+ select new
+ {
+ member.UserId,
+ IsOwner = member.UserId == team.OwnerId
+ };
+
+ var result = await query.ToListAsync(cancellationToken);
+
+ var user = result.FirstOrDefault(x => x.UserId == userId);
+ if (user == null)
+ {
+ return PermissionState.None;
+ }
+
+ return user.IsOwner ? PermissionState.Edit : PermissionState.Read;
+ }
}
\ No newline at end of file
diff --git a/Source/Starfish.Service/Repository/RepositoryModule.cs b/Source/Starfish.Service/Repository/RepositoryModule.cs
index 424cc98..6d1688a 100644
--- a/Source/Starfish.Service/Repository/RepositoryModule.cs
+++ b/Source/Starfish.Service/Repository/RepositoryModule.cs
@@ -122,9 +122,6 @@ public override void ConfigureServices(ServiceConfigurationContext context)
.AddScoped()
.AddScoped()
.AddScoped