From eef5a2690373910a9f681ab4a7cb7ff08439cab3 Mon Sep 17 00:00:00 2001 From: damon Date: Sun, 28 Jan 2024 22:26:23 +0800 Subject: [PATCH 1/4] rename --- Documents/SCRIPTS_MSSQL.md | 62 ++++++------ Documents/SCRIPTS_MYSQL.md | 34 +++---- Documents/SCRIPTS_PGSQL.md | 48 +++++----- Documents/SCRIPTS_SQLITE.md | 54 +++++------ .../Application/ApplicationServiceModule.cs | 2 +- .../AppInfoCreateCommand.cs | 0 .../AppInfoDeleteCommand.cs | 0 .../AppInfoSetSecretCommand.cs | 0 .../AppInfoUpdateCommand.cs | 0 .../ChangeAppStatusCommand.cs | 0 .../ConfigurationAbstractCommand.cs} | 4 +- .../ConfigurationArchiveCreateCommand.cs} | 2 +- .../ConfigurationCreateCommand.cs} | 4 +- .../ConfigurationDeleteCommand.cs} | 4 +- .../ConfigurationPublishCommand.cs} | 4 +- .../ConfigurationRevisionCreateCommand.cs} | 2 +- .../ConfigurationUpdateCommand.cs} | 4 +- .../ConfigurationValueUpdateCommand.cs} | 4 +- .../Application/ConnectionContainer.cs | 10 +- ...cs => IConfigurationApplicationService.cs} | 14 +-- ...vent.cs => ConfigurationPublishedEvent.cs} | 6 +- .../Handlers/ConfigurationCommandHandler.cs | 96 +++++++++++++++++++ .../Handlers/SettingCommandHandler.cs | 96 ------------------- ....cs => ConfigurationApplicationService.cs} | 50 +++++----- .../Mappings/ConfigurationMappingProfile.cs | 31 ++++++ .../Mappings/SettingMappingProfile.cs | 31 ------ ...=> ConfigurationArchiveEventSubscriber.cs} | 8 +- ...ber.cs => ConfigurationEventSubscriber.cs} | 4 +- ...> ConfigurationRevisionEventSubscriber.cs} | 8 +- .../Subscribers/LoggingEventSubscriber.cs | 14 +-- .../{Setting.cs => Configuration.cs} | 44 ++++----- ...tingArchive.cs => ConfigurationArchive.cs} | 10 +- .../{SettingItem.cs => ConfigurationItem.cs} | 14 +-- ...ngRevision.cs => ConfigurationRevision.cs} | 10 +- ...ess.cs => ConfigurationArchiveBusiness.cs} | 12 +-- ...ess.cs => ConfigurationGeneralBusiness.cs} | 26 ++--- ...ess.cs => ConfigurationPublishBusiness.cs} | 16 ++-- .../Business/ConfigurationRevisionBusiness.cs | 30 ++++++ .../Business/SettingRevisionBusiness.cs | 30 ------ ...ngItemType.cs => ConfigurationItemType.cs} | 2 +- ...ettingStatus.cs => ConfigurationStatus.cs} | 8 +- ...cs => ConfigurationArchiveUpdatedEvent.cs} | 2 +- .../Events/ConfigurationCreatedEvent.cs | 17 ++++ ...dEvent.cs => ConfigurationDeletedEvent.cs} | 2 +- .../Events/ConfigurationStatusChangedEvent.cs | 23 +++++ .../Domain/Events/SettingCreatedEvent.cs | 17 ---- .../Events/SettingStatusChangedEvent.cs | 23 ----- .../ConfigurationDisabledException.cs | 9 ++ ...n.cs => ConfigurationNotFoundException.cs} | 6 +- .../Exceptions/SettingDisabledException.cs | 9 -- .../IConfigurationArchiveRepository.cs | 9 ++ ...ository.cs => IConfigurationRepository.cs} | 6 +- ...cs => IConfigurationRevisionRepository.cs} | 2 +- .../Repositories/ISettingArchiveRepository.cs | 9 -- .../Properties/Resources.resx | 32 +++---- .../Properties/Resources.zh-Hans.resx | 32 +++---- .../Properties/Resources.zh-Hant.resx | 32 +++---- .../Contexts/InMemoryModelBuilder.cs | 32 +++---- .../Repository/Contexts/MssqlModelBuilder.cs | 32 +++---- .../Repository/Contexts/MysqlModelBuilder.cs | 32 +++---- .../Repository/Contexts/PgsqlModelBuilder.cs | 32 +++---- .../Repository/Contexts/SqliteModelBuilder.cs | 32 +++---- .../Repository/CriteriaExtensions.cs | 6 +- .../ConfigurationArchiveRepository.cs | 29 ++++++ .../Repositories/ConfigurationRepository.cs | 75 +++++++++++++++ .../ConfigurationRevisionRepository.cs | 13 +++ .../Repositories/SettingArchiveRepository.cs | 29 ------ .../Repositories/SettingRepository.cs | 75 --------------- .../Repositories/SettingRevisionRepository.cs | 13 --- .../Repository/RepositoryModule.cs | 6 +- .../ConfigurationArchiveSpecification.cs | 18 ++++ .../ConfigurationSpecification.cs | 37 +++++++ .../SettingArchiveSpecification.cs | 18 ---- .../Specifications/SettingSpecification.cs | 37 ------- .../ConfigurationCreateUseCase.cs} | 20 ++-- .../ConfigurationDeleteUseCase.cs} | 12 +-- .../ConfigurationPublishUseCase.cs} | 14 +-- .../ConfigurationUpdateUseCase.cs} | 18 ++-- .../ConfigurationValueUpdateUseCase.cs | 29 ++++++ .../GetConfigurationDetailUseCase.cs | 62 ++++++++++++ .../GetConfigurationItemCountUseCase.cs} | 16 ++-- .../GetConfigurationItemListUseCase.cs} | 18 ++-- .../GetConfigurationRawUseCase.cs | 26 +++++ .../PushRedisUseCase.cs | 10 +- .../Setting/GetSettingDetailUseCase.cs | 62 ------------ .../UseCases/Setting/GetSettingRawUseCase.cs | 26 ----- .../Setting/SettingValueUpdateUseCase.cs | 29 ------ .../ConfigurationCriteria.cs} | 2 +- .../ConfigurationDetailDto.cs} | 2 +- .../ConfigurationEditDto.cs} | 2 +- .../ConfigurationItemDto.cs} | 2 +- .../ConfigurationPublishDto.cs} | 2 +- .../ConfigurationValueUpdateDto.cs} | 2 +- .../PushRedisRequestDto.cs | 0 Source/Starfish.Webapi/Constants.cs | 2 +- ...ntroller.cs => ConfigurationController.cs} | 26 ++--- Source/Starfish.Webapp/Pages/Apps/Index.razor | 6 +- .../Pages/{Setting => Config}/Edit.razor | 16 ++-- .../{Setting => Config}/EditDialogArgs.cs | 2 +- .../Pages/{Setting => Config}/EditValue.razor | 6 +- .../Pages/{Setting => Config}/Index.razor | 86 ++++++++--------- .../Pages/{Setting => Config}/Publish.razor | 12 +-- .../Pages/{Setting => Config}/Revision.razor | 6 +- .../Pages/{Setting => Config}/SyncRedis.razor | 16 ++-- .../Starfish.Webapp/Properties/Resources.resx | 76 +++++++-------- .../Properties/Resources.zh-Hans.resx | 66 ++++++------- .../Properties/Resources.zh-Hant.resx | 66 ++++++------- .../Rest/Defines/IConfigurationApi.cs | 41 ++++++++ .../Rest/Defines/ISettingApi.cs | 41 -------- .../Rest/ServiceCollectionExtensions.cs | 2 +- Source/Starfish.Webapp/Seedwork/Constants.cs | 2 +- 111 files changed, 1184 insertions(+), 1186 deletions(-) rename Source/Starfish.Service/Application/Commands/{Setting => Configuration}/AppInfoCreateCommand.cs (100%) rename Source/Starfish.Service/Application/Commands/{Setting => Configuration}/AppInfoDeleteCommand.cs (100%) rename Source/Starfish.Service/Application/Commands/{Setting => Configuration}/AppInfoSetSecretCommand.cs (100%) rename Source/Starfish.Service/Application/Commands/{Setting => Configuration}/AppInfoUpdateCommand.cs (100%) rename Source/Starfish.Service/Application/Commands/{Setting => Configuration}/ChangeAppStatusCommand.cs (100%) rename Source/Starfish.Service/Application/Commands/{Setting/SettingAbstractCommand.cs => Configuration/ConfigurationAbstractCommand.cs} (69%) rename Source/Starfish.Service/Application/Commands/{Setting/SettingArchiveCreateCommand.cs => Configuration/ConfigurationArchiveCreateCommand.cs} (84%) rename Source/Starfish.Service/Application/Commands/{Setting/SettingCreateCommand.cs => Configuration/ConfigurationCreateCommand.cs} (66%) rename Source/Starfish.Service/Application/Commands/{Setting/SettingDeleteCommand.cs => Configuration/ConfigurationDeleteCommand.cs} (66%) rename Source/Starfish.Service/Application/Commands/{Setting/SettingPublishCommand.cs => Configuration/ConfigurationPublishCommand.cs} (50%) rename Source/Starfish.Service/Application/Commands/{Setting/SettingRevisionCreateCommand.cs => Configuration/ConfigurationRevisionCreateCommand.cs} (89%) rename Source/Starfish.Service/Application/Commands/{Setting/SettingUpdateCommand.cs => Configuration/ConfigurationUpdateCommand.cs} (57%) rename Source/Starfish.Service/Application/Commands/{Setting/SettingValueUpdateCommand.cs => Configuration/ConfigurationValueUpdateCommand.cs} (56%) rename Source/Starfish.Service/Application/Contracts/{ISettingApplicationService.cs => IConfigurationApplicationService.cs} (82%) rename Source/Starfish.Service/Application/Events/{SettingPublishedEvent.cs => ConfigurationPublishedEvent.cs} (78%) create mode 100644 Source/Starfish.Service/Application/Handlers/ConfigurationCommandHandler.cs delete mode 100644 Source/Starfish.Service/Application/Handlers/SettingCommandHandler.cs rename Source/Starfish.Service/Application/Implements/{SettingApplicationService.cs => ConfigurationApplicationService.cs} (55%) create mode 100644 Source/Starfish.Service/Application/Mappings/ConfigurationMappingProfile.cs delete mode 100644 Source/Starfish.Service/Application/Mappings/SettingMappingProfile.cs rename Source/Starfish.Service/Application/Subscribers/{SettingArchiveEventSubscriber.cs => ConfigurationArchiveEventSubscriber.cs} (66%) rename Source/Starfish.Service/Application/Subscribers/{SettingEventSubscriber.cs => ConfigurationEventSubscriber.cs} (58%) rename Source/Starfish.Service/Application/Subscribers/{SettingRevisionEventSubscriber.cs => ConfigurationRevisionEventSubscriber.cs} (68%) rename Source/Starfish.Service/Domain/Aggregates/{Setting.cs => Configuration.cs} (66%) rename Source/Starfish.Service/Domain/Aggregates/{SettingArchive.cs => ConfigurationArchive.cs} (74%) rename Source/Starfish.Service/Domain/Aggregates/{SettingItem.cs => ConfigurationItem.cs} (52%) rename Source/Starfish.Service/Domain/Aggregates/{SettingRevision.cs => ConfigurationRevision.cs} (73%) rename Source/Starfish.Service/Domain/Business/{SettingArchiveBusiness.cs => ConfigurationArchiveBusiness.cs} (62%) rename Source/Starfish.Service/Domain/Business/{SettingGeneralBusiness.cs => ConfigurationGeneralBusiness.cs} (76%) rename Source/Starfish.Service/Domain/Business/{SettingPublishBusiness.cs => ConfigurationPublishBusiness.cs} (59%) create mode 100644 Source/Starfish.Service/Domain/Business/ConfigurationRevisionBusiness.cs delete mode 100644 Source/Starfish.Service/Domain/Business/SettingRevisionBusiness.cs rename Source/Starfish.Service/Domain/Enums/{SettingItemType.cs => ConfigurationItemType.cs} (93%) rename Source/Starfish.Service/Domain/Enums/{SettingStatus.cs => ConfigurationStatus.cs} (61%) rename Source/Starfish.Service/Domain/Events/{SettingArchiveUpdatedEvent.cs => ConfigurationArchiveUpdatedEvent.cs} (69%) create mode 100644 Source/Starfish.Service/Domain/Events/ConfigurationCreatedEvent.cs rename Source/Starfish.Service/Domain/Events/{SettingDeletedEvent.cs => ConfigurationDeletedEvent.cs} (72%) create mode 100644 Source/Starfish.Service/Domain/Events/ConfigurationStatusChangedEvent.cs delete mode 100644 Source/Starfish.Service/Domain/Events/SettingCreatedEvent.cs delete mode 100644 Source/Starfish.Service/Domain/Events/SettingStatusChangedEvent.cs create mode 100644 Source/Starfish.Service/Domain/Exceptions/ConfigurationDisabledException.cs rename Source/Starfish.Service/Domain/Exceptions/{SettingNotFoundException.cs => ConfigurationNotFoundException.cs} (53%) delete mode 100644 Source/Starfish.Service/Domain/Exceptions/SettingDisabledException.cs create mode 100644 Source/Starfish.Service/Domain/Repositories/IConfigurationArchiveRepository.cs rename Source/Starfish.Service/Domain/Repositories/{ISettingRepository.cs => IConfigurationRepository.cs} (57%) rename Source/Starfish.Service/Domain/Repositories/{ISettingRevisionRepository.cs => IConfigurationRevisionRepository.cs} (50%) delete mode 100644 Source/Starfish.Service/Domain/Repositories/ISettingArchiveRepository.cs create mode 100644 Source/Starfish.Service/Repository/Repositories/ConfigurationArchiveRepository.cs create mode 100644 Source/Starfish.Service/Repository/Repositories/ConfigurationRepository.cs create mode 100644 Source/Starfish.Service/Repository/Repositories/ConfigurationRevisionRepository.cs delete mode 100644 Source/Starfish.Service/Repository/Repositories/SettingArchiveRepository.cs delete mode 100644 Source/Starfish.Service/Repository/Repositories/SettingRepository.cs delete mode 100644 Source/Starfish.Service/Repository/Repositories/SettingRevisionRepository.cs create mode 100644 Source/Starfish.Service/Repository/Specifications/ConfigurationArchiveSpecification.cs create mode 100644 Source/Starfish.Service/Repository/Specifications/ConfigurationSpecification.cs delete mode 100644 Source/Starfish.Service/Repository/Specifications/SettingArchiveSpecification.cs delete mode 100644 Source/Starfish.Service/Repository/Specifications/SettingSpecification.cs rename Source/Starfish.Service/UseCases/{Setting/SettingCreateUseCase.cs => Configuration/ConfigurationCreateUseCase.cs} (52%) rename Source/Starfish.Service/UseCases/{Setting/SettingDeleteUseCase.cs => Configuration/ConfigurationDeleteUseCase.cs} (51%) rename Source/Starfish.Service/UseCases/{Setting/SettingPublishUseCase.cs => Configuration/ConfigurationPublishUseCase.cs} (53%) rename Source/Starfish.Service/UseCases/{Setting/SettingUpdateUseCase.cs => Configuration/ConfigurationUpdateUseCase.cs} (56%) create mode 100644 Source/Starfish.Service/UseCases/Configuration/ConfigurationValueUpdateUseCase.cs create mode 100644 Source/Starfish.Service/UseCases/Configuration/GetConfigurationDetailUseCase.cs rename Source/Starfish.Service/UseCases/{Setting/GetSettingItemCountUseCase.cs => Configuration/GetConfigurationItemCountUseCase.cs} (50%) rename Source/Starfish.Service/UseCases/{Setting/GetSettingItemListUseCase.cs => Configuration/GetConfigurationItemListUseCase.cs} (66%) create mode 100644 Source/Starfish.Service/UseCases/Configuration/GetConfigurationRawUseCase.cs rename Source/Starfish.Service/UseCases/{Setting => Configuration}/PushRedisUseCase.cs (78%) delete mode 100644 Source/Starfish.Service/UseCases/Setting/GetSettingDetailUseCase.cs delete mode 100644 Source/Starfish.Service/UseCases/Setting/GetSettingRawUseCase.cs delete mode 100644 Source/Starfish.Service/UseCases/Setting/SettingValueUpdateUseCase.cs rename Source/Starfish.Transit/{Setting/SettingCriteria.cs => Configuration/ConfigurationCriteria.cs} (91%) rename Source/Starfish.Transit/{Setting/SettingDetailDto.cs => Configuration/ConfigurationDetailDto.cs} (96%) rename Source/Starfish.Transit/{Setting/SettingEditDto.cs => Configuration/ConfigurationEditDto.cs} (88%) rename Source/Starfish.Transit/{Setting/SettingItemDto.cs => Configuration/ConfigurationItemDto.cs} (90%) rename Source/Starfish.Transit/{Setting/SettingPublishDto.cs => Configuration/ConfigurationPublishDto.cs} (87%) rename Source/Starfish.Transit/{Setting/SettingValueUpdateDto.cs => Configuration/ConfigurationValueUpdateDto.cs} (80%) rename Source/Starfish.Transit/{Setting => Configuration}/PushRedisRequestDto.cs (100%) rename Source/Starfish.Webapi/Controllers/{SettingController.cs => ConfigurationController.cs} (88%) rename Source/Starfish.Webapp/Pages/{Setting => Config}/Edit.razor (83%) rename Source/Starfish.Webapp/Pages/{Setting => Config}/EditDialogArgs.cs (83%) rename Source/Starfish.Webapp/Pages/{Setting => Config}/EditValue.razor (90%) rename Source/Starfish.Webapp/Pages/{Setting => Config}/Index.razor (71%) rename Source/Starfish.Webapp/Pages/{Setting => Config}/Publish.razor (77%) rename Source/Starfish.Webapp/Pages/{Setting => Config}/Revision.razor (59%) rename Source/Starfish.Webapp/Pages/{Setting => Config}/SyncRedis.razor (75%) create mode 100644 Source/Starfish.Webapp/Rest/Defines/IConfigurationApi.cs delete mode 100644 Source/Starfish.Webapp/Rest/Defines/ISettingApi.cs diff --git a/Documents/SCRIPTS_MSSQL.md b/Documents/SCRIPTS_MSSQL.md index 4670ed0..fab195a 100644 --- a/Documents/SCRIPTS_MSSQL.md +++ b/Documents/SCRIPTS_MSSQL.md @@ -82,10 +82,10 @@ ON [operate_log] ( GO ``` -# setting +# configuration ```sql -CREATE TABLE [setting] ( +CREATE TABLE [configuration] ( [Id] bigint NOT NULL, [AppId] bigint NOT NULL, [Environment] varchar(50) NOT NULL, @@ -100,33 +100,33 @@ CREATE TABLE [setting] ( ) GO -ALTER TABLE [setting] SET (LOCK_ESCALATION = TABLE) +ALTER TABLE [configuration] SET (LOCK_ESCALATION = TABLE) GO -CREATE UNIQUE NONCLUSTERED INDEX [IDX_SETTING_UNIQUE] -ON [setting] ( +CREATE UNIQUE NONCLUSTERED INDEX [IDX_CONFIG_UNIQUE] +ON [configuration] ( [AppId] ASC, [Environment] ASC ) GO -CREATE NONCLUSTERED INDEX [IDX_SETTING_APP_ID] -ON [setting] ( +CREATE NONCLUSTERED INDEX [IDX_CONFIG_APP_ID] +ON [configuration] ( [AppId] ASC ) GO -CREATE NONCLUSTERED INDEX [IDX_SETTING_STATUS] -ON [setting] ( +CREATE NONCLUSTERED INDEX [IDX_CONFIG_STATUS] +ON [configuration] ( [Status] ASC ) GO ``` -# setting_archive +# configuration_archive ```sql -CREATE TABLE [setting_archive] ( +CREATE TABLE [configuration_archive] ( [Id] bigint NOT NULL, [AppId] bigint NOT NULL, [Environment] varchar(50) NOT NULL, @@ -137,23 +137,23 @@ CREATE TABLE [setting_archive] ( ) GO -ALTER TABLE [setting_archive] SET (LOCK_ESCALATION = TABLE) +ALTER TABLE [configuration_archive] SET (LOCK_ESCALATION = TABLE) GO -CREATE UNIQUE NONCLUSTERED INDEX [IDX_SETTING_ARCHIVE_UNIQUE] -ON [setting_archive] ( +CREATE UNIQUE NONCLUSTERED INDEX [IDX_CONFIG_ARCHIVE_UNIQUE] +ON [configuration_archive] ( [AppId] ASC, [Environment] ASC ) GO ``` -# setting_item +# configuration_item ```sql -CREATE TABLE [setting_item] ( +CREATE TABLE [configuration_item] ( [Id] bigint NOT NULL, - [SettingId] bigint NOT NULL, + [ConfigurationId] bigint NOT NULL, [Key] varchar(255) NOT NULL, [Value] text NULL, [UpdateTime] datetime DEFAULT getdate() NOT NULL, @@ -162,29 +162,29 @@ CREATE TABLE [setting_item] ( ) GO -ALTER TABLE [setting_item] SET (LOCK_ESCALATION = TABLE) +ALTER TABLE [configuration_item] SET (LOCK_ESCALATION = TABLE) GO -CREATE UNIQUE NONCLUSTERED INDEX [IDX_SETTING_ITEM_UNIQUE] -ON [setting_item] ( - [SettingId] ASC, +CREATE UNIQUE NONCLUSTERED INDEX [IDX_CONFIG_ITEM_UNIQUE] +ON [configuration_item] ( + [ConfigurationId] ASC, [Key] ASC ) GO -CREATE NONCLUSTERED INDEX [IDX_SETTING_ITEM_FK] -ON [setting_item] ( - [SettingId] ASC +CREATE NONCLUSTERED INDEX [IDX_CONFIG_ITEM_FK] +ON [configuration_item] ( + [ConfigurationId] ASC ) GO ``` -# setting_revision +# configuration_revision ```sql -CREATE TABLE [setting_revision] ( +CREATE TABLE [configuration_revision] ( [Id] bigint NOT NULL, - [SettingId] bigint NOT NULL, + [ConfigurationId] bigint NOT NULL, [Data] text NULL, [Comment] varchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT NULL NULL, [Version] varchar(25) NOT NULL, @@ -194,12 +194,12 @@ CREATE TABLE [setting_revision] ( ) GO -ALTER TABLE [setting_revision] SET (LOCK_ESCALATION = TABLE) +ALTER TABLE [configuration_revision] SET (LOCK_ESCALATION = TABLE) GO -CREATE NONCLUSTERED INDEX [IDS_SETTING_REVISION_FK] -ON [setting_revision] ( - [SettingId] ASC +CREATE NONCLUSTERED INDEX [IDS_CONFIG_REVISION_FK] +ON [configuration_revision] ( + [ConfigurationId] ASC ) GO ``` diff --git a/Documents/SCRIPTS_MYSQL.md b/Documents/SCRIPTS_MYSQL.md index f8030fe..b20734d 100644 --- a/Documents/SCRIPTS_MYSQL.md +++ b/Documents/SCRIPTS_MYSQL.md @@ -38,10 +38,10 @@ CREATE TABLE `operate_log` ( ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; ``` -# setting +# configuration ```sql -CREATE TABLE `setting` ( +CREATE TABLE `configuration` ( `Id` bigint NOT NULL, `AppId` bigint NOT NULL, `Environment` varchar(50) NOT NULL, @@ -53,16 +53,16 @@ CREATE TABLE `setting` ( `CreatedBy` varchar(64) NOT NULL, `UpdatedBy` varchar(64) NOT NULL, PRIMARY KEY (`Id`) USING BTREE, - UNIQUE INDEX `IDX_SETTING_UNIQUE`(`AppId` ASC, `Environment` ASC) USING BTREE, - INDEX `IDX_SETTING_APP_ID`(`AppId` ASC) USING BTREE, - INDEX `IDX_SETTING_STATUS`(`Status` ASC) USING BTREE + UNIQUE INDEX `IDX_CONFIG_UNIQUE`(`AppId` ASC, `Environment` ASC) USING BTREE, + INDEX `IDX_CONFIG_APP_ID`(`AppId` ASC) USING BTREE, + INDEX `IDX_CONFIG_STATUS`(`Status` ASC) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; ``` -# setting_archive +# configuration_archive ```sql -CREATE TABLE `setting_archive` ( +CREATE TABLE `configuration_archive` ( `Id` bigint NOT NULL, `AppId` bigint NOT NULL, `Environment` varchar(50) NOT NULL, @@ -70,39 +70,39 @@ CREATE TABLE `setting_archive` ( `Operator` varchar(64) NOT NULL, `ArchiveTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`Id`) USING BTREE, - INDEX `IDX_SETTING_ARCHIVE_UNIQUE`(`AppId` ASC, `Environment` ASC) USING BTREE + INDEX `IDX_CONFIG_ARCHIVE_UNIQUE`(`AppId` ASC, `Environment` ASC) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; ``` -# setting_item +# configuration_item ```sql -CREATE TABLE `setting_item` ( +CREATE TABLE `configuration_item` ( `Id` bigint NOT NULL, - `SettingId` bigint NOT NULL, + `ConfigurationId` bigint NOT NULL, `Key` varchar(255) NOT NULL, `Value` text NULL, `UpdateTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `UpdatedBy` varchar(64) NOT NULL, PRIMARY KEY (`Id`) USING BTREE, - UNIQUE INDEX `IDX_SETTING_ITEM_UNIQUE`(`SettingId` ASC, `Key` ASC) USING BTREE, - INDEX `IDX_SETTING_ITEM_FK`(`SettingId` ASC) USING BTREE + UNIQUE INDEX `IDX_CONFIG_ITEM_UNIQUE`(`ConfigurationId` ASC, `Key` ASC) USING BTREE, + INDEX `IDX_CONFIG_ITEM_FK`(`ConfigurationId` ASC) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; ``` -# setting_revision +# configuration_revision ```sql -CREATE TABLE `setting_revision` ( +CREATE TABLE `configuration_revision` ( `Id` bigint NOT NULL, - `SettingId` bigint NOT NULL, + `ConfigurationId` bigint NOT NULL, `Data` text NULL, `Comment` varchar(1000) NULL DEFAULT NULL, `Version` varchar(25) NOT NULL, `Operator` varchar(64) NOT NULL, `CreateTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`Id`) USING BTREE, - INDEX `IDS_SETTING_REVISION_FK`(`SettingId` ASC) USING BTREE + INDEX `IDS_CONFIG_REVISION_FK`(`ConfigurationId` ASC) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic; ``` diff --git a/Documents/SCRIPTS_PGSQL.md b/Documents/SCRIPTS_PGSQL.md index 66d0ce2..c8673c6 100644 --- a/Documents/SCRIPTS_PGSQL.md +++ b/Documents/SCRIPTS_PGSQL.md @@ -59,10 +59,10 @@ CREATE INDEX "IDX_OPERATE_LOG_USER_NAME" ON "public"."operate_log" USING btree ( ALTER TABLE "public"."operate_log" ADD CONSTRAINT "operate_log_pkey" PRIMARY KEY ("Id"); ``` -# setting +# configuration ```sql -CREATE TABLE "public"."setting" ( +CREATE TABLE "public"."configuration" ( "Id" int8 NOT NULL, "AppId" int8 NOT NULL, "Environment" varchar(25) COLLATE "pg_catalog"."default" NOT NULL, @@ -76,24 +76,24 @@ CREATE TABLE "public"."setting" ( ) ; -CREATE INDEX "IDX_SETTING_APP_ID" ON "public"."setting" USING btree ( +CREATE INDEX "IDX_CONFIG_APP_ID" ON "public"."configuration" USING btree ( "AppId" "pg_catalog"."int8_ops" ASC NULLS LAST ); -CREATE INDEX "IDX_SETTING_STATUS" ON "public"."setting" USING btree ( +CREATE INDEX "IDX_CONFIG_STATUS" ON "public"."configuration" USING btree ( "Status" "pg_catalog"."int4_ops" ASC NULLS LAST ); -CREATE UNIQUE INDEX "IDX_SETTING_UNIQUE" ON "public"."setting" USING btree ( +CREATE UNIQUE INDEX "IDX_CONFIG_UNIQUE" ON "public"."configuration" USING btree ( "AppId" "pg_catalog"."int8_ops" ASC NULLS LAST, "Environment" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST ); -ALTER TABLE "public"."setting" ADD CONSTRAINT "setting_pkey" PRIMARY KEY ("Id"); +ALTER TABLE "public"."configuration" ADD CONSTRAINT "configuration_pkey" PRIMARY KEY ("Id"); ``` -# setting_archive +# configuration_archive ```sql -CREATE TABLE "public"."setting_archive" ( +CREATE TABLE "public"."configuration_archive" ( "Id" int8 NOT NULL, "AppId" int8 NOT NULL, "Environment" varchar(50) COLLATE "pg_catalog"."default" NOT NULL, @@ -103,20 +103,20 @@ CREATE TABLE "public"."setting_archive" ( ) ; -CREATE UNIQUE INDEX "IDX_SETTING_ARCHIVE_UNIQUE" ON "public"."setting_archive" USING btree ( +CREATE UNIQUE INDEX "IDX_CONFIG_ARCHIVE_UNIQUE" ON "public"."configuration_archive" USING btree ( "AppId" "pg_catalog"."int8_ops" ASC NULLS LAST, "Environment" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST ); -ALTER TABLE "public"."setting_archive" ADD CONSTRAINT "setting_archive_pkey" PRIMARY KEY ("Id"); +ALTER TABLE "public"."configuration_archive" ADD CONSTRAINT "configuration_archive_pkey" PRIMARY KEY ("Id"); ``` -# setting_item +# configuration_item ```sql -CREATE TABLE "public"."setting_item" ( +CREATE TABLE "public"."configuration_item" ( "Id" int8 NOT NULL, - "SettingId" int8 NOT NULL, + "ConfigurationId" int8 NOT NULL, "Key" varchar(255) COLLATE "pg_catalog"."default" NOT NULL, "Value" text COLLATE "pg_catalog"."default", "UpdatedTime" timestamp(6) NOT NULL, @@ -124,23 +124,23 @@ CREATE TABLE "public"."setting_item" ( ) ; -CREATE INDEX "IDX_SETTING_ITEM_FK" ON "public"."setting_item" USING btree ( - "SettingId" "pg_catalog"."int8_ops" ASC NULLS LAST +CREATE INDEX "IDX_CONFIG_ITEM_FK" ON "public"."configuration_item" USING btree ( + "ConfigurationId" "pg_catalog"."int8_ops" ASC NULLS LAST ); -CREATE UNIQUE INDEX "IDX_SETTING_ITEM_UNIQUE" ON "public"."setting_item" USING btree ( - "SettingId" "pg_catalog"."int8_ops" ASC NULLS LAST, +CREATE UNIQUE INDEX "IDX_CONFIG_ITEM_UNIQUE" ON "public"."configuration_item" USING btree ( + "ConfigurationId" "pg_catalog"."int8_ops" ASC NULLS LAST, "Key" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST ); -ALTER TABLE "public"."setting_item" ADD CONSTRAINT "setting_item_pkey" PRIMARY KEY ("Id"); +ALTER TABLE "public"."configuration_item" ADD CONSTRAINT "configuration_item_pkey" PRIMARY KEY ("Id"); ``` -# setting_revision +# configuration_revision ```sql -CREATE TABLE "public"."setting_revision" ( +CREATE TABLE "public"."configuration_revision" ( "Id" int8 NOT NULL, - "SettingId" int8 NOT NULL, + "ConfigurationId" int8 NOT NULL, "Data" text COLLATE "pg_catalog"."default", "Comment" varchar(1000) COLLATE "pg_catalog"."default", "Version" varchar(25) COLLATE "pg_catalog"."default" NOT NULL, @@ -149,11 +149,11 @@ CREATE TABLE "public"."setting_revision" ( ) ; -CREATE INDEX "IDS_SETTING_REVISION_FK" ON "public"."setting_revision" USING btree ( - "SettingId" "pg_catalog"."int8_ops" ASC NULLS LAST +CREATE INDEX "IDS_CONFIG_REVISION_FK" ON "public"."configuration_revision" USING btree ( + "ConfigurationId" "pg_catalog"."int8_ops" ASC NULLS LAST ); -ALTER TABLE "public"."setting_revision" ADD CONSTRAINT "setting_revision_pkey" PRIMARY KEY ("Id"); +ALTER TABLE "public"."configuration_revision" ADD CONSTRAINT "configuration_revision_pkey" PRIMARY KEY ("Id"); ``` # team diff --git a/Documents/SCRIPTS_SQLITE.md b/Documents/SCRIPTS_SQLITE.md index 5534b44..eef19e2 100644 --- a/Documents/SCRIPTS_SQLITE.md +++ b/Documents/SCRIPTS_SQLITE.md @@ -62,10 +62,10 @@ ON "operate_log" ( ); ``` -# setting +# configuration ```sqlite -CREATE TABLE "setting" ( +CREATE TABLE "configuration" ( "Id" integer NOT NULL, "AppId" integer NOT NULL, "Environment" text NOT NULL, @@ -79,25 +79,25 @@ CREATE TABLE "setting" ( PRIMARY KEY ("Id") ); -CREATE INDEX "IDX_SETTING_APP_ID" -ON "setting" ( +CREATE INDEX "IDX_CONFIG_APP_ID" +ON "configuration" ( "AppId" ASC ); -CREATE INDEX "IDX_SETTING_STATUS" -ON "setting" ( +CREATE INDEX "IDX_CONFIG_STATUS" +ON "configuration" ( "Status" ASC ); -CREATE UNIQUE INDEX "IDX_SETTING_UNIQUE" -ON "setting" ( +CREATE UNIQUE INDEX "IDX_CONFIG_UNIQUE" +ON "configuration" ( "AppId" ASC, "Environment" ASC ); ``` -# setting_archive +# configuration_archive ```sqlite -CREATE TABLE "setting_archive" ( +CREATE TABLE "configuration_archive" ( "Id" integer NOT NULL, "AppId" integer NOT NULL, "Environment" text NOT NULL, @@ -107,19 +107,19 @@ CREATE TABLE "setting_archive" ( PRIMARY KEY ("Id") ); -CREATE UNIQUE INDEX "IDX_SETTING_ARCHIVE_UNIQUE" -ON "setting_archive" ( +CREATE UNIQUE INDEX "IDX_CONFIG_ARCHIVE_UNIQUE" +ON "configuration_archive" ( "AppId" ASC, "Environment" ASC ); ``` -# setting_item +# configuration_item ```sqlite -CREATE TABLE "setting_item" ( +CREATE TABLE "configuration_item" ( "Id" integer NOT NULL, - "SettingId" integer NOT NULL, + "ConfigurationId" integer NOT NULL, "Key" text NOT NULL, "Value" text, "UpdateTime" text NOT NULL, @@ -127,23 +127,23 @@ CREATE TABLE "setting_item" ( PRIMARY KEY ("Id") ); -CREATE INDEX "IDX_SETTING_ITEM_FK" -ON "setting_item" ( - "SettingId" ASC +CREATE INDEX "IDX_CONFIG_ITEM_FK" +ON "configuration_item" ( + "ConfigurationId" ASC ); -CREATE UNIQUE INDEX "IDX_SETTING_ITEM_UNIQUE" -ON "setting_item" ( - "SettingId" ASC, +CREATE UNIQUE INDEX "IDX_CONFIG_ITEM_UNIQUE" +ON "configuration_item" ( + "ConfigurationId" ASC, "Key" ASC ); ``` -# setting_revision +# configuration_revision ```sqlite -CREATE TABLE "setting_revision" ( +CREATE TABLE "configuration_revision" ( "Id" integer NOT NULL, - "SettingId" integer NOT NULL, + "ConfigurationId" integer NOT NULL, "Data" text, "Comment" text, "Version" text NOT NULL, @@ -152,9 +152,9 @@ CREATE TABLE "setting_revision" ( PRIMARY KEY ("Id") ); -CREATE INDEX "IDS_SETTING_REVISION_FK" -ON "setting_revision" ( - "SettingId" ASC +CREATE INDEX "IDS_CONFIG_REVISION_FK" +ON "configuration_revision" ( + "ConfigurationId" ASC ); ``` diff --git a/Source/Starfish.Service/Application/ApplicationServiceModule.cs b/Source/Starfish.Service/Application/ApplicationServiceModule.cs index cd10f2a..93d1035 100644 --- a/Source/Starfish.Service/Application/ApplicationServiceModule.cs +++ b/Source/Starfish.Service/Application/ApplicationServiceModule.cs @@ -33,7 +33,7 @@ public override void AheadConfigureServices(ServiceConfigurationContext context) options.AddProfile(); options.AddProfile(); options.AddProfile(); - options.AddProfile(); + options.AddProfile(); options.AddProfile(); }); } diff --git a/Source/Starfish.Service/Application/Commands/Setting/AppInfoCreateCommand.cs b/Source/Starfish.Service/Application/Commands/Configuration/AppInfoCreateCommand.cs similarity index 100% rename from Source/Starfish.Service/Application/Commands/Setting/AppInfoCreateCommand.cs rename to Source/Starfish.Service/Application/Commands/Configuration/AppInfoCreateCommand.cs diff --git a/Source/Starfish.Service/Application/Commands/Setting/AppInfoDeleteCommand.cs b/Source/Starfish.Service/Application/Commands/Configuration/AppInfoDeleteCommand.cs similarity index 100% rename from Source/Starfish.Service/Application/Commands/Setting/AppInfoDeleteCommand.cs rename to Source/Starfish.Service/Application/Commands/Configuration/AppInfoDeleteCommand.cs diff --git a/Source/Starfish.Service/Application/Commands/Setting/AppInfoSetSecretCommand.cs b/Source/Starfish.Service/Application/Commands/Configuration/AppInfoSetSecretCommand.cs similarity index 100% rename from Source/Starfish.Service/Application/Commands/Setting/AppInfoSetSecretCommand.cs rename to Source/Starfish.Service/Application/Commands/Configuration/AppInfoSetSecretCommand.cs diff --git a/Source/Starfish.Service/Application/Commands/Setting/AppInfoUpdateCommand.cs b/Source/Starfish.Service/Application/Commands/Configuration/AppInfoUpdateCommand.cs similarity index 100% rename from Source/Starfish.Service/Application/Commands/Setting/AppInfoUpdateCommand.cs rename to Source/Starfish.Service/Application/Commands/Configuration/AppInfoUpdateCommand.cs diff --git a/Source/Starfish.Service/Application/Commands/Setting/ChangeAppStatusCommand.cs b/Source/Starfish.Service/Application/Commands/Configuration/ChangeAppStatusCommand.cs similarity index 100% rename from Source/Starfish.Service/Application/Commands/Setting/ChangeAppStatusCommand.cs rename to Source/Starfish.Service/Application/Commands/Configuration/ChangeAppStatusCommand.cs diff --git a/Source/Starfish.Service/Application/Commands/Setting/SettingAbstractCommand.cs b/Source/Starfish.Service/Application/Commands/Configuration/ConfigurationAbstractCommand.cs similarity index 69% rename from Source/Starfish.Service/Application/Commands/Setting/SettingAbstractCommand.cs rename to Source/Starfish.Service/Application/Commands/Configuration/ConfigurationAbstractCommand.cs index 5165ec1..b9bc7fd 100644 --- a/Source/Starfish.Service/Application/Commands/Setting/SettingAbstractCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Configuration/ConfigurationAbstractCommand.cs @@ -2,9 +2,9 @@ namespace Nerosoft.Starfish.Application; -public abstract class SettingAbstractCommand : Command +public abstract class ConfigurationAbstractCommand : Command { - protected SettingAbstractCommand(long appId, string environment) + protected ConfigurationAbstractCommand(long appId, string environment) { AppId = appId; Environment = environment; diff --git a/Source/Starfish.Service/Application/Commands/Setting/SettingArchiveCreateCommand.cs b/Source/Starfish.Service/Application/Commands/Configuration/ConfigurationArchiveCreateCommand.cs similarity index 84% rename from Source/Starfish.Service/Application/Commands/Setting/SettingArchiveCreateCommand.cs rename to Source/Starfish.Service/Application/Commands/Configuration/ConfigurationArchiveCreateCommand.cs index 1c92d77..54420ef 100644 --- a/Source/Starfish.Service/Application/Commands/Setting/SettingArchiveCreateCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Configuration/ConfigurationArchiveCreateCommand.cs @@ -5,7 +5,7 @@ namespace Nerosoft.Starfish.Application; /// /// 创建配置归档命令 /// -public class SettingArchiveCreateCommand : Command +public class ConfigurationArchiveCreateCommand : Command { /// /// 应用Id diff --git a/Source/Starfish.Service/Application/Commands/Setting/SettingCreateCommand.cs b/Source/Starfish.Service/Application/Commands/Configuration/ConfigurationCreateCommand.cs similarity index 66% rename from Source/Starfish.Service/Application/Commands/Setting/SettingCreateCommand.cs rename to Source/Starfish.Service/Application/Commands/Configuration/ConfigurationCreateCommand.cs index e40ee1a..251ee54 100644 --- a/Source/Starfish.Service/Application/Commands/Setting/SettingCreateCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Configuration/ConfigurationCreateCommand.cs @@ -1,8 +1,8 @@ namespace Nerosoft.Starfish.Application; -public class SettingCreateCommand : SettingAbstractCommand +public class ConfigurationCreateCommand : ConfigurationAbstractCommand { - public SettingCreateCommand(long appId, string environment) + public ConfigurationCreateCommand(long appId, string environment) : base(appId, environment) { } diff --git a/Source/Starfish.Service/Application/Commands/Setting/SettingDeleteCommand.cs b/Source/Starfish.Service/Application/Commands/Configuration/ConfigurationDeleteCommand.cs similarity index 66% rename from Source/Starfish.Service/Application/Commands/Setting/SettingDeleteCommand.cs rename to Source/Starfish.Service/Application/Commands/Configuration/ConfigurationDeleteCommand.cs index 3792542..bd2efed 100644 --- a/Source/Starfish.Service/Application/Commands/Setting/SettingDeleteCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Configuration/ConfigurationDeleteCommand.cs @@ -3,14 +3,14 @@ /// /// 删除配置节点命令 /// -public class SettingDeleteCommand : SettingAbstractCommand +public class ConfigurationDeleteCommand : ConfigurationAbstractCommand { /// /// 构造函数 /// /// 应用Id /// - public SettingDeleteCommand(long id, string environment) + public ConfigurationDeleteCommand(long id, string environment) : base(id, environment) { } diff --git a/Source/Starfish.Service/Application/Commands/Setting/SettingPublishCommand.cs b/Source/Starfish.Service/Application/Commands/Configuration/ConfigurationPublishCommand.cs similarity index 50% rename from Source/Starfish.Service/Application/Commands/Setting/SettingPublishCommand.cs rename to Source/Starfish.Service/Application/Commands/Configuration/ConfigurationPublishCommand.cs index ac9fbdb..f2a8906 100644 --- a/Source/Starfish.Service/Application/Commands/Setting/SettingPublishCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Configuration/ConfigurationPublishCommand.cs @@ -3,9 +3,9 @@ /// /// 配置节点发布命令 /// -public class SettingPublishCommand : SettingAbstractCommand +public class ConfigurationPublishCommand : ConfigurationAbstractCommand { - public SettingPublishCommand(long appId, string environment) + public ConfigurationPublishCommand(long appId, string environment) : base(appId, environment) { } diff --git a/Source/Starfish.Service/Application/Commands/Setting/SettingRevisionCreateCommand.cs b/Source/Starfish.Service/Application/Commands/Configuration/ConfigurationRevisionCreateCommand.cs similarity index 89% rename from Source/Starfish.Service/Application/Commands/Setting/SettingRevisionCreateCommand.cs rename to Source/Starfish.Service/Application/Commands/Configuration/ConfigurationRevisionCreateCommand.cs index edb25fe..50fa466 100644 --- a/Source/Starfish.Service/Application/Commands/Setting/SettingRevisionCreateCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Configuration/ConfigurationRevisionCreateCommand.cs @@ -5,7 +5,7 @@ namespace Nerosoft.Starfish.Application; /// /// 创建配置版本命令 /// -public class SettingRevisionCreateCommand : Command +public class ConfigurationRevisionCreateCommand : Command { /// /// 应用Id diff --git a/Source/Starfish.Service/Application/Commands/Setting/SettingUpdateCommand.cs b/Source/Starfish.Service/Application/Commands/Configuration/ConfigurationUpdateCommand.cs similarity index 57% rename from Source/Starfish.Service/Application/Commands/Setting/SettingUpdateCommand.cs rename to Source/Starfish.Service/Application/Commands/Configuration/ConfigurationUpdateCommand.cs index 4de2c33..e871b6b 100644 --- a/Source/Starfish.Service/Application/Commands/Setting/SettingUpdateCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Configuration/ConfigurationUpdateCommand.cs @@ -1,8 +1,8 @@ namespace Nerosoft.Starfish.Application; -public class SettingUpdateCommand : SettingAbstractCommand +public class ConfigurationUpdateCommand : ConfigurationAbstractCommand { - public SettingUpdateCommand(long appId, string environment) + public ConfigurationUpdateCommand(long appId, string environment) : base(appId, environment) { AppId = appId; diff --git a/Source/Starfish.Service/Application/Commands/Setting/SettingValueUpdateCommand.cs b/Source/Starfish.Service/Application/Commands/Configuration/ConfigurationValueUpdateCommand.cs similarity index 56% rename from Source/Starfish.Service/Application/Commands/Setting/SettingValueUpdateCommand.cs rename to Source/Starfish.Service/Application/Commands/Configuration/ConfigurationValueUpdateCommand.cs index e68e6cb..3555fd3 100644 --- a/Source/Starfish.Service/Application/Commands/Setting/SettingValueUpdateCommand.cs +++ b/Source/Starfish.Service/Application/Commands/Configuration/ConfigurationValueUpdateCommand.cs @@ -1,8 +1,8 @@ namespace Nerosoft.Starfish.Application; -public class SettingValueUpdateCommand : SettingAbstractCommand +public class ConfigurationValueUpdateCommand : ConfigurationAbstractCommand { - public SettingValueUpdateCommand(long appId, string environment, string key, string value) + public ConfigurationValueUpdateCommand(long appId, string environment, string key, string value) : base(appId, environment) { AppId = appId; diff --git a/Source/Starfish.Service/Application/ConnectionContainer.cs b/Source/Starfish.Service/Application/ConnectionContainer.cs index 05dbbaa..f4369f9 100644 --- a/Source/Starfish.Service/Application/ConnectionContainer.cs +++ b/Source/Starfish.Service/Application/ConnectionContainer.cs @@ -11,9 +11,9 @@ public class ConnectionContainer private static readonly ConcurrentDictionary _connections = new(StringComparer.OrdinalIgnoreCase); - private readonly ISettingApplicationService _service; + private readonly IConfigurationApplicationService _service; - public ConnectionContainer(ISettingApplicationService service) + public ConnectionContainer(IConfigurationApplicationService service) { _service = service; @@ -22,7 +22,7 @@ public ConnectionContainer(ISettingApplicationService service) private async void OnClientConnected(object sender, ClientConnectedEventArgs e) { - var raw = await _service.GetSettingRawAsync(e.AppId, e.Environment); + var raw = await _service.GetArchiveAsync(e.AppId, e.Environment); var key = $"{e.AppId}-{e.Environment}"; if (_connections.TryGetValue(key, out var connection)) { @@ -61,9 +61,9 @@ public void Remove(long appId, string environment, string connectionId) } [Subscribe] - public async Task HandleAsync(SettingArchiveUpdatedEvent @event, MessageContext context, CancellationToken cancellationToken = default) + public async Task HandleAsync(ConfigurationArchiveUpdatedEvent @event, MessageContext context, CancellationToken cancellationToken = default) { - var aggregate = @event.GetAggregate(); + var aggregate = @event.GetAggregate(); var key = $"{aggregate.AppId}-{aggregate.Environment}"; if (_connections.TryGetValue(key, out var connection)) { diff --git a/Source/Starfish.Service/Application/Contracts/ISettingApplicationService.cs b/Source/Starfish.Service/Application/Contracts/IConfigurationApplicationService.cs similarity index 82% rename from Source/Starfish.Service/Application/Contracts/ISettingApplicationService.cs rename to Source/Starfish.Service/Application/Contracts/IConfigurationApplicationService.cs index caee836..2b4e5b0 100644 --- a/Source/Starfish.Service/Application/Contracts/ISettingApplicationService.cs +++ b/Source/Starfish.Service/Application/Contracts/IConfigurationApplicationService.cs @@ -6,7 +6,7 @@ namespace Nerosoft.Starfish.Application; /// /// 配置应用服务 /// -public interface ISettingApplicationService : IApplicationService +public interface IConfigurationApplicationService : IApplicationService { /// /// 获取配置项列表 @@ -17,7 +17,7 @@ public interface ISettingApplicationService : IApplicationService /// /// /// - Task> GetItemListAsync(long appId, string environment, int skip, int count, CancellationToken cancellationToken = default); + Task> GetItemListAsync(long appId, string environment, int skip, int count, CancellationToken cancellationToken = default); /// /// 获取配置项数量 @@ -35,7 +35,7 @@ public interface ISettingApplicationService : IApplicationService /// /// /// - Task GetDetailAsync(long appId, string environment, CancellationToken cancellationToken = default); + Task GetDetailAsync(long appId, string environment, CancellationToken cancellationToken = default); /// /// 新建配置 @@ -46,7 +46,7 @@ public interface ISettingApplicationService : IApplicationService /// /// /// - Task CreateAsync(long appId, string environment, string format, SettingEditDto data, CancellationToken cancellationToken = default); + Task CreateAsync(long appId, string environment, string format, ConfigurationEditDto data, CancellationToken cancellationToken = default); /// /// 更新配置 @@ -57,7 +57,7 @@ public interface ISettingApplicationService : IApplicationService /// /// /// - Task UpdateAsync(long appId, string environment, string format, SettingEditDto data, CancellationToken cancellationToken = default); + Task UpdateAsync(long appId, string environment, string format, ConfigurationEditDto data, CancellationToken cancellationToken = default); /// /// 删除节点 @@ -87,7 +87,7 @@ public interface ISettingApplicationService : IApplicationService /// /// /// - Task PublishAsync(long appId, string environment, SettingPublishDto data, CancellationToken cancellationToken = default); + Task PublishAsync(long appId, string environment, ConfigurationPublishDto data, CancellationToken cancellationToken = default); /// /// 获取已发布的配置 @@ -96,7 +96,7 @@ public interface ISettingApplicationService : IApplicationService /// 应用环境 /// /// - Task GetSettingRawAsync(long appId, string environment, CancellationToken cancellationToken = default); + Task GetArchiveAsync(long appId, string environment, CancellationToken cancellationToken = default); /// /// 获取指定格式的配置 diff --git a/Source/Starfish.Service/Application/Events/SettingPublishedEvent.cs b/Source/Starfish.Service/Application/Events/ConfigurationPublishedEvent.cs similarity index 78% rename from Source/Starfish.Service/Application/Events/SettingPublishedEvent.cs rename to Source/Starfish.Service/Application/Events/ConfigurationPublishedEvent.cs index b13f2c7..24933a1 100644 --- a/Source/Starfish.Service/Application/Events/SettingPublishedEvent.cs +++ b/Source/Starfish.Service/Application/Events/ConfigurationPublishedEvent.cs @@ -7,13 +7,13 @@ namespace Nerosoft.Starfish.Application; /// /// 配置节点发布完成事件 /// -public class SettingPublishedEvent : ApplicationEvent +public class ConfigurationPublishedEvent : ApplicationEvent { - public SettingPublishedEvent() + public ConfigurationPublishedEvent() { } - public SettingPublishedEvent(long appId, string environment) + public ConfigurationPublishedEvent(long appId, string environment) : this() { AppId = appId; diff --git a/Source/Starfish.Service/Application/Handlers/ConfigurationCommandHandler.cs b/Source/Starfish.Service/Application/Handlers/ConfigurationCommandHandler.cs new file mode 100644 index 0000000..5dd25d4 --- /dev/null +++ b/Source/Starfish.Service/Application/Handlers/ConfigurationCommandHandler.cs @@ -0,0 +1,96 @@ +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 ConfigurationCommandHandler : CommandHandlerBase, + IHandler, + IHandler, + IHandler, + IHandler, + IHandler, + IHandler, + IHandler +{ + public ConfigurationCommandHandler(IUnitOfWorkManager unitOfWork, IObjectFactory factory) + : base(unitOfWork, factory) + { + } + + public Task HandleAsync(ConfigurationCreateCommand message, MessageContext context, CancellationToken cancellationToken = default) + { + return ExecuteAsync(async () => + { + var business = await Factory.CreateAsync(cancellationToken); + business.AppId = message.AppId; + business.Environment = message.Environment; + business.Items = message.Data; + _ = await business.SaveAsync(false, cancellationToken); + return business.Id; + }, context.Response); + } + + public Task HandleAsync(ConfigurationUpdateCommand message, MessageContext context, CancellationToken cancellationToken = default) + { + return ExecuteAsync(async () => + { + var business = await Factory.FetchAsync(message.AppId, message.Environment, cancellationToken); + business.Items = message.Data; + _ = await business.SaveAsync(true, cancellationToken); + }); + } + + /// + public Task HandleAsync(ConfigurationDeleteCommand message, MessageContext context, CancellationToken cancellationToken = default) + { + return ExecuteAsync(async () => + { + var business = await Factory.FetchAsync(message.AppId, message.Environment, cancellationToken); + business.MarkAsDelete(); + await business.SaveAsync(false, cancellationToken); + }); + } + + /// + public Task HandleAsync(ConfigurationPublishCommand message, MessageContext context, CancellationToken cancellationToken = default) + { + return ExecuteAsync(async () => + { + await Factory.ExecuteAsync(message.AppId, message.Environment, 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); + }); + } + + public Task HandleAsync(ConfigurationRevisionCreateCommand 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); + }); + } + + public Task HandleAsync(ConfigurationArchiveCreateCommand message, MessageContext context, CancellationToken cancellationToken = default) + { + return ExecuteAsync(async () => + { + await Factory.ExecuteAsync(message.AppId, message.Environment, context.User?.Identity?.Name, cancellationToken); + }); + } +} \ No newline at end of file diff --git a/Source/Starfish.Service/Application/Handlers/SettingCommandHandler.cs b/Source/Starfish.Service/Application/Handlers/SettingCommandHandler.cs deleted file mode 100644 index 121b777..0000000 --- a/Source/Starfish.Service/Application/Handlers/SettingCommandHandler.cs +++ /dev/null @@ -1,96 +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 SettingCommandHandler : CommandHandlerBase, - IHandler, - IHandler, - IHandler, - IHandler, - IHandler, - IHandler, - IHandler -{ - public SettingCommandHandler(IUnitOfWorkManager unitOfWork, IObjectFactory factory) - : base(unitOfWork, factory) - { - } - - public Task HandleAsync(SettingCreateCommand message, MessageContext context, CancellationToken cancellationToken = default) - { - return ExecuteAsync(async () => - { - var business = await Factory.CreateAsync(cancellationToken); - business.AppId = message.AppId; - business.Environment = message.Environment; - business.Items = message.Data; - _ = await business.SaveAsync(false, cancellationToken); - return business.Id; - }, context.Response); - } - - public Task HandleAsync(SettingUpdateCommand message, MessageContext context, CancellationToken cancellationToken = default) - { - return ExecuteAsync(async () => - { - var business = await Factory.FetchAsync(message.AppId, message.Environment, cancellationToken); - business.Items = message.Data; - _ = await business.SaveAsync(true, cancellationToken); - }); - } - - /// - public Task HandleAsync(SettingDeleteCommand message, MessageContext context, CancellationToken cancellationToken = default) - { - return ExecuteAsync(async () => - { - var business = await Factory.FetchAsync(message.AppId, message.Environment, cancellationToken); - business.MarkAsDelete(); - await business.SaveAsync(false, cancellationToken); - }); - } - - /// - public Task HandleAsync(SettingPublishCommand message, MessageContext context, CancellationToken cancellationToken = default) - { - return ExecuteAsync(async () => - { - await Factory.ExecuteAsync(message.AppId, message.Environment, cancellationToken); - }); - } - - public Task HandleAsync(SettingValueUpdateCommand 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); - }); - } - - public Task HandleAsync(SettingRevisionCreateCommand message, MessageContext context, CancellationToken cancellationToken = default) - { - return ExecuteAsync(async () => - { - var argument = new SettingRevisionArgument(message.Version, message.Comment, context.User?.Identity?.Name); - await Factory.ExecuteAsync(message.AppId, message.Environment, argument, cancellationToken); - }); - } - - public Task HandleAsync(SettingArchiveCreateCommand message, MessageContext context, CancellationToken cancellationToken = default) - { - return ExecuteAsync(async () => - { - await Factory.ExecuteAsync(message.AppId, message.Environment, context.User?.Identity?.Name, cancellationToken); - }); - } -} \ No newline at end of file diff --git a/Source/Starfish.Service/Application/Implements/SettingApplicationService.cs b/Source/Starfish.Service/Application/Implements/ConfigurationApplicationService.cs similarity index 55% rename from Source/Starfish.Service/Application/Implements/SettingApplicationService.cs rename to Source/Starfish.Service/Application/Implements/ConfigurationApplicationService.cs index 7877d37..aaf01f9 100644 --- a/Source/Starfish.Service/Application/Implements/SettingApplicationService.cs +++ b/Source/Starfish.Service/Application/Implements/ConfigurationApplicationService.cs @@ -8,13 +8,13 @@ namespace Nerosoft.Starfish.Application; /// /// 配置应用服务 /// -public class SettingApplicationService : BaseApplicationService, ISettingApplicationService +public class ConfigurationApplicationService : BaseApplicationService, IConfigurationApplicationService { /// - public Task> GetItemListAsync(long appId, string environment, int skip, int count, CancellationToken cancellationToken = default) + public Task> GetItemListAsync(long appId, string environment, int skip, int count, CancellationToken cancellationToken = default) { - var useCase = LazyServiceProvider.GetRequiredService(); - var input = new GetSettingItemListInput(appId, environment, skip, count); + var useCase = LazyServiceProvider.GetRequiredService(); + var input = new GetConfigurationItemListInput(appId, environment, skip, count); return useCase.ExecuteAsync(input, cancellationToken) .ContinueWith(t => t.Result.Result, cancellationToken); } @@ -22,67 +22,67 @@ public Task> GetItemListAsync(long appId, string environmen /// public Task GetItemCountAsync(long appId, string environment, CancellationToken cancellationToken = default) { - var useCase = LazyServiceProvider.GetRequiredService(); - var input = new GetSettingItemCountInput(appId, environment); + var useCase = LazyServiceProvider.GetRequiredService(); + var input = new GetConfigurationItemCountInput(appId, environment); return useCase.ExecuteAsync(input, cancellationToken) .ContinueWith(t => t.Result.Result, cancellationToken); } /// - public Task GetDetailAsync(long appId, string environment, CancellationToken cancellationToken = default) + public Task GetDetailAsync(long appId, string environment, CancellationToken cancellationToken = default) { - var useCase = LazyServiceProvider.GetRequiredService(); - var input = new GetSettingDetailInput(appId, environment); + var useCase = LazyServiceProvider.GetRequiredService(); + var input = new GetConfigurationDetailInput(appId, environment); return useCase.ExecuteAsync(input, cancellationToken) .ContinueWith(t => t.Result.Result, cancellationToken); } /// - public Task CreateAsync(long appId, string environment, string format, SettingEditDto data, CancellationToken cancellationToken = default) + public Task CreateAsync(long appId, string environment, string format, ConfigurationEditDto data, CancellationToken cancellationToken = default) { - var useCase = LazyServiceProvider.GetRequiredService(); - var input = new SettingCreateInput(appId, environment, format, data); + var useCase = LazyServiceProvider.GetRequiredService(); + var input = new ConfigurationCreateInput(appId, environment, format, data); return useCase.ExecuteAsync(input, cancellationToken) .ContinueWith(t => t.Result, cancellationToken); } /// - public async Task UpdateAsync(long appId, string environment, string format, SettingEditDto data, CancellationToken cancellationToken = default) + public async Task UpdateAsync(long appId, string environment, string format, ConfigurationEditDto data, CancellationToken cancellationToken = default) { - var useCase = LazyServiceProvider.GetRequiredService(); - var input = new SettingUpdateInput(appId, environment, format, data); + var useCase = LazyServiceProvider.GetRequiredService(); + var input = new ConfigurationUpdateInput(appId, environment, format, data); await useCase.ExecuteAsync(input, cancellationToken); } /// public Task DeleteAsync(long appId, string environment, CancellationToken cancellationToken = default) { - var useCase = LazyServiceProvider.GetRequiredService(); - var input = new SettingDeleteInput(appId, environment); + var useCase = LazyServiceProvider.GetRequiredService(); + var input = new ConfigurationDeleteInput(appId, environment); return useCase.ExecuteAsync(input, cancellationToken); } /// public Task UpdateAsync(long appId, string environment, string key, string value, CancellationToken cancellationToken = default) { - var useCase = LazyServiceProvider.GetRequiredService(); - var input = new SettingValueUpdateInput(appId, environment, key, value); + var useCase = LazyServiceProvider.GetRequiredService(); + var input = new ConfigurationValueUpdateInput(appId, environment, key, value); return useCase.ExecuteAsync(input, cancellationToken); } /// - public Task PublishAsync(long appId, string environment, SettingPublishDto data, CancellationToken cancellationToken = default) + public Task PublishAsync(long appId, string environment, ConfigurationPublishDto data, CancellationToken cancellationToken = default) { - var useCase = LazyServiceProvider.GetRequiredService(); - var input = new SettingPublishInput(appId, environment, data); + var useCase = LazyServiceProvider.GetRequiredService(); + var input = new ConfigurationPublishInput(appId, environment, data); return useCase.ExecuteAsync(input, cancellationToken); } /// - public Task GetSettingRawAsync(long appId, string environment, CancellationToken cancellationToken = default) + public Task GetArchiveAsync(long appId, string environment, CancellationToken cancellationToken = default) { - var useCase = LazyServiceProvider.GetRequiredService(); - var input = new GetSettingRawInput(appId, environment); + var useCase = LazyServiceProvider.GetRequiredService(); + var input = new GetConfigurationRawInput(appId, environment); return useCase.ExecuteAsync(input, cancellationToken) .ContinueWith(t => t.Result.Result, cancellationToken); } diff --git a/Source/Starfish.Service/Application/Mappings/ConfigurationMappingProfile.cs b/Source/Starfish.Service/Application/Mappings/ConfigurationMappingProfile.cs new file mode 100644 index 0000000..5677b22 --- /dev/null +++ b/Source/Starfish.Service/Application/Mappings/ConfigurationMappingProfile.cs @@ -0,0 +1,31 @@ +using AutoMapper; +using Nerosoft.Starfish.Domain; +using Nerosoft.Starfish.Transit; + +namespace Nerosoft.Starfish.Application; + +/// +/// 配置节点映射配置 +/// +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)); + } + + private static string GetStatusDescription(ConfigurationStatus status) + { + return status switch + { + ConfigurationStatus.Disabled => Resources.IDS_ENUM_CONFIG_STATUS_DISABLED, + ConfigurationStatus.Pending => Resources.IDS_ENUM_CONFIG_STATUS_PENDING, + ConfigurationStatus.Published => Resources.IDS_ENUM_CONFIG_STATUS_PUBLISHED, + _ => status.ToString() + }; + } +} \ No newline at end of file diff --git a/Source/Starfish.Service/Application/Mappings/SettingMappingProfile.cs b/Source/Starfish.Service/Application/Mappings/SettingMappingProfile.cs deleted file mode 100644 index e05bf56..0000000 --- a/Source/Starfish.Service/Application/Mappings/SettingMappingProfile.cs +++ /dev/null @@ -1,31 +0,0 @@ -using AutoMapper; -using Nerosoft.Starfish.Domain; -using Nerosoft.Starfish.Transit; - -namespace Nerosoft.Starfish.Application; - -/// -/// 配置节点映射配置 -/// -internal class SettingMappingProfile : Profile -{ - /// - public SettingMappingProfile() - { - CreateMap(); - CreateMap() - .ForMember(dest => dest.StatusDescription, options => options.MapFrom(src => GetStatusDescription(src.Status))) - .ForMember(dest => dest.AppName, options => options.MapFrom(src => src.App.Name)); - } - - private static string GetStatusDescription(SettingStatus status) - { - return status switch - { - SettingStatus.Disabled => Resources.IDS_ENUM_SETTING_STATUS_DISABLED, - SettingStatus.Pending => Resources.IDS_ENUM_SETTING_STATUS_PENDING, - SettingStatus.Published => Resources.IDS_ENUM_SETTING_STATUS_PUBLISHED, - _ => status.ToString() - }; - } -} \ No newline at end of file diff --git a/Source/Starfish.Service/Application/Subscribers/SettingArchiveEventSubscriber.cs b/Source/Starfish.Service/Application/Subscribers/ConfigurationArchiveEventSubscriber.cs similarity index 66% rename from Source/Starfish.Service/Application/Subscribers/SettingArchiveEventSubscriber.cs rename to Source/Starfish.Service/Application/Subscribers/ConfigurationArchiveEventSubscriber.cs index f3f01c6..b9a9e61 100644 --- a/Source/Starfish.Service/Application/Subscribers/SettingArchiveEventSubscriber.cs +++ b/Source/Starfish.Service/Application/Subscribers/ConfigurationArchiveEventSubscriber.cs @@ -5,11 +5,11 @@ namespace Nerosoft.Starfish.Application; /// /// 配置归档事件订阅者 /// -public class SettingArchiveEventSubscriber : IHandler +public class ConfigurationArchiveEventSubscriber : IHandler { private readonly IBus _bus; - public SettingArchiveEventSubscriber(IBus bus) + public ConfigurationArchiveEventSubscriber(IBus bus) { _bus = bus; } @@ -22,9 +22,9 @@ public SettingArchiveEventSubscriber(IBus bus) /// /// /// - public Task HandleAsync(SettingPublishedEvent message, MessageContext context, CancellationToken cancellationToken = default) + public Task HandleAsync(ConfigurationPublishedEvent message, MessageContext context, CancellationToken cancellationToken = default) { - var command = new SettingArchiveCreateCommand + var command = new ConfigurationArchiveCreateCommand { AppId = message.AppId, Environment = message.Environment, diff --git a/Source/Starfish.Service/Application/Subscribers/SettingEventSubscriber.cs b/Source/Starfish.Service/Application/Subscribers/ConfigurationEventSubscriber.cs similarity index 58% rename from Source/Starfish.Service/Application/Subscribers/SettingEventSubscriber.cs rename to Source/Starfish.Service/Application/Subscribers/ConfigurationEventSubscriber.cs index 77d4c87..d6b5556 100644 --- a/Source/Starfish.Service/Application/Subscribers/SettingEventSubscriber.cs +++ b/Source/Starfish.Service/Application/Subscribers/ConfigurationEventSubscriber.cs @@ -2,11 +2,11 @@ namespace Nerosoft.Starfish.Application; -public class SettingEventSubscriber +public class ConfigurationEventSubscriber { private readonly IBus _bus; - public SettingEventSubscriber(IBus bus) + public ConfigurationEventSubscriber(IBus bus) { _bus = bus; } diff --git a/Source/Starfish.Service/Application/Subscribers/SettingRevisionEventSubscriber.cs b/Source/Starfish.Service/Application/Subscribers/ConfigurationRevisionEventSubscriber.cs similarity index 68% rename from Source/Starfish.Service/Application/Subscribers/SettingRevisionEventSubscriber.cs rename to Source/Starfish.Service/Application/Subscribers/ConfigurationRevisionEventSubscriber.cs index 4a5e2e8..a44550b 100644 --- a/Source/Starfish.Service/Application/Subscribers/SettingRevisionEventSubscriber.cs +++ b/Source/Starfish.Service/Application/Subscribers/ConfigurationRevisionEventSubscriber.cs @@ -5,11 +5,11 @@ namespace Nerosoft.Starfish.Application; /// /// 配置版本事件订阅者 /// -public class SettingRevisionEventSubscriber : IHandler +public class ConfigurationRevisionEventSubscriber : IHandler { private readonly IBus _bus; - public SettingRevisionEventSubscriber(IBus bus) + public ConfigurationRevisionEventSubscriber(IBus bus) { _bus = bus; } @@ -22,9 +22,9 @@ public SettingRevisionEventSubscriber(IBus bus) /// /// /// - public Task HandleAsync(SettingPublishedEvent message, MessageContext context, CancellationToken cancellationToken = default) + public Task HandleAsync(ConfigurationPublishedEvent message, MessageContext context, CancellationToken cancellationToken = default) { - var command = new SettingRevisionCreateCommand + var command = new ConfigurationRevisionCreateCommand { AppId = message.AppId, Environment = message.Environment, diff --git a/Source/Starfish.Service/Application/Subscribers/LoggingEventSubscriber.cs b/Source/Starfish.Service/Application/Subscribers/LoggingEventSubscriber.cs index 30239bd..c244ed8 100644 --- a/Source/Starfish.Service/Application/Subscribers/LoggingEventSubscriber.cs +++ b/Source/Starfish.Service/Application/Subscribers/LoggingEventSubscriber.cs @@ -173,9 +173,9 @@ public Task HandleAsync(AppInfoUpdatedEvent @event, MessageContext context, Canc /// /// [Subscribe] - public Task HandleAsync(SettingCreatedEvent @event, MessageContext context, CancellationToken cancellationToken = default) + public Task HandleAsync(ConfigurationCreatedEvent @event, MessageContext context, CancellationToken cancellationToken = default) { - var description = string.Format(Resources.IDS_MESSAGE_LOGS_SETTING_CREATE, @event.Setting.AppId, @event.Setting.Environment); + var description = string.Format(Resources.IDS_MESSAGE_LOGS_CONFIG_CREATE, @event.Configuration.AppId, @event.Configuration.Environment); var command = new OperateLogCreateCommand { @@ -197,10 +197,10 @@ public Task HandleAsync(SettingCreatedEvent @event, MessageContext context, Canc /// /// [Subscribe] - public Task HandleAsync(SettingDeletedEvent @event, MessageContext context, CancellationToken cancellationToken = default) + public Task HandleAsync(ConfigurationDeletedEvent @event, MessageContext context, CancellationToken cancellationToken = default) { - var aggregate = @event.GetAggregate(); - var description = string.Format(Resources.IDS_MESSAGE_LOGS_SETTING_DELETE, aggregate.AppId, aggregate.Environment); + var aggregate = @event.GetAggregate(); + var description = string.Format(Resources.IDS_MESSAGE_LOGS_CONFIG_DELETE, aggregate.AppId, aggregate.Environment); var command = new OperateLogCreateCommand { @@ -215,9 +215,9 @@ public Task HandleAsync(SettingDeletedEvent @event, MessageContext context, Canc } [Subscribe] - public Task HandleAsync(SettingPublishedEvent @event, MessageContext context, CancellationToken cancellationToken = default) + public Task HandleAsync(ConfigurationPublishedEvent @event, MessageContext context, CancellationToken cancellationToken = default) { - var description = string.Format(Resources.IDS_MESSAGE_LOGS_SETTING_PUBLISH, @event.AppId, @event.Environment); + var description = string.Format(Resources.IDS_MESSAGE_LOGS_CONFIG_PUBLISH, @event.AppId, @event.Environment); var command = new OperateLogCreateCommand { diff --git a/Source/Starfish.Service/Domain/Aggregates/Setting.cs b/Source/Starfish.Service/Domain/Aggregates/Configuration.cs similarity index 66% rename from Source/Starfish.Service/Domain/Aggregates/Setting.cs rename to Source/Starfish.Service/Domain/Aggregates/Configuration.cs index 53acfde..37d6973 100644 --- a/Source/Starfish.Service/Domain/Aggregates/Setting.cs +++ b/Source/Starfish.Service/Domain/Aggregates/Configuration.cs @@ -7,11 +7,11 @@ namespace Nerosoft.Starfish.Domain; /// /// 设置聚合根 /// -public class Setting : Aggregate, IAuditing +public class Configuration : Aggregate, IAuditing { - private Setting() + private Configuration() { - Register(@event => + Register(@event => { Status = @event.NewStatus; }); @@ -30,7 +30,7 @@ private Setting() /// /// 状态 /// - public SettingStatus Status { get; set; } + public ConfigurationStatus Status { get; set; } /// /// 当前版本号 @@ -59,38 +59,38 @@ private Setting() /// /// 设置项 /// - public HashSet Items { get; set; } + public HashSet Items { get; set; } /// /// 历史版本 /// - public HashSet Revisions { get; set; } + public HashSet Revisions { get; set; } /// /// 应用信息 /// public AppInfo App { get; set; } - internal static Setting Create(long appId, string environment, IDictionary items) + internal static Configuration Create(long appId, string environment, IDictionary items) { - var setting = new Setting + var setting = new Configuration { AppId = appId, Environment = environment, - Status = SettingStatus.Pending + Status = ConfigurationStatus.Pending }; setting.AddOrUpdateItem(items); - setting.RaiseEvent(new SettingCreatedEvent(setting)); + setting.RaiseEvent(new ConfigurationCreatedEvent(setting)); return setting; } internal void AddOrUpdateItem(IDictionary items) { - if (Status == SettingStatus.Disabled) + if (Status == ConfigurationStatus.Disabled) { - throw new InvalidOperationException(Resources.IDS_ERROR_SETTING_DISABLED); + throw new InvalidOperationException(Resources.IDS_ERROR_CONFIG_DISABLED); } Items ??= []; @@ -100,7 +100,7 @@ internal void AddOrUpdateItem(IDictionary items) var item = Items.FirstOrDefault(t => t.Key == key); if (item == null) { - item = new SettingItem(key, value); + item = new ConfigurationItem(key, value); Items.Add(item); } else @@ -109,14 +109,14 @@ internal void AddOrUpdateItem(IDictionary items) } } - Status = SettingStatus.Pending; + Status = ConfigurationStatus.Pending; } internal void UpdateItem(string key, string value) { - if (Status == SettingStatus.Disabled) + if (Status == ConfigurationStatus.Disabled) { - throw new InvalidOperationException(Resources.IDS_ERROR_SETTING_DISABLED); + throw new InvalidOperationException(Resources.IDS_ERROR_CONFIG_DISABLED); } Items ??= []; @@ -125,22 +125,22 @@ internal void UpdateItem(string key, string value) if (item == null) { - throw new InvalidOperationException(string.Format(Resources.IDS_ERROR_SETTING_KEY_NOT_EXISTS, key)); + throw new InvalidOperationException(string.Format(Resources.IDS_ERROR_CONFIG_KEY_NOT_EXISTS, key)); } item.Value = value; - Status = SettingStatus.Pending; + Status = ConfigurationStatus.Pending; } - internal void SetStatus(SettingStatus status) + internal void SetStatus(ConfigurationStatus status) { if (Status == status) { return; } - RaiseEvent(new SettingStatusChangedEvent(Status, status)); + RaiseEvent(new ConfigurationStatusChangedEvent(Status, status)); } internal void CreateRevision(string version, string comment, string @operator) @@ -154,12 +154,12 @@ internal void CreateRevision(string version, string comment, string @operator) if (Revisions.Any(t => string.Equals(t.Version, version, StringComparison.OrdinalIgnoreCase))) { - throw new InvalidOperationException(string.Format(Resources.IDS_ERROR_SETTING_VERSION_NUMBER_EXISTS, version)); + throw new InvalidOperationException(string.Format(Resources.IDS_ERROR_CONFIG_VERSION_NUMBER_EXISTS, version)); } var data = JsonConvert.SerializeObject(Items, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); - var revision = new SettingRevision(version, comment, data, @operator); + var revision = new ConfigurationRevision(version, comment, data, @operator); Revisions.Add(revision); diff --git a/Source/Starfish.Service/Domain/Aggregates/SettingArchive.cs b/Source/Starfish.Service/Domain/Aggregates/ConfigurationArchive.cs similarity index 74% rename from Source/Starfish.Service/Domain/Aggregates/SettingArchive.cs rename to Source/Starfish.Service/Domain/Aggregates/ConfigurationArchive.cs index dbbfeb4..8a2fa0f 100644 --- a/Source/Starfish.Service/Domain/Aggregates/SettingArchive.cs +++ b/Source/Starfish.Service/Domain/Aggregates/ConfigurationArchive.cs @@ -5,9 +5,9 @@ namespace Nerosoft.Starfish.Domain; /// /// 配置归档 /// -public class SettingArchive : Aggregate +public class ConfigurationArchive : Aggregate { - private SettingArchive() + private ConfigurationArchive() { } /// @@ -35,9 +35,9 @@ private SettingArchive() /// public DateTime ArchiveTime { get; set; } - internal static SettingArchive Create(long appId, string environment) + internal static ConfigurationArchive Create(long appId, string environment) { - var entity = new SettingArchive() + var entity = new ConfigurationArchive() { AppId = appId, Environment = environment @@ -52,6 +52,6 @@ internal void Update(string data, string @operator) Operator = @operator; ArchiveTime = DateTime.Now; - RaiseEvent(new SettingArchiveUpdatedEvent()); + RaiseEvent(new ConfigurationArchiveUpdatedEvent()); } } \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Aggregates/SettingItem.cs b/Source/Starfish.Service/Domain/Aggregates/ConfigurationItem.cs similarity index 52% rename from Source/Starfish.Service/Domain/Aggregates/SettingItem.cs rename to Source/Starfish.Service/Domain/Aggregates/ConfigurationItem.cs index 0748005..cff3e9e 100644 --- a/Source/Starfish.Service/Domain/Aggregates/SettingItem.cs +++ b/Source/Starfish.Service/Domain/Aggregates/ConfigurationItem.cs @@ -5,31 +5,31 @@ namespace Nerosoft.Starfish.Domain; /// -/// 配置信息 +/// 配置项 /// -public class SettingItem : Entity +public class ConfigurationItem : Entity { - private SettingItem() + private ConfigurationItem() { } - public SettingItem(string key) + public ConfigurationItem(string key) { Key = key; } - internal SettingItem(string key, string value) + internal ConfigurationItem(string key, string value) : this() { Key = key; Value = value; } - public long SettingId { get; set; } + public long ConfigurationId { get; set; } public string Key { get; set; } public string Value { get; set; } - public Setting Setting { get; set; } + public Configuration Configuration { get; set; } } \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Aggregates/SettingRevision.cs b/Source/Starfish.Service/Domain/Aggregates/ConfigurationRevision.cs similarity index 73% rename from Source/Starfish.Service/Domain/Aggregates/SettingRevision.cs rename to Source/Starfish.Service/Domain/Aggregates/ConfigurationRevision.cs index e2ea8f4..b64f749 100644 --- a/Source/Starfish.Service/Domain/Aggregates/SettingRevision.cs +++ b/Source/Starfish.Service/Domain/Aggregates/ConfigurationRevision.cs @@ -5,14 +5,14 @@ namespace Nerosoft.Starfish.Domain; /// /// 配置修订版本 /// -public class SettingRevision : Entity, +public class ConfigurationRevision : Entity, IHasCreateTime { - private SettingRevision() + private ConfigurationRevision() { } - internal SettingRevision(string version, string comment, string data, string @operator) + internal ConfigurationRevision(string version, string comment, string data, string @operator) : this() { Version = version; @@ -21,7 +21,7 @@ internal SettingRevision(string version, string comment, string data, string @op Operator = @operator; } - public long SettingId { get; set; } + public long ConfigurationId { get; set; } /// /// 配置数据 @@ -51,5 +51,5 @@ internal SettingRevision(string version, string comment, string data, string @op /// /// /// - public Setting Setting { get; set; } + public Configuration Configuration { get; set; } } \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Business/SettingArchiveBusiness.cs b/Source/Starfish.Service/Domain/Business/ConfigurationArchiveBusiness.cs similarity index 62% rename from Source/Starfish.Service/Domain/Business/SettingArchiveBusiness.cs rename to Source/Starfish.Service/Domain/Business/ConfigurationArchiveBusiness.cs index 4d25b75..1ce2ddb 100644 --- a/Source/Starfish.Service/Domain/Business/SettingArchiveBusiness.cs +++ b/Source/Starfish.Service/Domain/Business/ConfigurationArchiveBusiness.cs @@ -5,22 +5,22 @@ namespace Nerosoft.Starfish.Domain; -public class SettingArchiveBusiness : CommandObject, IDomainService +public class ConfigurationArchiveBusiness : CommandObject, IDomainService { [Inject] - public ISettingRepository SettingRepository { get; set; } + public IConfigurationRepository ConfigurationRepository { get; set; } [Inject] - public ISettingArchiveRepository ArchiveRepository { get; set; } + public IConfigurationArchiveRepository ArchiveRepository { get; set; } [FactoryExecute] protected async Task ExecuteAsync(long appId, string environment, string userName, CancellationToken cancellationToken = default) { - var aggregate = await SettingRepository.GetAsync(appId, environment, false, [nameof(Setting.Items)], cancellationToken); + var aggregate = await ConfigurationRepository.GetAsync(appId, environment, false, [nameof(Configuration.Items)], cancellationToken); if (aggregate == null) { - throw new SettingNotFoundException(appId, environment); + throw new ConfigurationNotFoundException(appId, environment); } var data = aggregate.Items.ToDictionary(t => t.Key, t => t.Value); @@ -28,7 +28,7 @@ protected async Task ExecuteAsync(long appId, string environment, string userNam var archive = await ArchiveRepository.GetAsync(appId, environment, cancellationToken); - archive ??= SettingArchive.Create(appId, environment); + archive ??= ConfigurationArchive.Create(appId, environment); archive.Update(GzipHelper.CompressToBase64(json), userName); diff --git a/Source/Starfish.Service/Domain/Business/SettingGeneralBusiness.cs b/Source/Starfish.Service/Domain/Business/ConfigurationGeneralBusiness.cs similarity index 76% rename from Source/Starfish.Service/Domain/Business/SettingGeneralBusiness.cs rename to Source/Starfish.Service/Domain/Business/ConfigurationGeneralBusiness.cs index b62242b..ce3c9d0 100644 --- a/Source/Starfish.Service/Domain/Business/SettingGeneralBusiness.cs +++ b/Source/Starfish.Service/Domain/Business/ConfigurationGeneralBusiness.cs @@ -6,15 +6,15 @@ namespace Nerosoft.Starfish.Domain; -internal class SettingGeneralBusiness : EditableObjectBase +internal class ConfigurationGeneralBusiness : EditableObjectBase { [Inject] public IAppInfoRepository AppInfoRepository { get; set; } [Inject] - public ISettingRepository SettingRepository { get; set; } + public IConfigurationRepository ConfigurationRepository { get; set; } - internal Setting Aggregate { get; private 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); @@ -73,9 +73,9 @@ protected override async Task CreateAsync(CancellationToken cancellationToken = [FactoryFetch] protected async Task FetchAsync(long appId, string environment, CancellationToken cancellationToken = default) { - var aggregate = await SettingRepository.GetAsync(appId, environment, true, [nameof(Setting.Items)], cancellationToken); + var aggregate = await ConfigurationRepository.GetAsync(appId, environment, true, [nameof(Configuration.Items)], cancellationToken); - Aggregate = aggregate ?? throw new SettingNotFoundException(appId, environment); + Aggregate = aggregate ?? throw new ConfigurationNotFoundException(appId, environment); using (BypassRuleChecks) { @@ -113,8 +113,8 @@ protected override async Task InsertAsync(CancellationToken cancellationToken = throw new AppInfoNotEnabledException(AppId); } - var aggregate = Setting.Create(AppId, Environment, Items); - await SettingRepository.InsertAsync(aggregate, true, cancellationToken); + var aggregate = Configuration.Create(AppId, Environment, Items); + await ConfigurationRepository.InsertAsync(aggregate, true, cancellationToken); Id = aggregate.Id; } @@ -135,30 +135,30 @@ protected override async Task UpdateAsync(CancellationToken cancellationToken = Aggregate.UpdateItem(Key, Value); } - await SettingRepository.UpdateAsync(Aggregate, true, cancellationToken); + await ConfigurationRepository.UpdateAsync(Aggregate, true, cancellationToken); } [FactoryDelete] protected override Task DeleteAsync(CancellationToken cancellationToken = default) { - Aggregate.RaiseEvent(new SettingDeletedEvent()); - return SettingRepository.DeleteAsync(Aggregate, true, cancellationToken); + Aggregate.RaiseEvent(new ConfigurationDeletedEvent()); + return ConfigurationRepository.DeleteAsync(Aggregate, true, cancellationToken); } public class DuplicateCheckRule : RuleBase { public override async Task ExecuteAsync(IRuleContext context, CancellationToken cancellationToken = default) { - var target = (SettingGeneralBusiness)context.Target; + var target = (ConfigurationGeneralBusiness)context.Target; if (!target.IsInsert) { return; } - var exists = await target.SettingRepository.ExistsAsync(target.AppId, target.Environment, cancellationToken); + var exists = await target.ConfigurationRepository.ExistsAsync(target.AppId, target.Environment, cancellationToken); if (exists) { - context.AddErrorResult(string.Format(Resources.IDS_ERROR_SETTING_DUPLICATE, target.AppId, target.Environment)); + context.AddErrorResult(string.Format(Resources.IDS_ERROR_CONFIG_DUPLICATE, target.AppId, target.Environment)); } } } diff --git a/Source/Starfish.Service/Domain/Business/SettingPublishBusiness.cs b/Source/Starfish.Service/Domain/Business/ConfigurationPublishBusiness.cs similarity index 59% rename from Source/Starfish.Service/Domain/Business/SettingPublishBusiness.cs rename to Source/Starfish.Service/Domain/Business/ConfigurationPublishBusiness.cs index 548faf1..0a55641 100644 --- a/Source/Starfish.Service/Domain/Business/SettingPublishBusiness.cs +++ b/Source/Starfish.Service/Domain/Business/ConfigurationPublishBusiness.cs @@ -9,13 +9,13 @@ namespace Nerosoft.Starfish.Domain; /// /// 应用配置发布领域服务 /// -public class SettingPublishBusiness : CommandObject, IDomainService +public class ConfigurationPublishBusiness : CommandObject, IDomainService { [Inject] public IAppInfoRepository AppInfoRepository { get; set; } [Inject] - public ISettingRepository SettingRepository { get; set; } + public IConfigurationRepository ConfigurationRepository { get; set; } [Inject] public UserPrincipal Identity { get; set; } @@ -37,20 +37,20 @@ protected async Task ExecuteAsync(long appId, string environment, CancellationTo throw new ArgumentOutOfRangeException(); } - var aggregate = await SettingRepository.GetAsync(appId, environment, true, [], cancellationToken); + var aggregate = await ConfigurationRepository.GetAsync(appId, environment, true, [], cancellationToken); if (aggregate == null) { - throw new SettingNotFoundException(appId, environment); + throw new ConfigurationNotFoundException(appId, environment); } - if (aggregate.Status == SettingStatus.Disabled) + if (aggregate.Status == ConfigurationStatus.Disabled) { - throw new SettingDisabledException(appId, environment); + throw new ConfigurationDisabledException(appId, environment); } - aggregate.SetStatus(SettingStatus.Published); + aggregate.SetStatus(ConfigurationStatus.Published); - await SettingRepository.UpdateAsync(aggregate, true, cancellationToken); + await ConfigurationRepository.UpdateAsync(aggregate, true, cancellationToken); } } \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Business/ConfigurationRevisionBusiness.cs b/Source/Starfish.Service/Domain/Business/ConfigurationRevisionBusiness.cs new file mode 100644 index 0000000..eea7442 --- /dev/null +++ b/Source/Starfish.Service/Domain/Business/ConfigurationRevisionBusiness.cs @@ -0,0 +1,30 @@ +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(long 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/SettingRevisionBusiness.cs b/Source/Starfish.Service/Domain/Business/SettingRevisionBusiness.cs deleted file mode 100644 index d502885..0000000 --- a/Source/Starfish.Service/Domain/Business/SettingRevisionBusiness.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Nerosoft.Euonia.Business; -using Nerosoft.Euonia.Domain; - -namespace Nerosoft.Starfish.Domain; - -public class SettingRevisionBusiness : CommandObject, IDomainService -{ - private readonly ISettingRepository _repository; - - public SettingRevisionBusiness(ISettingRepository repository) - { - _repository = repository; - } - - [FactoryExecute] - protected async Task ExecuteAsync(long appId, string environment, SettingRevisionArgument argument, CancellationToken cancellationToken = default) - { - var aggregate = await _repository.GetAsync(appId, environment, true, [nameof(Setting.Items), nameof(Setting.Revisions)], cancellationToken); - - if (aggregate == null) - { - throw new SettingNotFoundException(appId, environment); - } - - aggregate.CreateRevision(argument.Version, argument.Comment, argument.Username); - await _repository.UpdateAsync(aggregate, true, cancellationToken); - } -} - -public record SettingRevisionArgument(string Version, string Comment, string Username); \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Enums/SettingItemType.cs b/Source/Starfish.Service/Domain/Enums/ConfigurationItemType.cs similarity index 93% rename from Source/Starfish.Service/Domain/Enums/SettingItemType.cs rename to Source/Starfish.Service/Domain/Enums/ConfigurationItemType.cs index 0b58bf6..d80ac04 100644 --- a/Source/Starfish.Service/Domain/Enums/SettingItemType.cs +++ b/Source/Starfish.Service/Domain/Enums/ConfigurationItemType.cs @@ -3,7 +3,7 @@ /// /// 配置节点类型 /// -public enum SettingItemType +public enum ConfigurationItemType { /// /// 根节点 diff --git a/Source/Starfish.Service/Domain/Enums/SettingStatus.cs b/Source/Starfish.Service/Domain/Enums/ConfigurationStatus.cs similarity index 61% rename from Source/Starfish.Service/Domain/Enums/SettingStatus.cs rename to Source/Starfish.Service/Domain/Enums/ConfigurationStatus.cs index ca4f73a..8fa1531 100644 --- a/Source/Starfish.Service/Domain/Enums/SettingStatus.cs +++ b/Source/Starfish.Service/Domain/Enums/ConfigurationStatus.cs @@ -5,7 +5,7 @@ namespace Nerosoft.Starfish.Domain; /// /// 配置节点状态 /// -public enum SettingStatus +public enum ConfigurationStatus { /// /// @@ -15,18 +15,18 @@ public enum SettingStatus /// /// 待发布 /// - [Description(nameof(Resources.IDS_ENUM_SETTING_STATUS_PENDING))] + [Description(nameof(Resources.IDS_ENUM_CONFIG_STATUS_PENDING))] Pending = 1, /// /// 已发布 /// - [Description(nameof(Resources.IDS_ENUM_SETTING_STATUS_PUBLISHED))] + [Description(nameof(Resources.IDS_ENUM_CONFIG_STATUS_PUBLISHED))] Published = 2, /// /// 禁用 /// - [Description(nameof(Resources.IDS_ENUM_SETTING_STATUS_DISABLED))] + [Description(nameof(Resources.IDS_ENUM_CONFIG_STATUS_DISABLED))] Disabled = 3 } diff --git a/Source/Starfish.Service/Domain/Events/SettingArchiveUpdatedEvent.cs b/Source/Starfish.Service/Domain/Events/ConfigurationArchiveUpdatedEvent.cs similarity index 69% rename from Source/Starfish.Service/Domain/Events/SettingArchiveUpdatedEvent.cs rename to Source/Starfish.Service/Domain/Events/ConfigurationArchiveUpdatedEvent.cs index 33660ff..e68ab07 100644 --- a/Source/Starfish.Service/Domain/Events/SettingArchiveUpdatedEvent.cs +++ b/Source/Starfish.Service/Domain/Events/ConfigurationArchiveUpdatedEvent.cs @@ -5,6 +5,6 @@ namespace Nerosoft.Starfish.Domain; /// /// 设置归档更新领域事件 /// -public class SettingArchiveUpdatedEvent : DomainEvent +public class ConfigurationArchiveUpdatedEvent : DomainEvent { } diff --git a/Source/Starfish.Service/Domain/Events/ConfigurationCreatedEvent.cs b/Source/Starfish.Service/Domain/Events/ConfigurationCreatedEvent.cs new file mode 100644 index 0000000..09f2c5b --- /dev/null +++ b/Source/Starfish.Service/Domain/Events/ConfigurationCreatedEvent.cs @@ -0,0 +1,17 @@ +using Nerosoft.Euonia.Domain; + +namespace Nerosoft.Starfish.Domain; + +public class ConfigurationCreatedEvent : DomainEvent +{ + public ConfigurationCreatedEvent() + { + } + + public ConfigurationCreatedEvent(Configuration configuration) + { + Configuration = configuration; + } + + public Configuration Configuration { get; set; } +} \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Events/SettingDeletedEvent.cs b/Source/Starfish.Service/Domain/Events/ConfigurationDeletedEvent.cs similarity index 72% rename from Source/Starfish.Service/Domain/Events/SettingDeletedEvent.cs rename to Source/Starfish.Service/Domain/Events/ConfigurationDeletedEvent.cs index 641ca19..fedb385 100644 --- a/Source/Starfish.Service/Domain/Events/SettingDeletedEvent.cs +++ b/Source/Starfish.Service/Domain/Events/ConfigurationDeletedEvent.cs @@ -5,6 +5,6 @@ namespace Nerosoft.Starfish.Domain; /// /// 配置节点删除领域事件 /// -public class SettingDeletedEvent : DomainEvent +public class ConfigurationDeletedEvent : DomainEvent { } \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Events/ConfigurationStatusChangedEvent.cs b/Source/Starfish.Service/Domain/Events/ConfigurationStatusChangedEvent.cs new file mode 100644 index 0000000..f2c880e --- /dev/null +++ b/Source/Starfish.Service/Domain/Events/ConfigurationStatusChangedEvent.cs @@ -0,0 +1,23 @@ +using Nerosoft.Euonia.Domain; + +namespace Nerosoft.Starfish.Domain; + +/// +/// 配置节点状态变更领域事件 +/// +public class ConfigurationStatusChangedEvent : DomainEvent +{ + public ConfigurationStatusChangedEvent() + { + } + + public ConfigurationStatusChangedEvent(ConfigurationStatus oldStatus, ConfigurationStatus newStatus) + { + OldStatus = oldStatus; + NewStatus = newStatus; + } + + public ConfigurationStatus OldStatus { get; set; } + + public ConfigurationStatus NewStatus { get; set; } +} \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Events/SettingCreatedEvent.cs b/Source/Starfish.Service/Domain/Events/SettingCreatedEvent.cs deleted file mode 100644 index 2a4e957..0000000 --- a/Source/Starfish.Service/Domain/Events/SettingCreatedEvent.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Nerosoft.Euonia.Domain; - -namespace Nerosoft.Starfish.Domain; - -public class SettingCreatedEvent : DomainEvent -{ - public SettingCreatedEvent() - { - } - - public SettingCreatedEvent(Setting setting) - { - Setting = setting; - } - - public Setting Setting { get; set; } -} \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Events/SettingStatusChangedEvent.cs b/Source/Starfish.Service/Domain/Events/SettingStatusChangedEvent.cs deleted file mode 100644 index c05c63b..0000000 --- a/Source/Starfish.Service/Domain/Events/SettingStatusChangedEvent.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Nerosoft.Euonia.Domain; - -namespace Nerosoft.Starfish.Domain; - -/// -/// 配置节点状态变更领域事件 -/// -public class SettingStatusChangedEvent : DomainEvent -{ - public SettingStatusChangedEvent() - { - } - - public SettingStatusChangedEvent(SettingStatus oldStatus, SettingStatus newStatus) - { - OldStatus = oldStatus; - NewStatus = newStatus; - } - - public SettingStatus OldStatus { get; set; } - - public SettingStatus NewStatus { get; set; } -} \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Exceptions/ConfigurationDisabledException.cs b/Source/Starfish.Service/Domain/Exceptions/ConfigurationDisabledException.cs new file mode 100644 index 0000000..b891f7c --- /dev/null +++ b/Source/Starfish.Service/Domain/Exceptions/ConfigurationDisabledException.cs @@ -0,0 +1,9 @@ +namespace Nerosoft.Starfish.Domain; + +public class ConfigurationDisabledException : BadRequestException +{ + public ConfigurationDisabledException(long appId, string environment) + : base(string.Format(Resources.IDS_ERROR_CONFIG_DISABLED, appId, environment)) + { + } +} \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Exceptions/SettingNotFoundException.cs b/Source/Starfish.Service/Domain/Exceptions/ConfigurationNotFoundException.cs similarity index 53% rename from Source/Starfish.Service/Domain/Exceptions/SettingNotFoundException.cs rename to Source/Starfish.Service/Domain/Exceptions/ConfigurationNotFoundException.cs index b386edb..6e2ac82 100644 --- a/Source/Starfish.Service/Domain/Exceptions/SettingNotFoundException.cs +++ b/Source/Starfish.Service/Domain/Exceptions/ConfigurationNotFoundException.cs @@ -3,15 +3,15 @@ /// /// 配置信息不存在异常 /// -public class SettingNotFoundException : NotFoundException +public class ConfigurationNotFoundException : NotFoundException { /// /// 构造函数 /// /// 应用Id /// 应用环境 - public SettingNotFoundException(long appId, string environment) - : base(string.Format(Resources.IDS_ERROR_SETTING_NOT_EXISTS, appId, environment)) + public ConfigurationNotFoundException(long appId, string environment) + : base(string.Format(Resources.IDS_ERROR_CONFIG_NOT_EXISTS, appId, environment)) { } } \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Exceptions/SettingDisabledException.cs b/Source/Starfish.Service/Domain/Exceptions/SettingDisabledException.cs deleted file mode 100644 index 097b378..0000000 --- a/Source/Starfish.Service/Domain/Exceptions/SettingDisabledException.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Nerosoft.Starfish.Domain; - -public class SettingDisabledException : BadRequestException -{ - public SettingDisabledException(long appId, string environment) - : base(string.Format(Resources.IDS_ERROR_SETTING_DISABLED, appId, environment)) - { - } -} \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Repositories/IConfigurationArchiveRepository.cs b/Source/Starfish.Service/Domain/Repositories/IConfigurationArchiveRepository.cs new file mode 100644 index 0000000..7d0207f --- /dev/null +++ b/Source/Starfish.Service/Domain/Repositories/IConfigurationArchiveRepository.cs @@ -0,0 +1,9 @@ +using Nerosoft.Starfish.Repository; +using Nerosoft.Starfish.Service; + +namespace Nerosoft.Starfish.Domain; + +public interface IConfigurationArchiveRepository : IBaseRepository +{ + Task GetAsync(long appId, string environment, CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Repositories/ISettingRepository.cs b/Source/Starfish.Service/Domain/Repositories/IConfigurationRepository.cs similarity index 57% rename from Source/Starfish.Service/Domain/Repositories/ISettingRepository.cs rename to Source/Starfish.Service/Domain/Repositories/IConfigurationRepository.cs index a4b006b..07b5753 100644 --- a/Source/Starfish.Service/Domain/Repositories/ISettingRepository.cs +++ b/Source/Starfish.Service/Domain/Repositories/IConfigurationRepository.cs @@ -3,7 +3,7 @@ namespace Nerosoft.Starfish.Domain; -public interface ISettingRepository : IBaseRepository +public interface IConfigurationRepository : IBaseRepository { /// /// 检查配置是否存在 @@ -14,9 +14,9 @@ public interface ISettingRepository : IBaseRepository Task ExistsAsync(long appId, string environment, CancellationToken cancellationToken = default); - Task GetAsync(long appId, string environment, bool tracking, string[] properties, CancellationToken cancellationToken = default); + Task GetAsync(long appId, string environment, bool tracking, string[] properties, CancellationToken cancellationToken = default); - Task> GetItemListAsync(long id, string environment, int skip, int count, CancellationToken cancellationToken = default); + Task> GetItemListAsync(long id, string environment, int skip, int count, CancellationToken cancellationToken = default); Task GetItemCountAsync(long id, string environment, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Repositories/ISettingRevisionRepository.cs b/Source/Starfish.Service/Domain/Repositories/IConfigurationRevisionRepository.cs similarity index 50% rename from Source/Starfish.Service/Domain/Repositories/ISettingRevisionRepository.cs rename to Source/Starfish.Service/Domain/Repositories/IConfigurationRevisionRepository.cs index 9825697..370a52d 100644 --- a/Source/Starfish.Service/Domain/Repositories/ISettingRevisionRepository.cs +++ b/Source/Starfish.Service/Domain/Repositories/IConfigurationRevisionRepository.cs @@ -3,6 +3,6 @@ namespace Nerosoft.Starfish.Domain; -public interface ISettingRevisionRepository : IBaseRepository +public interface IConfigurationRevisionRepository : IBaseRepository { } \ No newline at end of file diff --git a/Source/Starfish.Service/Domain/Repositories/ISettingArchiveRepository.cs b/Source/Starfish.Service/Domain/Repositories/ISettingArchiveRepository.cs deleted file mode 100644 index 3732641..0000000 --- a/Source/Starfish.Service/Domain/Repositories/ISettingArchiveRepository.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Nerosoft.Starfish.Repository; -using Nerosoft.Starfish.Service; - -namespace Nerosoft.Starfish.Domain; - -public interface ISettingArchiveRepository : IBaseRepository -{ - Task GetAsync(long appId, string environment, 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 226887b..c3d7702 100644 --- a/Source/Starfish.Service/Properties/Resources.resx +++ b/Source/Starfish.Service/Properties/Resources.resx @@ -144,13 +144,13 @@ Enabled - + Disabled - + Pending - + Published @@ -192,31 +192,31 @@ Refresh_token is required. - + Data format '{0}' is not supported. - + Data format required. - + Setting was disabled, [App]:{0}, [Env]:{1}. - + Setting was duplicated, [App]:{0}, [Env]:{1}. - + Setting key '{0}' exists. - + Setting key '{0}' not exists. - + Setting not exists, [App]:{0}, [Env]:{1}. - + No pending item to publish. - + Version number '{0}' already exists. @@ -294,16 +294,16 @@ User authenticate successfully. - + Create setting, [App]:{0}, [Env]:{1}. - + Delete setting, [App]:{0}, [Env]:{1}. - + Publish setting, [App]:{0}, [Env]:{1}. - + Update setting, [App]:{0}, [Env]:{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 ff081b8..f09c876 100644 --- a/Source/Starfish.Service/Properties/Resources.zh-Hans.resx +++ b/Source/Starfish.Service/Properties/Resources.zh-Hans.resx @@ -144,13 +144,13 @@ 启用 - + 禁用 - + 待发布 - + 已发布 @@ -192,31 +192,31 @@ Token不能为空。 - + 不支持的数据格式 '{0}'。 - + 数据格式不能为空。 - + 配置已被禁用,[应用]:{0},[环境]:{1}。 - + 配置重复,[应用]:{0},[环境]:{1}。 - + 配置项 '{0}' 已经存在。 - + 配置项 '{0}' 不存在。 - + 配置不存在,[应用]:{0},[环境]:{1}。 - + 没有待发布的配置。 - + 版本号 '{0}' 已经存在。 @@ -294,16 +294,16 @@ 用户认证成功。 - + 新增配置,[应用]:{0},[环境]:{1}。 - + 删除配置,[应用]:{0},[环境]:{1}。 - + 发布配置,[应用]:{0},[环境]:{1}。 - + 更新配置,[应用]:{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 2dd7315..c7f2acf 100644 --- a/Source/Starfish.Service/Properties/Resources.zh-Hant.resx +++ b/Source/Starfish.Service/Properties/Resources.zh-Hant.resx @@ -124,13 +124,13 @@ 啟用 - + 停用 - + 待發表 - + 已發表 @@ -172,31 +172,31 @@ 刷新令牌不能為空。 - + 不支援資料格式“{0}”。 - + 資料格式不能為空。 - + 設置已停用,[應用程式]:{0},[環境]:{1}。 - + 設置重複,[應用程式]:{0},[環境]:{1}。 - + 設置項目“{0}”已經存在。 - + 設置項目“{0}”不存在。 - + 設定不存在,[應用程式]:{0},[環境]:{1}。 - + 沒有待發布的設定。 - + 版本號碼“{0}”已存在。 @@ -274,16 +274,16 @@ 用戶身份驗證成功。 - + 建立設置,[應用程式]:{0},[環境]:{1}。 - + 刪除設置,[應用程式]:{0},[環境]:{1}。 - + 發佈設置,[應用程式]:{0},[環境]:{1}。 - + 更新設置,[應用程式]:{0},[環境]:{1}。 \ No newline at end of file diff --git a/Source/Starfish.Service/Repository/Contexts/InMemoryModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/InMemoryModelBuilder.cs index 46d663a..e47a189 100644 --- a/Source/Starfish.Service/Repository/Contexts/InMemoryModelBuilder.cs +++ b/Source/Starfish.Service/Repository/Contexts/InMemoryModelBuilder.cs @@ -80,14 +80,14 @@ public void Configure(ModelBuilder modelBuilder) .HasValueGenerator(); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId); entity.HasIndex(t => t.Environment); - entity.HasIndex([nameof(Setting.AppId), nameof(Setting.Environment)], "IDX_SETTING_UNIQUE") + entity.HasIndex([nameof(Configuration.AppId), nameof(Configuration.Environment)], "IDX_CONFIG_UNIQUE") .IsUnique(); entity.Property(t => t.Id) @@ -101,59 +101,59 @@ public void Configure(ModelBuilder modelBuilder) entity.HasMany(t => t.Items) .WithOne() - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); entity.HasMany(t => t.Revisions) .WithOne() - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting_item"); entity.HasKey(t => t.Id); - entity.HasIndex(t => t.SettingId); + entity.HasIndex(t => t.ConfigurationId); entity.HasIndex(t => t.Key); - entity.HasIndex([nameof(SettingItem.SettingId), nameof(SettingItem.Key)], "IDX_SETTING_ITEM_UNIQUE") + entity.HasIndex([nameof(ConfigurationItem.ConfigurationId), nameof(ConfigurationItem.Key)], "IDX_CONFIG_ITEM_UNIQUE") .IsUnique(); entity.Property(t => t.Id) .IsRequired() .HasValueGenerator(); - entity.HasOne(t => t.Setting) + entity.HasOne(t => t.Configuration) .WithMany(t => t.Items) - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting_revision"); entity.HasKey(t => t.Id); - entity.HasIndex(t => t.SettingId); + entity.HasIndex(t => t.ConfigurationId); entity.Property(t => t.Id) .IsRequired() .HasValueGenerator(); - entity.HasOne(t => t.Setting) + entity.HasOne(t => t.Configuration) .WithMany(t => t.Revisions) - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting_archive"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId) - .HasDatabaseName("IDX_SETTING_ARCHIVE_APP_ID"); - entity.HasIndex([nameof(SettingArchive.AppId), nameof(SettingArchive.Environment)], "IDX_SETTING_ARCHIVE_UNIQUE") + .HasDatabaseName("IDX_CONFIG_ARCHIVE_APP_ID"); + entity.HasIndex([nameof(ConfigurationArchive.AppId), nameof(ConfigurationArchive.Environment)], "IDX_CONFIG_ARCHIVE_UNIQUE") .IsUnique(); entity.Property(t => t.Id) diff --git a/Source/Starfish.Service/Repository/Contexts/MssqlModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/MssqlModelBuilder.cs index 3c3b15e..13d8e5a 100644 --- a/Source/Starfish.Service/Repository/Contexts/MssqlModelBuilder.cs +++ b/Source/Starfish.Service/Repository/Contexts/MssqlModelBuilder.cs @@ -76,14 +76,14 @@ public void Configure(ModelBuilder modelBuilder) .HasValueGenerator(); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId); entity.HasIndex(t => t.Environment); - entity.HasIndex([nameof(Setting.AppId), nameof(Setting.Environment)], "IDX_SETTING_UNIQUE") + entity.HasIndex([nameof(Configuration.AppId), nameof(Configuration.Environment)], "IDX_CONFIG_UNIQUE") .IsUnique(); entity.Property(t => t.Id) @@ -97,59 +97,59 @@ public void Configure(ModelBuilder modelBuilder) entity.HasMany(t => t.Items) .WithOne() - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); entity.HasMany(t => t.Revisions) .WithOne() - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting_item"); entity.HasKey(t => t.Id); - entity.HasIndex(t => t.SettingId); + entity.HasIndex(t => t.ConfigurationId); entity.HasIndex(t => t.Key); - entity.HasIndex([nameof(SettingItem.SettingId), nameof(SettingItem.Key)], "IDX_SETTING_ITEM_UNIQUE") + entity.HasIndex([nameof(ConfigurationItem.ConfigurationId), nameof(ConfigurationItem.Key)], "IDX_CONFIG_ITEM_UNIQUE") .IsUnique(); entity.Property(t => t.Id) .IsRequired() .HasValueGenerator(); - entity.HasOne(t => t.Setting) + entity.HasOne(t => t.Configuration) .WithMany(t => t.Items) - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting_revision"); entity.HasKey(t => t.Id); - entity.HasIndex(t => t.SettingId); + entity.HasIndex(t => t.ConfigurationId); entity.Property(t => t.Id) .IsRequired() .HasValueGenerator(); - entity.HasOne(t => t.Setting) + entity.HasOne(t => t.Configuration) .WithMany(t => t.Revisions) - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting_archive"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId) - .HasDatabaseName("IDX_SETTING_ARCHIVE_APP_ID"); - entity.HasIndex([nameof(SettingArchive.AppId), nameof(SettingArchive.Environment)], "IDX_SETTING_ARCHIVE_UNIQUE") + .HasDatabaseName("IDX_CONFIG_ARCHIVE_APP_ID"); + entity.HasIndex([nameof(ConfigurationArchive.AppId), nameof(ConfigurationArchive.Environment)], "IDX_CONFIG_ARCHIVE_UNIQUE") .IsUnique(); entity.Property(t => t.Id) diff --git a/Source/Starfish.Service/Repository/Contexts/MysqlModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/MysqlModelBuilder.cs index d03c984..8decc77 100644 --- a/Source/Starfish.Service/Repository/Contexts/MysqlModelBuilder.cs +++ b/Source/Starfish.Service/Repository/Contexts/MysqlModelBuilder.cs @@ -76,14 +76,14 @@ public void Configure(ModelBuilder modelBuilder) .HasValueGenerator(); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId); entity.HasIndex(t => t.Environment); - entity.HasIndex([nameof(Setting.AppId), nameof(Setting.Environment)], "IDX_SETTING_UNIQUE") + entity.HasIndex([nameof(Configuration.AppId), nameof(Configuration.Environment)], "IDX_CONFIG_UNIQUE") .IsUnique(); entity.Property(t => t.Id) @@ -97,59 +97,59 @@ public void Configure(ModelBuilder modelBuilder) entity.HasMany(t => t.Items) .WithOne() - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); entity.HasMany(t => t.Revisions) .WithOne() - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting_item"); entity.HasKey(t => t.Id); - entity.HasIndex(t => t.SettingId); + entity.HasIndex(t => t.ConfigurationId); entity.HasIndex(t => t.Key); - entity.HasIndex([nameof(SettingItem.SettingId), nameof(SettingItem.Key)], "IDX_SETTING_ITEM_UNIQUE") + entity.HasIndex([nameof(ConfigurationItem.ConfigurationId), nameof(ConfigurationItem.Key)], "IDX_CONFIG_ITEM_UNIQUE") .IsUnique(); entity.Property(t => t.Id) .IsRequired() .HasValueGenerator(); - entity.HasOne(t => t.Setting) + entity.HasOne(t => t.Configuration) .WithMany(t => t.Items) - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting_revision"); entity.HasKey(t => t.Id); - entity.HasIndex(t => t.SettingId); + entity.HasIndex(t => t.ConfigurationId); entity.Property(t => t.Id) .IsRequired() .HasValueGenerator(); - entity.HasOne(t => t.Setting) + entity.HasOne(t => t.Configuration) .WithMany(t => t.Revisions) - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting_archive"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId) - .HasDatabaseName("IDX_SETTING_ARCHIVE_APP_ID"); - entity.HasIndex([nameof(SettingArchive.AppId), nameof(SettingArchive.Environment)], "IDX_SETTING_ARCHIVE_UNIQUE") + .HasDatabaseName("IDX_CONFIG_ARCHIVE_APP_ID"); + entity.HasIndex([nameof(ConfigurationArchive.AppId), nameof(ConfigurationArchive.Environment)], "IDX_CONFIG_ARCHIVE_UNIQUE") .IsUnique(); entity.Property(t => t.Id) diff --git a/Source/Starfish.Service/Repository/Contexts/PgsqlModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/PgsqlModelBuilder.cs index 23d5213..1c5bb84 100644 --- a/Source/Starfish.Service/Repository/Contexts/PgsqlModelBuilder.cs +++ b/Source/Starfish.Service/Repository/Contexts/PgsqlModelBuilder.cs @@ -76,14 +76,14 @@ public void Configure(ModelBuilder modelBuilder) .HasValueGenerator(); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId); entity.HasIndex(t => t.Environment); - entity.HasIndex([nameof(Setting.AppId), nameof(Setting.Environment)], "IDX_SETTING_UNIQUE") + entity.HasIndex([nameof(Configuration.AppId), nameof(Configuration.Environment)], "IDX_CONFIG_UNIQUE") .IsUnique(); entity.Property(t => t.Id) @@ -97,59 +97,59 @@ public void Configure(ModelBuilder modelBuilder) entity.HasMany(t => t.Items) .WithOne() - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); entity.HasMany(t => t.Revisions) .WithOne() - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting_item"); entity.HasKey(t => t.Id); - entity.HasIndex(t => t.SettingId); + entity.HasIndex(t => t.ConfigurationId); entity.HasIndex(t => t.Key); - entity.HasIndex([nameof(SettingItem.SettingId), nameof(SettingItem.Key)], "IDX_SETTING_ITEM_UNIQUE") + entity.HasIndex([nameof(ConfigurationItem.ConfigurationId), nameof(ConfigurationItem.Key)], "IDX_CONFIG_ITEM_UNIQUE") .IsUnique(); entity.Property(t => t.Id) .IsRequired() .HasValueGenerator(); - entity.HasOne(t => t.Setting) + entity.HasOne(t => t.Configuration) .WithMany(t => t.Items) - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting_revision"); entity.HasKey(t => t.Id); - entity.HasIndex(t => t.SettingId); + entity.HasIndex(t => t.ConfigurationId); entity.Property(t => t.Id) .IsRequired() .HasValueGenerator(); - entity.HasOne(t => t.Setting) + entity.HasOne(t => t.Configuration) .WithMany(t => t.Revisions) - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting_archive"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId) - .HasDatabaseName("IDX_SETTING_ARCHIVE_APP_ID"); - entity.HasIndex([nameof(SettingArchive.AppId), nameof(SettingArchive.Environment)], "IDX_SETTING_ARCHIVE_UNIQUE") + .HasDatabaseName("IDX_CONFIG_ARCHIVE_APP_ID"); + entity.HasIndex([nameof(ConfigurationArchive.AppId), nameof(ConfigurationArchive.Environment)], "IDX_CONFIG_ARCHIVE_UNIQUE") .IsUnique(); entity.Property(t => t.Id) diff --git a/Source/Starfish.Service/Repository/Contexts/SqliteModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/SqliteModelBuilder.cs index d666629..916002f 100644 --- a/Source/Starfish.Service/Repository/Contexts/SqliteModelBuilder.cs +++ b/Source/Starfish.Service/Repository/Contexts/SqliteModelBuilder.cs @@ -80,14 +80,14 @@ public void Configure(ModelBuilder modelBuilder) .HasValueGenerator(); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId); entity.HasIndex(t => t.Environment); - entity.HasIndex([nameof(Setting.AppId), nameof(Setting.Environment)], "IDX_SETTING_UNIQUE") + entity.HasIndex([nameof(Configuration.AppId), nameof(Configuration.Environment)], "IDX_CONFIG_UNIQUE") .IsUnique(); entity.Property(t => t.Id) @@ -101,59 +101,59 @@ public void Configure(ModelBuilder modelBuilder) entity.HasMany(t => t.Items) .WithOne() - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); entity.HasMany(t => t.Revisions) .WithOne() - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting_item"); entity.HasKey(t => t.Id); - entity.HasIndex(t => t.SettingId); + entity.HasIndex(t => t.ConfigurationId); entity.HasIndex(t => t.Key); - entity.HasIndex([nameof(SettingItem.SettingId), nameof(SettingItem.Key)], "IDX_SETTING_ITEM_UNIQUE") + entity.HasIndex([nameof(ConfigurationItem.ConfigurationId), nameof(ConfigurationItem.Key)], "IDX_CONFIG_ITEM_UNIQUE") .IsUnique(); entity.Property(t => t.Id) .IsRequired() .HasValueGenerator(); - entity.HasOne(t => t.Setting) + entity.HasOne(t => t.Configuration) .WithMany(t => t.Items) - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting_revision"); entity.HasKey(t => t.Id); - entity.HasIndex(t => t.SettingId); + entity.HasIndex(t => t.ConfigurationId); entity.Property(t => t.Id) .IsRequired() .HasValueGenerator(); - entity.HasOne(t => t.Setting) + entity.HasOne(t => t.Configuration) .WithMany(t => t.Revisions) - .HasForeignKey(t => t.SettingId) + .HasForeignKey(t => t.ConfigurationId) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.ToTable("setting_archive"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId) - .HasDatabaseName("IDX_SETTING_ARCHIVE_APP_ID"); - entity.HasIndex([nameof(SettingArchive.AppId), nameof(SettingArchive.Environment)], "IDX_SETTING_ARCHIVE_UNIQUE") + .HasDatabaseName("IDX_CONFIG_ARCHIVE_APP_ID"); + entity.HasIndex([nameof(ConfigurationArchive.AppId), nameof(ConfigurationArchive.Environment)], "IDX_CONFIG_ARCHIVE_UNIQUE") .IsUnique(); entity.Property(t => t.Id) diff --git a/Source/Starfish.Service/Repository/CriteriaExtensions.cs b/Source/Starfish.Service/Repository/CriteriaExtensions.cs index 7a52ce9..f793762 100644 --- a/Source/Starfish.Service/Repository/CriteriaExtensions.cs +++ b/Source/Starfish.Service/Repository/CriteriaExtensions.cs @@ -91,9 +91,9 @@ public static Specification GetSpecification(this AppInfoCriteria crite /// /// /// - public static Specification GetSpecification(this SettingCriteria criteria) + public static Specification GetSpecification(this ConfigurationCriteria criteria) { - Specification specification = new TrueSpecification(); + Specification specification = new TrueSpecification(); if (criteria == null) { return specification; @@ -101,7 +101,7 @@ public static Specification GetSpecification(this SettingCriteria crite if (!string.IsNullOrWhiteSpace(criteria.Environment)) { - specification &= SettingSpecification.EnvironmentEquals(criteria.Environment); + specification &= ConfigurationSpecification.EnvironmentEquals(criteria.Environment); } return specification; diff --git a/Source/Starfish.Service/Repository/Repositories/ConfigurationArchiveRepository.cs b/Source/Starfish.Service/Repository/Repositories/ConfigurationArchiveRepository.cs new file mode 100644 index 0000000..29b597d --- /dev/null +++ b/Source/Starfish.Service/Repository/Repositories/ConfigurationArchiveRepository.cs @@ -0,0 +1,29 @@ +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(long 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 new file mode 100644 index 0000000..fbfee24 --- /dev/null +++ b/Source/Starfish.Service/Repository/Repositories/ConfigurationRepository.cs @@ -0,0 +1,75 @@ +using Microsoft.EntityFrameworkCore; +using Nerosoft.Euonia.Linq; +using Nerosoft.Euonia.Repository; +using Nerosoft.Starfish.Domain; +using Nerosoft.Starfish.Service; + +namespace Nerosoft.Starfish.Repository; + +public class ConfigurationRepository : BaseRepository, IConfigurationRepository +{ + public ConfigurationRepository(IContextProvider provider) + : base(provider) + { + } + + public Task ExistsAsync(long appId, string environment, CancellationToken cancellationToken = default) + { + ISpecification[] specifications = + [ + ConfigurationSpecification.AppIdEquals(appId), + ConfigurationSpecification.EnvironmentEquals(environment) + ]; + + var predicate = new CompositeSpecification(PredicateOperator.AndAlso, specifications).Satisfy(); + return AnyAsync(predicate, null, cancellationToken); + } + + public Task GetAsync(long appId, string environment, bool tracking, string[] properties, 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); + } + + public Task> GetItemListAsync(long id, string environment, int skip, int count, CancellationToken cancellationToken = default) + { + ISpecification[] specifications = + [ + ConfigurationSpecification.ConfigurationAppIdEquals(id), + ConfigurationSpecification.ConfigurationAppEnvironmentEquals(environment) + ]; + + var predicate = new CompositeSpecification(PredicateOperator.AndAlso, specifications).Satisfy(); + + var query = Context.Set() + .AsQueryable() + .Include(t => t.Configuration); + return query.Where(predicate) + .Skip(skip) + .Take(count) + .ToListAsync(cancellationToken); + } + + public Task GetItemCountAsync(long id, string environment, CancellationToken cancellationToken = default) + { + ISpecification[] specifications = + [ + ConfigurationSpecification.ConfigurationAppIdEquals(id), + ConfigurationSpecification.ConfigurationAppEnvironmentEquals(environment) + ]; + + var predicate = new CompositeSpecification(PredicateOperator.AndAlso, specifications).Satisfy(); + + 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 new file mode 100644 index 0000000..074d822 --- /dev/null +++ b/Source/Starfish.Service/Repository/Repositories/ConfigurationRevisionRepository.cs @@ -0,0 +1,13 @@ +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/SettingArchiveRepository.cs b/Source/Starfish.Service/Repository/Repositories/SettingArchiveRepository.cs deleted file mode 100644 index 4151a31..0000000 --- a/Source/Starfish.Service/Repository/Repositories/SettingArchiveRepository.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 SettingArchiveRepository : BaseRepository, ISettingArchiveRepository -{ - public SettingArchiveRepository(IContextProvider provider) - : base(provider) - { - } - - public Task GetAsync(long appId, string environment, CancellationToken cancellationToken = default) - { - ISpecification[] specs = - [ - SettingArchiveSpecification.AppIdEquals(appId), - SettingArchiveSpecification.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/SettingRepository.cs b/Source/Starfish.Service/Repository/Repositories/SettingRepository.cs deleted file mode 100644 index 7a3797d..0000000 --- a/Source/Starfish.Service/Repository/Repositories/SettingRepository.cs +++ /dev/null @@ -1,75 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Nerosoft.Euonia.Linq; -using Nerosoft.Euonia.Repository; -using Nerosoft.Starfish.Domain; -using Nerosoft.Starfish.Service; - -namespace Nerosoft.Starfish.Repository; - -public class SettingRepository : BaseRepository, ISettingRepository -{ - public SettingRepository(IContextProvider provider) - : base(provider) - { - } - - public Task ExistsAsync(long appId, string environment, CancellationToken cancellationToken = default) - { - ISpecification[] specifications = - [ - SettingSpecification.AppIdEquals(appId), - SettingSpecification.EnvironmentEquals(environment) - ]; - - var predicate = new CompositeSpecification(PredicateOperator.AndAlso, specifications).Satisfy(); - return AnyAsync(predicate, null, cancellationToken); - } - - public Task GetAsync(long appId, string environment, bool tracking, string[] properties, CancellationToken cancellationToken = default) - { - ISpecification[] specifications = - [ - SettingSpecification.AppIdEquals(appId), - SettingSpecification.EnvironmentEquals(environment) - ]; - - var predicate = new CompositeSpecification(PredicateOperator.AndAlso, specifications).Satisfy(); - - return GetAsync(predicate, tracking, properties, cancellationToken); - } - - public Task> GetItemListAsync(long id, string environment, int skip, int count, CancellationToken cancellationToken = default) - { - ISpecification[] specifications = - [ - SettingSpecification.SettingAppIdEquals(id), - SettingSpecification.SettingAppEnvironmentEquals(environment) - ]; - - var predicate = new CompositeSpecification(PredicateOperator.AndAlso, specifications).Satisfy(); - - var query = Context.Set() - .AsQueryable() - .Include(t => t.Setting); - return query.Where(predicate) - .Skip(skip) - .Take(count) - .ToListAsync(cancellationToken); - } - - public Task GetItemCountAsync(long id, string environment, CancellationToken cancellationToken = default) - { - ISpecification[] specifications = - [ - SettingSpecification.SettingAppIdEquals(id), - SettingSpecification.SettingAppEnvironmentEquals(environment) - ]; - - var predicate = new CompositeSpecification(PredicateOperator.AndAlso, specifications).Satisfy(); - - var query = Context.Set() - .AsQueryable() - .Include(t => t.Setting); - return query.Where(predicate).CountAsync(cancellationToken); - } -} \ No newline at end of file diff --git a/Source/Starfish.Service/Repository/Repositories/SettingRevisionRepository.cs b/Source/Starfish.Service/Repository/Repositories/SettingRevisionRepository.cs deleted file mode 100644 index 1001f98..0000000 --- a/Source/Starfish.Service/Repository/Repositories/SettingRevisionRepository.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 SettingRevisionRepository : BaseRepository, ISettingRevisionRepository -{ - public SettingRevisionRepository(IContextProvider provider) - : base(provider) - { - } -} \ No newline at end of file diff --git a/Source/Starfish.Service/Repository/RepositoryModule.cs b/Source/Starfish.Service/Repository/RepositoryModule.cs index e78f1f1..424cc98 100644 --- a/Source/Starfish.Service/Repository/RepositoryModule.cs +++ b/Source/Starfish.Service/Repository/RepositoryModule.cs @@ -123,8 +123,8 @@ public override void ConfigureServices(ServiceConfigurationContext context) .AddScoped() .AddScoped() .AddScoped() - .AddScoped() - .AddScoped() - .AddScoped(); + .AddScoped() + .AddScoped() + .AddScoped(); } } \ No newline at end of file diff --git a/Source/Starfish.Service/Repository/Specifications/ConfigurationArchiveSpecification.cs b/Source/Starfish.Service/Repository/Specifications/ConfigurationArchiveSpecification.cs new file mode 100644 index 0000000..eb7ca86 --- /dev/null +++ b/Source/Starfish.Service/Repository/Specifications/ConfigurationArchiveSpecification.cs @@ -0,0 +1,18 @@ +using Nerosoft.Euonia.Linq; +using Nerosoft.Starfish.Domain; + +namespace Nerosoft.Starfish.Repository; + +public static class ConfigurationArchiveSpecification +{ + public static Specification AppIdEquals(long appId) + { + return new DirectSpecification(x => x.AppId == appId); + } + + public static Specification EnvironmentEquals(string environment) + { + environment = environment.Normalize(TextCaseType.Upper); + return new DirectSpecification(x => x.Environment == environment); + } +} \ No newline at end of file diff --git a/Source/Starfish.Service/Repository/Specifications/ConfigurationSpecification.cs b/Source/Starfish.Service/Repository/Specifications/ConfigurationSpecification.cs new file mode 100644 index 0000000..edeb174 --- /dev/null +++ b/Source/Starfish.Service/Repository/Specifications/ConfigurationSpecification.cs @@ -0,0 +1,37 @@ +using Nerosoft.Euonia.Linq; +using Nerosoft.Starfish.Domain; + +namespace Nerosoft.Starfish.Repository; + +public static class ConfigurationSpecification +{ + public static Specification IdEquals(long id) + { + return new DirectSpecification(x => x.Id == id); + } + + public static Specification AppIdEquals(long appId) + { + return new DirectSpecification(x => x.AppId == appId); + } + + public static Specification EnvironmentEquals(string environment) + { + return new DirectSpecification(x => x.Environment == environment); + } + + public static Specification StatusEquals(ConfigurationStatus status) + { + return new DirectSpecification(x => x.Status == status); + } + + public static Specification ConfigurationAppIdEquals(long appId) + { + return new DirectSpecification(x => x.Configuration.AppId == appId); + } + + public static Specification ConfigurationAppEnvironmentEquals(string environment) + { + return new DirectSpecification(x => x.Configuration.Environment == environment); + } +} \ No newline at end of file diff --git a/Source/Starfish.Service/Repository/Specifications/SettingArchiveSpecification.cs b/Source/Starfish.Service/Repository/Specifications/SettingArchiveSpecification.cs deleted file mode 100644 index c702f73..0000000 --- a/Source/Starfish.Service/Repository/Specifications/SettingArchiveSpecification.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Nerosoft.Euonia.Linq; -using Nerosoft.Starfish.Domain; - -namespace Nerosoft.Starfish.Repository; - -public static class SettingArchiveSpecification -{ - public static Specification AppIdEquals(long appId) - { - return new DirectSpecification(x => x.AppId == appId); - } - - public static Specification EnvironmentEquals(string environment) - { - environment = environment.Normalize(TextCaseType.Upper); - return new DirectSpecification(x => x.Environment == environment); - } -} \ No newline at end of file diff --git a/Source/Starfish.Service/Repository/Specifications/SettingSpecification.cs b/Source/Starfish.Service/Repository/Specifications/SettingSpecification.cs deleted file mode 100644 index 8c7b716..0000000 --- a/Source/Starfish.Service/Repository/Specifications/SettingSpecification.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Nerosoft.Euonia.Linq; -using Nerosoft.Starfish.Domain; - -namespace Nerosoft.Starfish.Repository; - -public static class SettingSpecification -{ - public static Specification IdEquals(long id) - { - return new DirectSpecification(x => x.Id == id); - } - - public static Specification AppIdEquals(long appId) - { - return new DirectSpecification(x => x.AppId == appId); - } - - public static Specification EnvironmentEquals(string environment) - { - return new DirectSpecification(x => x.Environment == environment); - } - - public static Specification StatusEquals(SettingStatus status) - { - return new DirectSpecification(x => x.Status == status); - } - - public static Specification SettingAppIdEquals(long appId) - { - return new DirectSpecification(x => x.Setting.AppId == appId); - } - - public static Specification SettingAppEnvironmentEquals(string environment) - { - return new DirectSpecification(x => x.Setting.Environment == environment); - } -} \ No newline at end of file diff --git a/Source/Starfish.Service/UseCases/Setting/SettingCreateUseCase.cs b/Source/Starfish.Service/UseCases/Configuration/ConfigurationCreateUseCase.cs similarity index 52% rename from Source/Starfish.Service/UseCases/Setting/SettingCreateUseCase.cs rename to Source/Starfish.Service/UseCases/Configuration/ConfigurationCreateUseCase.cs index 937b08b..9faa19a 100644 --- a/Source/Starfish.Service/UseCases/Setting/SettingCreateUseCase.cs +++ b/Source/Starfish.Service/UseCases/Configuration/ConfigurationCreateUseCase.cs @@ -6,40 +6,40 @@ namespace Nerosoft.Starfish.UseCases; -public interface ISettingCreateUseCase : IUseCase; +public interface IConfigurationCreateUseCase : IUseCase; -public record SettingCreateInput(long AppId, string Environment, string Format, SettingEditDto Data) : IUseCaseInput; +public record ConfigurationCreateInput(long AppId, string Environment, string Format, ConfigurationEditDto Data) : IUseCaseInput; -public class SettingCreateUseCase : ISettingCreateUseCase +public class ConfigurationCreateUseCase : IConfigurationCreateUseCase { private readonly IBus _bus; private readonly IServiceProvider _provider; - public SettingCreateUseCase(IBus bus, IServiceProvider provider) + public ConfigurationCreateUseCase(IBus bus, IServiceProvider provider) { _bus = bus; _provider = provider; } - public Task ExecuteAsync(SettingCreateInput input, CancellationToken cancellationToken = default) + public Task ExecuteAsync(ConfigurationCreateInput input, CancellationToken cancellationToken = default) { var format = input.Format?.Normalize(TextCaseType.Lower).Trim(TextTrimType.All); var parserName = format switch { "plain/text" => "text", "plain/json" => "json", - "" => throw new ArgumentNullException(Resources.IDS_ERROR_SETTING_DATA_FORMAT_REQUIRED), - null => throw new ArgumentNullException(Resources.IDS_ERROR_SETTING_DATA_FORMAT_REQUIRED), - _ => throw new InvalidOperationException(Resources.IDS_ERROR_SETTING_DATA_FORMAT_NOT_SUPPORTED) + "" => throw new ArgumentNullException(Resources.IDS_ERROR_CONFIG_DATA_FORMAT_REQUIRED), + null => throw new ArgumentNullException(Resources.IDS_ERROR_CONFIG_DATA_FORMAT_REQUIRED), + _ => throw new InvalidOperationException(Resources.IDS_ERROR_CONFIG_DATA_FORMAT_NOT_SUPPORTED) }; var parser = _provider.GetKeyedService(parserName); var data = Cryptography.Base64.Decrypt(input.Data.Data); - var command = new SettingCreateCommand(input.AppId, input.Environment) + var command = new ConfigurationCreateCommand(input.AppId, input.Environment) { Data = parser.Parse(data) }; - return _bus.SendAsync(command, cancellationToken) + return _bus.SendAsync(command, cancellationToken) .ContinueWith(task => { task.WaitAndUnwrapException(cancellationToken); diff --git a/Source/Starfish.Service/UseCases/Setting/SettingDeleteUseCase.cs b/Source/Starfish.Service/UseCases/Configuration/ConfigurationDeleteUseCase.cs similarity index 51% rename from Source/Starfish.Service/UseCases/Setting/SettingDeleteUseCase.cs rename to Source/Starfish.Service/UseCases/Configuration/ConfigurationDeleteUseCase.cs index 75a9137..aebc157 100644 --- a/Source/Starfish.Service/UseCases/Setting/SettingDeleteUseCase.cs +++ b/Source/Starfish.Service/UseCases/Configuration/ConfigurationDeleteUseCase.cs @@ -7,30 +7,30 @@ namespace Nerosoft.Starfish.UseCases; /// /// 删除配置节点用例接口 /// -public interface ISettingDeleteUseCase : INonOutputUseCase; +public interface IConfigurationDeleteUseCase : INonOutputUseCase; /// /// 删除配置节点输入 /// /// /// -public record SettingDeleteInput(long AppId, string Environment) : IUseCaseInput; +public record ConfigurationDeleteInput(long AppId, string Environment) : IUseCaseInput; /// /// 删除配置节点用例 /// -public class SettingDeleteUseCase : ISettingDeleteUseCase +public class ConfigurationDeleteUseCase : IConfigurationDeleteUseCase { private readonly IBus _bus; - public SettingDeleteUseCase(IBus bus) + public ConfigurationDeleteUseCase(IBus bus) { _bus = bus; } - public Task ExecuteAsync(SettingDeleteInput input, CancellationToken cancellationToken = default) + public Task ExecuteAsync(ConfigurationDeleteInput input, CancellationToken cancellationToken = default) { - var command = new SettingDeleteCommand(input.AppId, input.Environment); + var command = new ConfigurationDeleteCommand(input.AppId, input.Environment); return _bus.SendAsync(command, cancellationToken); } } \ No newline at end of file diff --git a/Source/Starfish.Service/UseCases/Setting/SettingPublishUseCase.cs b/Source/Starfish.Service/UseCases/Configuration/ConfigurationPublishUseCase.cs similarity index 53% rename from Source/Starfish.Service/UseCases/Setting/SettingPublishUseCase.cs rename to Source/Starfish.Service/UseCases/Configuration/ConfigurationPublishUseCase.cs index 0f1d50e..71cc987 100644 --- a/Source/Starfish.Service/UseCases/Setting/SettingPublishUseCase.cs +++ b/Source/Starfish.Service/UseCases/Configuration/ConfigurationPublishUseCase.cs @@ -8,7 +8,7 @@ namespace Nerosoft.Starfish.UseCases; /// /// 配置节点发布用例接口 /// -public interface ISettingPublishUseCase : INonOutputUseCase; +public interface IConfigurationPublishUseCase : INonOutputUseCase; /// /// 配置节点发布输入 @@ -16,26 +16,26 @@ public interface ISettingPublishUseCase : INonOutputUseCase /// /// /// -public record SettingPublishInput(long AppId, string Environment, SettingPublishDto Data) : IUseCaseInput; +public record ConfigurationPublishInput(long AppId, string Environment, ConfigurationPublishDto Data) : IUseCaseInput; /// /// 配置节点发布用例 /// -public class SettingPublishUseCase : ISettingPublishUseCase +public class ConfigurationPublishUseCase : IConfigurationPublishUseCase { private readonly IBus _bus; - public SettingPublishUseCase(IBus bus) + public ConfigurationPublishUseCase(IBus bus) { _bus = bus; } - public async Task ExecuteAsync(SettingPublishInput input, CancellationToken cancellationToken = default) + public async Task ExecuteAsync(ConfigurationPublishInput input, CancellationToken cancellationToken = default) { - var command = new SettingPublishCommand(input.AppId, input.Environment); + var command = new ConfigurationPublishCommand(input.AppId, input.Environment); await _bus.SendAsync(command, cancellationToken); - var @event = new SettingPublishedEvent(input.AppId, input.Environment) + var @event = new ConfigurationPublishedEvent(input.AppId, input.Environment) { Version = input.Data.Version, Comment = input.Data.Comment diff --git a/Source/Starfish.Service/UseCases/Setting/SettingUpdateUseCase.cs b/Source/Starfish.Service/UseCases/Configuration/ConfigurationUpdateUseCase.cs similarity index 56% rename from Source/Starfish.Service/UseCases/Setting/SettingUpdateUseCase.cs rename to Source/Starfish.Service/UseCases/Configuration/ConfigurationUpdateUseCase.cs index 55ec5ff..8595a88 100644 --- a/Source/Starfish.Service/UseCases/Setting/SettingUpdateUseCase.cs +++ b/Source/Starfish.Service/UseCases/Configuration/ConfigurationUpdateUseCase.cs @@ -6,36 +6,36 @@ namespace Nerosoft.Starfish.UseCases; -public interface ISettingUpdateUseCase : INonOutputUseCase; +public interface IConfigurationUpdateUseCase : INonOutputUseCase; -public record SettingUpdateInput(long AppId, string Environment, string Format, SettingEditDto Data); +public record ConfigurationUpdateInput(long AppId, string Environment, string Format, ConfigurationEditDto Data); -public class SettingUpdateUseCase : ISettingUpdateUseCase +public class ConfigurationUpdateUseCase : IConfigurationUpdateUseCase { private readonly IBus _bus; private readonly IServiceProvider _provider; - public SettingUpdateUseCase(IBus bus, IServiceProvider provider) + public ConfigurationUpdateUseCase(IBus bus, IServiceProvider provider) { _bus = bus; _provider = provider; } - public Task ExecuteAsync(SettingUpdateInput input, CancellationToken cancellationToken = default) + public Task ExecuteAsync(ConfigurationUpdateInput input, CancellationToken cancellationToken = default) { var format = input.Format?.Normalize(TextCaseType.Lower).Trim(TextTrimType.All); var parserName = format switch { "plain/text" => "text", "plain/json" => "json", - "" => throw new ArgumentNullException(Resources.IDS_ERROR_SETTING_DATA_FORMAT_REQUIRED), - null => throw new ArgumentNullException(Resources.IDS_ERROR_SETTING_DATA_FORMAT_REQUIRED), - _ => throw new InvalidOperationException(Resources.IDS_ERROR_SETTING_DATA_FORMAT_NOT_SUPPORTED) + "" => throw new ArgumentNullException(Resources.IDS_ERROR_CONFIG_DATA_FORMAT_REQUIRED), + null => throw new ArgumentNullException(Resources.IDS_ERROR_CONFIG_DATA_FORMAT_REQUIRED), + _ => throw new InvalidOperationException(Resources.IDS_ERROR_CONFIG_DATA_FORMAT_NOT_SUPPORTED) }; var parser = _provider.GetKeyedService(parserName); var data = Cryptography.Base64.Decrypt(input.Data.Data); - var command = new SettingUpdateCommand(input.AppId, input.Environment) + var command = new ConfigurationUpdateCommand(input.AppId, input.Environment) { Data = parser.Parse(data) }; diff --git a/Source/Starfish.Service/UseCases/Configuration/ConfigurationValueUpdateUseCase.cs b/Source/Starfish.Service/UseCases/Configuration/ConfigurationValueUpdateUseCase.cs new file mode 100644 index 0000000..2848fdf --- /dev/null +++ b/Source/Starfish.Service/UseCases/Configuration/ConfigurationValueUpdateUseCase.cs @@ -0,0 +1,29 @@ +using Nerosoft.Euonia.Application; +using Nerosoft.Euonia.Bus; +using Nerosoft.Starfish.Application; + +namespace Nerosoft.Starfish.UseCases; + +public interface IConfigurationValueUpdateUseCase : INonOutputUseCase; + +public record ConfigurationValueUpdateInput(long AppId, string Environment, string Key, string Value) : IUseCaseInput; + +public class ConfigurationValueUpdateUseCase : IConfigurationValueUpdateUseCase +{ + private readonly IBus _bus; + + public ConfigurationValueUpdateUseCase(IBus bus) + { + _bus = bus; + } + + public Task ExecuteAsync(ConfigurationValueUpdateInput input, CancellationToken cancellationToken = default) + { + var command = new ConfigurationValueUpdateCommand(input.AppId, input.Environment, input.Key, input.Value); + return _bus.SendAsync(command, cancellationToken) + .ContinueWith(task => + { + task.WaitAndUnwrapException(cancellationToken); + }, cancellationToken); + } +} \ No newline at end of file diff --git a/Source/Starfish.Service/UseCases/Configuration/GetConfigurationDetailUseCase.cs b/Source/Starfish.Service/UseCases/Configuration/GetConfigurationDetailUseCase.cs new file mode 100644 index 0000000..4d6d441 --- /dev/null +++ b/Source/Starfish.Service/UseCases/Configuration/GetConfigurationDetailUseCase.cs @@ -0,0 +1,62 @@ +using Nerosoft.Euonia.Application; +using Nerosoft.Euonia.Linq; +using Nerosoft.Euonia.Mapping; +using Nerosoft.Starfish.Domain; +using Nerosoft.Starfish.Repository; +using Nerosoft.Starfish.Transit; + +namespace Nerosoft.Starfish.UseCases; + +/// +/// 获取配置节点详情用例接口 +/// +public interface IGetConfigurationDetailUseCase : IUseCase; + +/// +/// 获取配置节点详情用例输出 +/// +/// +public record GetConfigurationDetailOutput(ConfigurationDetailDto Result) : IUseCaseOutput; + +/// +/// 获取配置节点详情用例输入 +/// +/// +public record GetConfigurationDetailInput(long AppId, string Environment) : IUseCaseInput; + +/// +/// 获取配置节点详情用例 +/// +public class GetConfigurationDetailUseCase : IGetConfigurationDetailUseCase +{ + private readonly IConfigurationRepository _repository; + + /// + /// 构造函数 + /// + /// + public GetConfigurationDetailUseCase(IConfigurationRepository repository) + { + _repository = repository; + } + + /// + public Task ExecuteAsync(GetConfigurationDetailInput input, CancellationToken cancellationToken = default) + { + ISpecification[] specifications = + [ + ConfigurationSpecification.AppIdEquals(input.AppId), + ConfigurationSpecification.EnvironmentEquals(input.Environment) + ]; + + var predicate = new CompositeSpecification(PredicateOperator.AndAlso, specifications).Satisfy(); + + return _repository.GetAsync(predicate, false, [nameof(Configuration.App)], cancellationToken) + .ContinueWith(task => + { + task.WaitAndUnwrapException(cancellationToken); + var result = TypeAdapter.ProjectedAs(task.Result); + return new GetConfigurationDetailOutput(result); + }, cancellationToken); + } +} \ No newline at end of file diff --git a/Source/Starfish.Service/UseCases/Setting/GetSettingItemCountUseCase.cs b/Source/Starfish.Service/UseCases/Configuration/GetConfigurationItemCountUseCase.cs similarity index 50% rename from Source/Starfish.Service/UseCases/Setting/GetSettingItemCountUseCase.cs rename to Source/Starfish.Service/UseCases/Configuration/GetConfigurationItemCountUseCase.cs index 8684c14..4c72286 100644 --- a/Source/Starfish.Service/UseCases/Setting/GetSettingItemCountUseCase.cs +++ b/Source/Starfish.Service/UseCases/Configuration/GetConfigurationItemCountUseCase.cs @@ -6,41 +6,41 @@ namespace Nerosoft.Starfish.UseCases; /// /// 获取符合条件的配置数量用例接口 /// -public interface IGetSettingItemCountUseCase : IUseCase; +public interface IGetConfigurationItemCountUseCase : IUseCase; /// /// 获取符合条件的配置数量用例输出 /// /// -public record GetSettingItemCountOutput(int Result) : IUseCaseOutput; +public record GetConfigurationItemCountOutput(int Result) : IUseCaseOutput; /// /// 获取符合条件的配置数量用例输入 /// /// /// -public record GetSettingItemCountInput(long Id, string Environment) : IUseCaseInput; +public record GetConfigurationItemCountInput(long Id, string Environment) : IUseCaseInput; /// /// 获取符合条件的配置数量用例 /// -public class GetSettingItemCountUseCase : IGetSettingItemCountUseCase +public class GetConfigurationItemCountUseCase : IGetConfigurationItemCountUseCase { - private readonly ISettingRepository _repository; + private readonly IConfigurationRepository _repository; /// /// 构造函数 /// /// - public GetSettingItemCountUseCase(ISettingRepository repository) + public GetConfigurationItemCountUseCase(IConfigurationRepository repository) { _repository = repository; } /// - public Task ExecuteAsync(GetSettingItemCountInput input, CancellationToken cancellationToken = default) + public Task ExecuteAsync(GetConfigurationItemCountInput input, CancellationToken cancellationToken = default) { return _repository.GetItemCountAsync(input.Id, input.Environment, cancellationToken) - .ContinueWith(t => new GetSettingItemCountOutput(t.Result), cancellationToken); + .ContinueWith(t => new GetConfigurationItemCountOutput(t.Result), cancellationToken); } } \ No newline at end of file diff --git a/Source/Starfish.Service/UseCases/Setting/GetSettingItemListUseCase.cs b/Source/Starfish.Service/UseCases/Configuration/GetConfigurationItemListUseCase.cs similarity index 66% rename from Source/Starfish.Service/UseCases/Setting/GetSettingItemListUseCase.cs rename to Source/Starfish.Service/UseCases/Configuration/GetConfigurationItemListUseCase.cs index 5ad383a..b52c928 100644 --- a/Source/Starfish.Service/UseCases/Setting/GetSettingItemListUseCase.cs +++ b/Source/Starfish.Service/UseCases/Configuration/GetConfigurationItemListUseCase.cs @@ -9,13 +9,13 @@ namespace Nerosoft.Starfish.UseCases; /// /// 获取符合条件的配置列表用例接口 /// -public interface IGetSettingItemListUseCase : IUseCase; +public interface IGetConfigurationItemListUseCase : IUseCase; /// /// 获取符合条件的配置列表用例输出 /// /// -public record GetSettingItemListOutput(List Result) : IUseCaseOutput; +public record GetConfigurationItemListOutput(List Result) : IUseCaseOutput; /// /// 获取符合条件的配置列表用例输入 @@ -24,14 +24,14 @@ public record GetSettingItemListOutput(List Result) : IUseCaseOu /// /// /// -public record GetSettingItemListInput(long Id, string Environment, int Skip, int Count) : IUseCaseInput; +public record GetConfigurationItemListInput(long Id, string Environment, int Skip, int Count) : IUseCaseInput; /// /// 获取符合条件的配置列表用例 /// -public class GetSettingItemListUseCase : IGetSettingItemListUseCase +public class GetConfigurationItemListUseCase : IGetConfigurationItemListUseCase { - private readonly ISettingRepository _repository; + private readonly IConfigurationRepository _repository; private readonly UserPrincipal _identity; /// @@ -39,14 +39,14 @@ public class GetSettingItemListUseCase : IGetSettingItemListUseCase /// /// /// - public GetSettingItemListUseCase(ISettingRepository repository, UserPrincipal identity) + public GetConfigurationItemListUseCase(IConfigurationRepository repository, UserPrincipal identity) { _repository = repository; _identity = identity; } /// - public Task ExecuteAsync(GetSettingItemListInput input, CancellationToken cancellationToken = default) + public Task ExecuteAsync(GetConfigurationItemListInput input, CancellationToken cancellationToken = default) { if (input.Skip < 0) { @@ -67,8 +67,8 @@ public Task ExecuteAsync(GetSettingItemListInput input .ContinueWith(task => { task.WaitAndUnwrapException(cancellationToken); - var result = task.Result.ProjectedAsCollection(); - return new GetSettingItemListOutput(result); + var result = task.Result.ProjectedAsCollection(); + return new GetConfigurationItemListOutput(result); }, cancellationToken); } } \ No newline at end of file diff --git a/Source/Starfish.Service/UseCases/Configuration/GetConfigurationRawUseCase.cs b/Source/Starfish.Service/UseCases/Configuration/GetConfigurationRawUseCase.cs new file mode 100644 index 0000000..e90a720 --- /dev/null +++ b/Source/Starfish.Service/UseCases/Configuration/GetConfigurationRawUseCase.cs @@ -0,0 +1,26 @@ +using Nerosoft.Euonia.Application; +using Nerosoft.Starfish.Domain; + +namespace Nerosoft.Starfish.UseCases; + +public interface IGetConfigurationRawUseCase : IUseCase; + +public record GetConfigurationRawUseCaseOutput(string Result) : IUseCaseOutput; + +public record GetConfigurationRawInput(long AppId, string Environment) : IUseCaseInput; + +public class GetConfigurationRawUseCase : IGetConfigurationRawUseCase +{ + private readonly IConfigurationArchiveRepository _repository; + + public GetConfigurationRawUseCase(IConfigurationArchiveRepository repository) + { + _repository = repository; + } + + public Task ExecuteAsync(GetConfigurationRawInput input, CancellationToken cancellationToken = default) + { + return _repository.GetAsync(input.AppId, input.Environment, cancellationToken) + .ContinueWith(t => new GetConfigurationRawUseCaseOutput(t.Result.Data), cancellationToken); + } +} diff --git a/Source/Starfish.Service/UseCases/Setting/PushRedisUseCase.cs b/Source/Starfish.Service/UseCases/Configuration/PushRedisUseCase.cs similarity index 78% rename from Source/Starfish.Service/UseCases/Setting/PushRedisUseCase.cs rename to Source/Starfish.Service/UseCases/Configuration/PushRedisUseCase.cs index a032249..ea7bec0 100644 --- a/Source/Starfish.Service/UseCases/Setting/PushRedisUseCase.cs +++ b/Source/Starfish.Service/UseCases/Configuration/PushRedisUseCase.cs @@ -14,13 +14,13 @@ internal record PushRedisInput(long AppId, string Environment, PushRedisRequestD internal sealed class PushRedisUseCase : IPushRedisUseCase { - private readonly ISettingArchiveRepository _settingRepository; + private readonly IConfigurationArchiveRepository _configurationRepository; private readonly IAppInfoRepository _appInfoRepository; private readonly UserPrincipal _identity; - public PushRedisUseCase(ISettingArchiveRepository settingRepository, IAppInfoRepository appInfoRepository, UserPrincipal identity) + public PushRedisUseCase(IConfigurationArchiveRepository configurationRepository, IAppInfoRepository appInfoRepository, UserPrincipal identity) { - _settingRepository = settingRepository; + _configurationRepository = configurationRepository; _appInfoRepository = appInfoRepository; _identity = identity; } @@ -34,11 +34,11 @@ public async Task ExecuteAsync(PushRedisInput input, CancellationToken cancellat throw new UnauthorizedAccessException(); } - var archive = await _settingRepository.GetAsync(input.AppId, input.Environment, cancellationToken); + var archive = await _configurationRepository.GetAsync(input.AppId, input.Environment, cancellationToken); if (archive == null) { - throw new SettingNotFoundException(input.AppId, input.Environment); + throw new ConfigurationNotFoundException(input.AppId, input.Environment); } if (string.IsNullOrWhiteSpace(archive.Data)) diff --git a/Source/Starfish.Service/UseCases/Setting/GetSettingDetailUseCase.cs b/Source/Starfish.Service/UseCases/Setting/GetSettingDetailUseCase.cs deleted file mode 100644 index f28adee..0000000 --- a/Source/Starfish.Service/UseCases/Setting/GetSettingDetailUseCase.cs +++ /dev/null @@ -1,62 +0,0 @@ -using Nerosoft.Euonia.Application; -using Nerosoft.Euonia.Linq; -using Nerosoft.Euonia.Mapping; -using Nerosoft.Starfish.Domain; -using Nerosoft.Starfish.Repository; -using Nerosoft.Starfish.Transit; - -namespace Nerosoft.Starfish.UseCases; - -/// -/// 获取配置节点详情用例接口 -/// -public interface IGetSettingDetailUseCase : IUseCase; - -/// -/// 获取配置节点详情用例输出 -/// -/// -public record GetSettingDetailOutput(SettingDetailDto Result) : IUseCaseOutput; - -/// -/// 获取配置节点详情用例输入 -/// -/// -public record GetSettingDetailInput(long AppId, string Environment) : IUseCaseInput; - -/// -/// 获取配置节点详情用例 -/// -public class GetSettingDetailUseCase : IGetSettingDetailUseCase -{ - private readonly ISettingRepository _repository; - - /// - /// 构造函数 - /// - /// - public GetSettingDetailUseCase(ISettingRepository repository) - { - _repository = repository; - } - - /// - public Task ExecuteAsync(GetSettingDetailInput input, CancellationToken cancellationToken = default) - { - ISpecification[] specifications = - [ - SettingSpecification.AppIdEquals(input.AppId), - SettingSpecification.EnvironmentEquals(input.Environment) - ]; - - var predicate = new CompositeSpecification(PredicateOperator.AndAlso, specifications).Satisfy(); - - return _repository.GetAsync(predicate, false, [nameof(Setting.App)], cancellationToken) - .ContinueWith(task => - { - task.WaitAndUnwrapException(cancellationToken); - var result = TypeAdapter.ProjectedAs(task.Result); - return new GetSettingDetailOutput(result); - }, cancellationToken); - } -} \ No newline at end of file diff --git a/Source/Starfish.Service/UseCases/Setting/GetSettingRawUseCase.cs b/Source/Starfish.Service/UseCases/Setting/GetSettingRawUseCase.cs deleted file mode 100644 index 627deda..0000000 --- a/Source/Starfish.Service/UseCases/Setting/GetSettingRawUseCase.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Nerosoft.Euonia.Application; -using Nerosoft.Starfish.Domain; - -namespace Nerosoft.Starfish.UseCases; - -public interface IGetSettingRawUseCase : IUseCase; - -public record GetSettingRawUseCaseOutput(string Result) : IUseCaseOutput; - -public record GetSettingRawInput(long AppId, string Environment) : IUseCaseInput; - -public class GetSettingRawUseCase : IGetSettingRawUseCase -{ - private readonly ISettingArchiveRepository _repository; - - public GetSettingRawUseCase(ISettingArchiveRepository repository) - { - _repository = repository; - } - - public Task ExecuteAsync(GetSettingRawInput input, CancellationToken cancellationToken = default) - { - return _repository.GetAsync(input.AppId, input.Environment, cancellationToken) - .ContinueWith(t => new GetSettingRawUseCaseOutput(t.Result.Data), cancellationToken); - } -} diff --git a/Source/Starfish.Service/UseCases/Setting/SettingValueUpdateUseCase.cs b/Source/Starfish.Service/UseCases/Setting/SettingValueUpdateUseCase.cs deleted file mode 100644 index f175479..0000000 --- a/Source/Starfish.Service/UseCases/Setting/SettingValueUpdateUseCase.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Nerosoft.Euonia.Application; -using Nerosoft.Euonia.Bus; -using Nerosoft.Starfish.Application; - -namespace Nerosoft.Starfish.UseCases; - -public interface ISettingValueUpdateUseCase : INonOutputUseCase; - -public record SettingValueUpdateInput(long AppId, string Environment, string Key, string Value) : IUseCaseInput; - -public class SettingValueUpdateUseCase : ISettingValueUpdateUseCase -{ - private readonly IBus _bus; - - public SettingValueUpdateUseCase(IBus bus) - { - _bus = bus; - } - - public Task ExecuteAsync(SettingValueUpdateInput input, CancellationToken cancellationToken = default) - { - var command = new SettingValueUpdateCommand(input.AppId, input.Environment, input.Key, input.Value); - return _bus.SendAsync(command, cancellationToken) - .ContinueWith(task => - { - task.WaitAndUnwrapException(cancellationToken); - }, cancellationToken); - } -} \ No newline at end of file diff --git a/Source/Starfish.Transit/Setting/SettingCriteria.cs b/Source/Starfish.Transit/Configuration/ConfigurationCriteria.cs similarity index 91% rename from Source/Starfish.Transit/Setting/SettingCriteria.cs rename to Source/Starfish.Transit/Configuration/ConfigurationCriteria.cs index 4fe1f7e..3b69a4f 100644 --- a/Source/Starfish.Transit/Setting/SettingCriteria.cs +++ b/Source/Starfish.Transit/Configuration/ConfigurationCriteria.cs @@ -3,7 +3,7 @@ /// /// 配置节点查询条件 /// -public class SettingCriteria +public class ConfigurationCriteria { /// /// 团队Id diff --git a/Source/Starfish.Transit/Setting/SettingDetailDto.cs b/Source/Starfish.Transit/Configuration/ConfigurationDetailDto.cs similarity index 96% rename from Source/Starfish.Transit/Setting/SettingDetailDto.cs rename to Source/Starfish.Transit/Configuration/ConfigurationDetailDto.cs index cbf3485..829ace4 100644 --- a/Source/Starfish.Transit/Setting/SettingDetailDto.cs +++ b/Source/Starfish.Transit/Configuration/ConfigurationDetailDto.cs @@ -3,7 +3,7 @@ /// /// 配置详情Dto /// -public class SettingDetailDto +public class ConfigurationDetailDto { /// /// Id diff --git a/Source/Starfish.Transit/Setting/SettingEditDto.cs b/Source/Starfish.Transit/Configuration/ConfigurationEditDto.cs similarity index 88% rename from Source/Starfish.Transit/Setting/SettingEditDto.cs rename to Source/Starfish.Transit/Configuration/ConfigurationEditDto.cs index d3ddb67..946c939 100644 --- a/Source/Starfish.Transit/Setting/SettingEditDto.cs +++ b/Source/Starfish.Transit/Configuration/ConfigurationEditDto.cs @@ -3,7 +3,7 @@ /// /// 配置更新Dto /// -public class SettingEditDto +public class ConfigurationEditDto { /// /// 数据类型 diff --git a/Source/Starfish.Transit/Setting/SettingItemDto.cs b/Source/Starfish.Transit/Configuration/ConfigurationItemDto.cs similarity index 90% rename from Source/Starfish.Transit/Setting/SettingItemDto.cs rename to Source/Starfish.Transit/Configuration/ConfigurationItemDto.cs index a4d47a8..7b77524 100644 --- a/Source/Starfish.Transit/Setting/SettingItemDto.cs +++ b/Source/Starfish.Transit/Configuration/ConfigurationItemDto.cs @@ -3,7 +3,7 @@ /// /// 设置列表Dto /// -public class SettingItemDto +public class ConfigurationItemDto { /// /// Id diff --git a/Source/Starfish.Transit/Setting/SettingPublishDto.cs b/Source/Starfish.Transit/Configuration/ConfigurationPublishDto.cs similarity index 87% rename from Source/Starfish.Transit/Setting/SettingPublishDto.cs rename to Source/Starfish.Transit/Configuration/ConfigurationPublishDto.cs index b18af72..d084813 100644 --- a/Source/Starfish.Transit/Setting/SettingPublishDto.cs +++ b/Source/Starfish.Transit/Configuration/ConfigurationPublishDto.cs @@ -3,7 +3,7 @@ /// /// 配置节点发布Dto /// -public class SettingPublishDto +public class ConfigurationPublishDto { /// /// 版本号 diff --git a/Source/Starfish.Transit/Setting/SettingValueUpdateDto.cs b/Source/Starfish.Transit/Configuration/ConfigurationValueUpdateDto.cs similarity index 80% rename from Source/Starfish.Transit/Setting/SettingValueUpdateDto.cs rename to Source/Starfish.Transit/Configuration/ConfigurationValueUpdateDto.cs index 9b135f4..e071c13 100644 --- a/Source/Starfish.Transit/Setting/SettingValueUpdateDto.cs +++ b/Source/Starfish.Transit/Configuration/ConfigurationValueUpdateDto.cs @@ -3,7 +3,7 @@ /// /// 配置项更新Dto /// -public class SettingValueUpdateDto +public class ConfigurationValueUpdateDto { /// /// diff --git a/Source/Starfish.Transit/Setting/PushRedisRequestDto.cs b/Source/Starfish.Transit/Configuration/PushRedisRequestDto.cs similarity index 100% rename from Source/Starfish.Transit/Setting/PushRedisRequestDto.cs rename to Source/Starfish.Transit/Configuration/PushRedisRequestDto.cs diff --git a/Source/Starfish.Webapi/Constants.cs b/Source/Starfish.Webapi/Constants.cs index 0ca17c4..041b900 100644 --- a/Source/Starfish.Webapi/Constants.cs +++ b/Source/Starfish.Webapi/Constants.cs @@ -16,7 +16,7 @@ public static class Query public const int Count = 20; } - public static class Setting + public static class Configuration { public const string FormatJson = "plain/json"; public const string FormatText = "plain/text"; diff --git a/Source/Starfish.Webapi/Controllers/SettingController.cs b/Source/Starfish.Webapi/Controllers/ConfigurationController.cs similarity index 88% rename from Source/Starfish.Webapi/Controllers/SettingController.cs rename to Source/Starfish.Webapi/Controllers/ConfigurationController.cs index e43279c..3d46560 100644 --- a/Source/Starfish.Webapi/Controllers/SettingController.cs +++ b/Source/Starfish.Webapi/Controllers/ConfigurationController.cs @@ -10,17 +10,17 @@ namespace Nerosoft.Starfish.Webapi.Controllers; /// 应用配置管理接口 /// [Route("api/apps/{id:long}/[controller]/{environment}")] -[ApiController, ApiExplorerSettings(GroupName = "setting")] +[ApiController, ApiExplorerSettings(GroupName = "configuration")] [Authorize] -public class SettingController : ControllerBase +public class ConfigurationController : ControllerBase { - private readonly ISettingApplicationService _service; + private readonly IConfigurationApplicationService _service; /// /// 构造函数 /// /// - public SettingController(ISettingApplicationService service) + public ConfigurationController(IConfigurationApplicationService service) { _service = service; } @@ -35,15 +35,15 @@ public SettingController(ISettingApplicationService service) /// /// [HttpGet("item")] - [Produces(typeof(List))] + [Produces(typeof(List))] public async Task GetItemListAsync(long id, string environment, int skip = Constants.Query.Skip, int count = Constants.Query.Count, [FromHeader(Name = "x-format")] string format = null) { switch (format) { - case Constants.Setting.FormatText: + case Constants.Configuration.FormatText: var text = await _service.GetItemsInTextAsync(id, environment, "text", HttpContext.RequestAborted); return Ok(text); - case Constants.Setting.FormatJson: + case Constants.Configuration.FormatJson: var json = await _service.GetItemsInTextAsync(id, environment, "json", HttpContext.RequestAborted); return Ok(json); default: @@ -87,7 +87,7 @@ public async Task GetJsonAsync(long id, string environment) /// 应用环境 /// [HttpGet("detail")] - [Produces] + [Produces] public async Task GetAsync(long id, string environment) { var result = await _service.GetDetailAsync(id, environment, HttpContext.RequestAborted); @@ -103,7 +103,7 @@ public async Task GetAsync(long id, string environment) /// /// [HttpPost] - public async Task CreateAsync(long id, string environment, [FromHeader(Name = "x-format")] string format, [FromBody] SettingEditDto data) + public async Task CreateAsync(long id, string environment, [FromHeader(Name = "x-format")] string format, [FromBody] ConfigurationEditDto data) { var result = await _service.CreateAsync(id, environment, format, data, HttpContext.RequestAborted); Response.Headers.Append("Entry", $"{result}"); @@ -119,7 +119,7 @@ public async Task CreateAsync(long id, string environment, [FromH /// 数据内容 /// [HttpPut] - public async Task UpdateAsync(long id, string environment, [FromHeader(Name = "x-format")] string format, [FromBody] SettingEditDto data) + public async Task UpdateAsync(long id, string environment, [FromHeader(Name = "x-format")] string format, [FromBody] ConfigurationEditDto data) { await _service.UpdateAsync(id, environment, format, data, HttpContext.RequestAborted); return Ok(); @@ -147,7 +147,7 @@ public async Task DeleteAsync(long id, string environment) /// /// [HttpPut("{key}")] - public async Task UpdateItemValueAsync(long id, string environment, string key, [FromBody] SettingValueUpdateDto data) + public async Task UpdateItemValueAsync(long id, string environment, string key, [FromBody] ConfigurationValueUpdateDto data) { key = HttpUtility.UrlDecode(key); await _service.UpdateAsync(id, environment, key, data.Value, HttpContext.RequestAborted); @@ -162,7 +162,7 @@ public async Task UpdateItemValueAsync(long id, string environmen /// /// [HttpPost("publish")] - public async Task PublishAsync(long id, string environment, [FromBody] SettingPublishDto data) + public async Task PublishAsync(long id, string environment, [FromBody] ConfigurationPublishDto data) { await _service.PublishAsync(id, environment, data, HttpContext.RequestAborted); return Ok(); @@ -178,7 +178,7 @@ public async Task PublishAsync(long id, string environment, [From [Produces] public async Task GetArchivedAsync(long id, string environment) { - var result = await _service.GetSettingRawAsync(id, environment, HttpContext.RequestAborted); + var result = await _service.GetArchiveAsync(id, environment, HttpContext.RequestAborted); return Ok(result); } diff --git a/Source/Starfish.Webapp/Pages/Apps/Index.razor b/Source/Starfish.Webapp/Pages/Apps/Index.razor index 5a61602..8e4daa6 100644 --- a/Source/Starfish.Webapp/Pages/Apps/Index.razor +++ b/Source/Starfish.Webapp/Pages/Apps/Index.razor @@ -33,7 +33,7 @@ - + @(context.Name) @@ -110,9 +110,9 @@ return DialogService.ShowDialogAsync(id, new DialogParameters { Title = Resources.IDS_APPS_DETAIL_DIALOG_TITLE, PreventDismissOnOverlayClick = true }); } - private async Task OnGotoSettingClicked(long id) + private async Task OnGotoConfigurationClicked(long id) { - Navigation.NavigateTo($"/apps/{id}/settings"); + Navigation.NavigateTo($"/apps/{id}/configs"); await Task.CompletedTask; } diff --git a/Source/Starfish.Webapp/Pages/Setting/Edit.razor b/Source/Starfish.Webapp/Pages/Config/Edit.razor similarity index 83% rename from Source/Starfish.Webapp/Pages/Setting/Edit.razor rename to Source/Starfish.Webapp/Pages/Config/Edit.razor index 3122d64..285eb74 100644 --- a/Source/Starfish.Webapp/Pages/Setting/Edit.razor +++ b/Source/Starfish.Webapp/Pages/Config/Edit.razor @@ -1,7 +1,7 @@ @using Nerosoft.Starfish.Common @implements IDialogContentComponent -@inject ISettingApi SettingApi +@inject IConfigurationApi ConfigurationApi @@ -15,7 +15,7 @@
@@ -61,8 +61,8 @@ options.Language = Format switch { - Constants.Setting.FormatJson => "json", - Constants.Setting.FormatText => "text", + Constants.Configuration.FormatJson => "json", + Constants.Configuration.FormatText => "text", _ => options.Language }; @@ -82,15 +82,15 @@ { Loading = true; var value = await _editor.GetValue(); - var request = new SettingEditDto() + var request = new ConfigurationEditDto() { Type = "diff", Data = Cryptography.Base64.Encrypt(value) }; var task = Mode switch { - "create" => SettingApi.CreateAsync(Content.AppId, Content.Environment, Format, request).EnsureSuccess(), - "update" => SettingApi.UpdateAsync(Content.AppId, Content.Environment, Format, request).EnsureSuccess(), + "create" => ConfigurationApi.CreateAsync(Content.AppId, Content.Environment, Format, request).EnsureSuccess(), + "update" => ConfigurationApi.UpdateAsync(Content.AppId, Content.Environment, Format, request).EnsureSuccess(), _ => Task.CompletedTask }; await task; @@ -113,7 +113,7 @@ private Task LoadValueAsync() { - return SettingApi.GetItemsAsync(Content.AppId, Content.Environment, Format) + return ConfigurationApi.GetItemsAsync(Content.AppId, Content.Environment, Format) .EnsureSuccess(result=> { var value = Cryptography.Base64.Decrypt(result); diff --git a/Source/Starfish.Webapp/Pages/Setting/EditDialogArgs.cs b/Source/Starfish.Webapp/Pages/Config/EditDialogArgs.cs similarity index 83% rename from Source/Starfish.Webapp/Pages/Setting/EditDialogArgs.cs rename to Source/Starfish.Webapp/Pages/Config/EditDialogArgs.cs index 75d163c..ef312e5 100644 --- a/Source/Starfish.Webapp/Pages/Setting/EditDialogArgs.cs +++ b/Source/Starfish.Webapp/Pages/Config/EditDialogArgs.cs @@ -1,4 +1,4 @@ -namespace Nerosoft.Starfish.Webapp.Pages.Setting; +namespace Nerosoft.Starfish.Webapp.Pages.Config; public class EditDialogArgs { diff --git a/Source/Starfish.Webapp/Pages/Setting/EditValue.razor b/Source/Starfish.Webapp/Pages/Config/EditValue.razor similarity index 90% rename from Source/Starfish.Webapp/Pages/Setting/EditValue.razor rename to Source/Starfish.Webapp/Pages/Config/EditValue.razor index 84b0e0c..1ef2e2e 100644 --- a/Source/Starfish.Webapp/Pages/Setting/EditValue.razor +++ b/Source/Starfish.Webapp/Pages/Config/EditValue.razor @@ -1,6 +1,6 @@ @implements IDialogContentComponent -@inject ISettingApi SettingApi +@inject IConfigurationApi ConfigurationApi @@ -40,7 +40,7 @@ private string Key => Content?.Properties?.TryGetValue("key") as string; - private SettingValueUpdateDto Request { get; } = new(); + private ConfigurationValueUpdateDto Request { get; } = new(); protected override async Task OnInitializedAsync() { @@ -53,7 +53,7 @@ try { Loading = true; - await SettingApi.UpdateItemValueAsync(Content.AppId, Content.Environment, Key, Request) + await ConfigurationApi.UpdateItemValueAsync(Content.AppId, Content.Environment, Key, Request) .EnsureSuccess(); await Dialog.CloseAsync(Content); } diff --git a/Source/Starfish.Webapp/Pages/Setting/Index.razor b/Source/Starfish.Webapp/Pages/Config/Index.razor similarity index 71% rename from Source/Starfish.Webapp/Pages/Setting/Index.razor rename to Source/Starfish.Webapp/Pages/Config/Index.razor index 55c1d03..7c0df08 100644 --- a/Source/Starfish.Webapp/Pages/Setting/Index.razor +++ b/Source/Starfish.Webapp/Pages/Config/Index.razor @@ -1,15 +1,15 @@ -@page "/apps/{id:long}/settings" +@page "/apps/{id:long}/configs" @attribute [Authorize] @inject IDialogService DialogService -@inject ISettingApi SettingApi +@inject IConfigurationApi ConfigurationApi @inject IAppsApi AppsApi @(Resources.IDS_MENU_TEXT_HOME) @(Resources.IDS_MENU_TEXT_APPS) - @(Resources.IDS_BREADCRUMB_SETTING) + @(Resources.IDS_BREADCRUMB_CONFIG) @@ -27,14 +27,14 @@ PRD (@Resources.IDS_COMMON_ENVIRONMENT_PRD) - @(Resources.IDS_SETTING_INDEX_BUTTON_EDIT_JSON) - @(Resources.IDS_SETTING_INDEX_BUTTON_EDIT_TEXT) + @(Resources.IDS_CONFIG_INDEX_BUTTON_EDIT_JSON) + @(Resources.IDS_CONFIG_INDEX_BUTTON_EDIT_TEXT)
- - - + + + @@ -49,34 +49,34 @@
- + - @string.Format(Resources.IDS_SETTING_INDEX_PANEL_LABEL_APP_NAME, AppDetail?.Name) - @string.Format(Resources.IDS_SETTING_INDEX_PANEL_LABEL_APP_CODE, AppDetail?.Code) - @string.Format(Resources.IDS_SETTING_INDEX_PANEL_LABEL_APP_STATUS, AppDetail?.StatusDescription) + @string.Format(Resources.IDS_CONFIG_INDEX_PANEL_LABEL_APP_NAME, AppDetail?.Name) + @string.Format(Resources.IDS_CONFIG_INDEX_PANEL_LABEL_APP_CODE, AppDetail?.Code) + @string.Format(Resources.IDS_CONFIG_INDEX_PANEL_LABEL_APP_STATUS, AppDetail?.StatusDescription) @AppDetail?.Description - @if (SettingDetail != null) + @if (ConfigurationDetail != null) { - + - @string.Format(Resources.IDS_SETTING_INDEX_PANEL_LABEL_SETTING_VERSION, SettingDetail?.Version ?? "--") - @string.Format(Resources.IDS_SETTING_INDEX_PANEL_LABEL_SETTING_PUBLISH_TIME, SettingDetail?.PublishTime) - @string.Format(Resources.IDS_SETTING_INDEX_PANEL_LABEL_SETTING_UPDATE_TIME, SettingDetail?.UpdateTime) + @string.Format(Resources.IDS_CONFIG_INDEX_PANEL_LABEL_CONFIG_VERSION, ConfigurationDetail?.Version ?? "--") + @string.Format(Resources.IDS_CONFIG_INDEX_PANEL_LABEL_CONFIG_PUBLISH_TIME, ConfigurationDetail?.PublishTime) + @string.Format(Resources.IDS_CONFIG_INDEX_PANEL_LABEL_CONFIG_UPDATE_TIME, ConfigurationDetail?.UpdateTime) } - @(Resources.IDS_SETTING_INDEX_BUTTON_SYNC_REDIS) - @(Resources.IDS_SETTING_INDEX_BUTTON_DELETE) + @(Resources.IDS_CONFIG_INDEX_BUTTON_SYNC_REDIS) + @(Resources.IDS_CONFIG_INDEX_BUTTON_DELETE) - @if (SettingDetail?.Status == "Pending") + @if (ConfigurationDetail?.Status == "Pending") { - @(Resources.IDS_SETTING_INDEX_BUTTON_PUBLISH) + @(Resources.IDS_CONFIG_INDEX_BUTTON_PUBLISH) } @@ -97,13 +97,13 @@ private UserPrincipal Identity { get; set; } - private GridItemsProvider _provider; + private GridItemsProvider _provider; private PaginationState Pagination { get; } = new() { ItemsPerPage = Constants.Query.Count }; private int Total { get; set; } - private SettingDetailDto SettingDetail { get; set; } + private ConfigurationDetailDto ConfigurationDetail { get; set; } private AppInfoDetailDto AppDetail { get; set; } @@ -116,21 +116,21 @@ Identity = new UserPrincipal(user.User); await LoadAppDetailAsync(); - await LoadSettingDetailAsync(); + await LoadConfigurationDetailAsync(); _provider = async request => { - List items = null; + List items = null; var tasks = new List { - SettingApi.GetItemListAsync(Id, Environment, request.StartIndex, Pagination.ItemsPerPage, request.CancellationToken) + ConfigurationApi.GetItemListAsync(Id, Environment, request.StartIndex, Pagination.ItemsPerPage, request.CancellationToken) .EnsureSuccess(result => items = result, request.CancellationToken) }; if (request.StartIndex == 0) { tasks.Add( - SettingApi.GetItemCountAsync(Id, Environment, request.CancellationToken) + ConfigurationApi.GetItemCountAsync(Id, Environment, request.CancellationToken) .EnsureSuccess(result => Total = result, request.CancellationToken) ); } @@ -147,15 +147,15 @@ var tasks = new List { Pagination.SetCurrentPageIndexAsync(0), - LoadSettingDetailAsync() + LoadConfigurationDetailAsync() }; await Task.WhenAll(tasks).Guard(); } - private Task LoadSettingDetailAsync(CancellationToken cancellationToken = default) + private Task LoadConfigurationDetailAsync(CancellationToken cancellationToken = default) { - return SettingApi.GetAsync(Id, Environment, cancellationToken) - .EnsureSuccess(result => SettingDetail = result, cancellationToken) + return ConfigurationApi.GetAsync(Id, Environment, cancellationToken) + .EnsureSuccess(result => ConfigurationDetail = result, cancellationToken) .Guard(); } @@ -172,11 +172,11 @@ { Properties = new Dictionary { - ["mode"] = SettingDetail == null ? "create" : "update", - ["format"] = Constants.Setting.FormatJson + ["mode"] = ConfigurationDetail == null ? "create" : "update", + ["format"] = Constants.Configuration.FormatJson } }; - var title = SettingDetail == null ? Resources.IDS_SETTING_EDIT_DIALOG_TITLE_CREATE_FROM_JSON : Resources.IDS_SETTING_EDIT_DIALOG_TITLE_EDIT_AS_JSON; + var title = ConfigurationDetail == null ? Resources.IDS_CONFIG_EDIT_DIALOG_TITLE_CREATE_FROM_JSON : Resources.IDS_CONFIG_EDIT_DIALOG_TITLE_EDIT_AS_JSON; var dialog = await DialogService.ShowDialogAsync(args, new DialogParameters { Title = title, Width = "calc(100% - 2px)", Height = "calc(100% - 2px)", PreventDismissOnOverlayClick = true }); var result = await dialog.Result; @@ -192,12 +192,12 @@ { Properties = new Dictionary { - ["mode"] = SettingDetail == null ? "create" : "update", - ["format"] = Constants.Setting.FormatText + ["mode"] = ConfigurationDetail == null ? "create" : "update", + ["format"] = Constants.Configuration.FormatText } }; - var title = SettingDetail == null ? Resources.IDS_SETTING_EDIT_DIALOG_TITLE_CREATE_FROM_TEXT : Resources.IDS_SETTING_EDIT_DIALOG_TITLE_EDIT_AS_TEXT; + var title = ConfigurationDetail == null ? Resources.IDS_CONFIG_EDIT_DIALOG_TITLE_CREATE_FROM_TEXT : Resources.IDS_CONFIG_EDIT_DIALOG_TITLE_EDIT_AS_TEXT; var dialog = await DialogService.ShowDialogAsync(args, new DialogParameters { Title = title, Width = "calc(100% - 2px)", Height = "calc(100% - 2px)", PreventDismissOnOverlayClick = true }); var result = await dialog.Result; @@ -218,7 +218,7 @@ } }; - var dialog = await DialogService.ShowDialogAsync(args, new DialogParameters { Title = Resources.IDS_SETTING_EDIT_DIALOG_TITLE_EDIT_VALUE, PreventDismissOnOverlayClick = true }); + var dialog = await DialogService.ShowDialogAsync(args, new DialogParameters { Title = Resources.IDS_CONFIG_EDIT_DIALOG_TITLE_EDIT_VALUE, PreventDismissOnOverlayClick = true }); var result = await dialog.Result; if (!result.Cancelled) { @@ -229,29 +229,29 @@ private async Task OnPublishClicked() { var args = new EditDialogArgs(Id, Environment); - var dialog = await DialogService.ShowDialogAsync(args, new DialogParameters { Title = Resources.IDS_SETTING_PUBLISH_DIALOG_TITLE, PreventDismissOnOverlayClick = true }); + var dialog = await DialogService.ShowDialogAsync(args, new DialogParameters { Title = Resources.IDS_CONFIG_PUBLISH_DIALOG_TITLE, PreventDismissOnOverlayClick = true }); var result = await dialog.Result; if (!result.Cancelled) { - await LoadSettingDetailAsync(); + await LoadConfigurationDetailAsync(); } } private async Task OnSyncRedisClicked() { var args = new EditDialogArgs(Id, Environment); - await DialogService.ShowDialogAsync(args, new DialogParameters { Title = Resources.IDS_SETTING_SYNC_REDIS_DIALOG_TITLE, PreventDismissOnOverlayClick = true }); + await DialogService.ShowDialogAsync(args, new DialogParameters { Title = Resources.IDS_CONFIG_SYNC_REDIS_DIALOG_TITLE, PreventDismissOnOverlayClick = true }); } private async Task OnDeleteClicked() { - var confirmation = await DialogService.ShowConfirmationAsync(Resources.IDS_SETTING_DELETE_CONFIRM_MESSAGE, primaryText: Resources.IDS_COMMON_YES, secondaryText: Resources.IDS_COMMON_NO, title: Resources.IDS_SETTING_DELETE_CONFIRM_TITLE); + var confirmation = await DialogService.ShowConfirmationAsync(Resources.IDS_CONFIG_DELETE_CONFIRM_MESSAGE, primaryText: Resources.IDS_COMMON_YES, secondaryText: Resources.IDS_COMMON_NO, title: Resources.IDS_CONFIG_DELETE_CONFIRM_TITLE); var result = await confirmation.Result; if (!result.Cancelled) { try { - await SettingApi.DeleteAsync(Id, Environment) + await ConfigurationApi.DeleteAsync(Id, Environment) .EnsureSuccess(); await Pagination.SetCurrentPageIndexAsync(0); StateHasChanged(); diff --git a/Source/Starfish.Webapp/Pages/Setting/Publish.razor b/Source/Starfish.Webapp/Pages/Config/Publish.razor similarity index 77% rename from Source/Starfish.Webapp/Pages/Setting/Publish.razor rename to Source/Starfish.Webapp/Pages/Config/Publish.razor index e949714..6efff7b 100644 --- a/Source/Starfish.Webapp/Pages/Setting/Publish.razor +++ b/Source/Starfish.Webapp/Pages/Config/Publish.razor @@ -1,6 +1,6 @@ @implements IDialogContentComponent -@inject ISettingApi SettingApi +@inject IConfigurationApi ConfigurationApi @@ -14,17 +14,17 @@ - @(Resources.IDS_SETTING_PUBLISH_DIALOG_BUTTON_PUBLISH) + @(Resources.IDS_CONFIG_PUBLISH_DIALOG_BUTTON_PUBLISH) @(Resources.IDS_COMMON_CANCEL) @@ -38,7 +38,7 @@ private bool Loading { get; set; } - private SettingPublishDto Request { get; } = new(); + private ConfigurationPublishDto Request { get; } = new(); private async Task PublishAsync() { @@ -46,7 +46,7 @@ { Loading = true; - await SettingApi.PublishAsync(Content.AppId, Content.Environment, Request) + await ConfigurationApi.PublishAsync(Content.AppId, Content.Environment, Request) .EnsureSuccess(); await Dialog.CloseAsync(Content); diff --git a/Source/Starfish.Webapp/Pages/Setting/Revision.razor b/Source/Starfish.Webapp/Pages/Config/Revision.razor similarity index 59% rename from Source/Starfish.Webapp/Pages/Setting/Revision.razor rename to Source/Starfish.Webapp/Pages/Config/Revision.razor index 5cac8ba..adea7b8 100644 --- a/Source/Starfish.Webapp/Pages/Setting/Revision.razor +++ b/Source/Starfish.Webapp/Pages/Config/Revision.razor @@ -1,9 +1,9 @@ -@page "/apps/{appId:long}/settings/{settingId}/revision" +@page "/apps/{appId:long}/configs/{configurationId}/revision" @(Resources.IDS_MENU_TEXT_HOME) @(Resources.IDS_MENU_TEXT_APPS) - @(Resources.IDS_BREADCRUMB_SETTING) + @(Resources.IDS_BREADCRUMB_CONFIG) @code { @@ -11,5 +11,5 @@ public long AppId { get; set; } [Parameter] - public long SettingId { get; set; } + public long ConfigurationId { get; set; } } \ No newline at end of file diff --git a/Source/Starfish.Webapp/Pages/Setting/SyncRedis.razor b/Source/Starfish.Webapp/Pages/Config/SyncRedis.razor similarity index 75% rename from Source/Starfish.Webapp/Pages/Setting/SyncRedis.razor rename to Source/Starfish.Webapp/Pages/Config/SyncRedis.razor index f928103..18b468b 100644 --- a/Source/Starfish.Webapp/Pages/Setting/SyncRedis.razor +++ b/Source/Starfish.Webapp/Pages/Config/SyncRedis.razor @@ -1,7 +1,6 @@ -@using System.IO.Compression -@implements IDialogContentComponent +@implements IDialogContentComponent -@inject ISettingApi SettingApi +@inject IConfigurationApi ConfigurationApi @@ -15,21 +14,21 @@ - @(Resources.IDS_SETTING_SYNC_REDIS_DIALOG_BUTTON_START) + @(Resources.IDS_CONFIG_SYNC_REDIS_DIALOG_BUTTON_START) @(Resources.IDS_COMMON_CANCEL) @@ -51,7 +50,7 @@ { Loading = true; - await SettingApi.PushRedisAsync(Content.AppId, Content.Environment, Request) + await ConfigurationApi.PushRedisAsync(Content.AppId, Content.Environment, Request) .EnsureSuccess(); await Dialog.CloseAsync(Content); @@ -65,7 +64,6 @@ Loading = false; } } - private async Task CancelAsync() { await Dialog.CancelAsync(); diff --git a/Source/Starfish.Webapp/Properties/Resources.resx b/Source/Starfish.Webapp/Properties/Resources.resx index a9c48c4..21872ff 100644 --- a/Source/Starfish.Webapp/Properties/Resources.resx +++ b/Source/Starfish.Webapp/Properties/Resources.resx @@ -186,8 +186,8 @@ Detail - - Setting + + Configuration Detail @@ -357,100 +357,100 @@ User name - - Are you sure delete this setting? + + Are you sure delete this configuration? - - Delete setting + + Delete configuration - + Create from Json - + Create from Text - + Edit as Json - + Edit as Text - + Edit value - + Environment - + Delete - + Edit as Json - + Edit as Text - + Publish - + Sync to Redis - + Key - + Value - + App code: {0} - + App name: {0} - + App Status: {0} - + Publish: {0:yyyy-MM-dd HH:mm:ss} - + Updated: {0:yyyy-MM-dd HH:mm:ss} - + Version: {0} - + App information - - Setting information + + Configuration information - + Publish - + Comment - + Version number - - Publish setting + + Publish configuration - + Start - + Connection string - + Database - + Key name - + Sync to Redis diff --git a/Source/Starfish.Webapp/Properties/Resources.zh-Hans.resx b/Source/Starfish.Webapp/Properties/Resources.zh-Hans.resx index f5e0d2e..d9790be 100644 --- a/Source/Starfish.Webapp/Properties/Resources.zh-Hans.resx +++ b/Source/Starfish.Webapp/Properties/Resources.zh-Hans.resx @@ -186,7 +186,7 @@ 应用详情 - + 应用配置 @@ -357,100 +357,100 @@ 用户名 - + 确定要删除配置吗? - + 删除配置 - + 从Json创建 - + 从文本创建 - + 编辑Json - + 编辑文本 - + 编辑配置 - + 应用环境 - + 删除 - + 编辑Json - + 编辑文本 - + 发布配置 - + 同步到Redis - + - + - + 代码:{0} - + 名称:{0} - + 状态:{0} - + 发布:{0} - + 修改:{0} - + 版本:{0} - + 应用信息 - + 配置信息 - + 发布 - + 发布内容 - + 版本号 - + 发布配置 - + 开始同步 - + 连接字符串 - + 数据库 - + Redis键名称 - + 同步到Redis diff --git a/Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx b/Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx index 3d65962..c88ab3d 100644 --- a/Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx +++ b/Source/Starfish.Webapp/Properties/Resources.zh-Hant.resx @@ -186,7 +186,7 @@ 應用詳情 - + 應用配置 @@ -357,100 +357,100 @@ 用戶名 - + 確定要刪除配置嗎? - + 刪除配置 - + 從Json創建 - + 從文本創建 - + 編輯Json - + 編輯文字 - + 編輯配置 - + 應用環境 - + 刪除 - + 編輯Json - + 編輯文本 - + 發布配置 - + 同步到Redis - + - + - + 代碼:{0} - + 代碼:{0} - + 狀態:{0} - + 發布:{0} - + 修改:{0} - + 版本:{0} - + 應用訊息 - + 配置訊息 - + 發布 - + 發布內容 - + 版本號 - + 發佈配置 - + 開始同步 - + 連接字串 - + 數據庫 - + Redis鍵名稱 - + 同步到Redis diff --git a/Source/Starfish.Webapp/Rest/Defines/IConfigurationApi.cs b/Source/Starfish.Webapp/Rest/Defines/IConfigurationApi.cs new file mode 100644 index 0000000..33cd51a --- /dev/null +++ b/Source/Starfish.Webapp/Rest/Defines/IConfigurationApi.cs @@ -0,0 +1,41 @@ +using Nerosoft.Starfish.Transit; +using Refit; + +namespace Nerosoft.Starfish.Webapp.Rest; + +internal interface IConfigurationApi +{ + [Get("/api/apps/{id}/configuration/{environment}/item")] + [Headers("x-format: application/json")] + Task>> GetItemListAsync(long id, string environment, int skip = Constants.Query.Skip, int count = Constants.Query.Count, CancellationToken cancellationToken = default); + + [Get("/api/apps/{id}/configuration/{environment}/item/count")] + Task> GetItemCountAsync(long id, string environment, CancellationToken cancellationToken = default); + + [Get("/api/apps/{id}/configuration/{environment}/item")] + Task> GetItemsAsync(long id, string environment, [Header("x-format")] string format, CancellationToken cancellationToken = default); + + [Get("/api/apps/{id}/configuration/{environment}/detail")] + Task> GetAsync(long id, string environment, CancellationToken cancellationToken = default); + + [Post("/api/apps/{id}/configuration/{environment}")] + Task CreateAsync(long id, string environment, [Header("x-format")] string format, [Body] ConfigurationEditDto data, CancellationToken cancellationToken = default); + + [Put("/api/apps/{id}/configuration/{environment}")] + Task UpdateAsync(long id, string environment, [Header("x-format")] string format, [Body] ConfigurationEditDto data, CancellationToken cancellationToken = default); + + [Delete("/api/apps/{id}/configuration/{environment}")] + Task DeleteAsync(long id, string environment, CancellationToken cancellationToken = default); + + [Put("/api/apps/{id}/configuration/{environment}/{key}")] + Task UpdateItemValueAsync(long id, string environment, string key, [Body] ConfigurationValueUpdateDto data, CancellationToken cancellationToken = default); + + [Post("/api/apps/{id}/configuration/{environment}/publish")] + Task PublishAsync(long id, string environment, [Body] ConfigurationPublishDto data, CancellationToken cancellationToken = default); + + [Get("/api/apps/{id}/configuration/{environment}/archive")] + Task> GetArchivedAsync(long id, string environment, CancellationToken cancellationToken = default); + + [Post("/api/apps/{id}/configuration/{environment}/redis")] + Task PushRedisAsync(long id, string environment, [Body] PushRedisRequestDto data); +} \ No newline at end of file diff --git a/Source/Starfish.Webapp/Rest/Defines/ISettingApi.cs b/Source/Starfish.Webapp/Rest/Defines/ISettingApi.cs deleted file mode 100644 index a4272fd..0000000 --- a/Source/Starfish.Webapp/Rest/Defines/ISettingApi.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Nerosoft.Starfish.Transit; -using Refit; - -namespace Nerosoft.Starfish.Webapp.Rest; - -internal interface ISettingApi -{ - [Get("/api/apps/{id}/setting/{environment}/item")] - [Headers("x-format: application/json")] - Task>> GetItemListAsync(long id, string environment, int skip = Constants.Query.Skip, int count = Constants.Query.Count, CancellationToken cancellationToken = default); - - [Get("/api/apps/{id}/setting/{environment}/item/count")] - Task> GetItemCountAsync(long id, string environment, CancellationToken cancellationToken = default); - - [Get("/api/apps/{id}/setting/{environment}/item")] - Task> GetItemsAsync(long id, string environment, [Header("x-format")] string format, CancellationToken cancellationToken = default); - - [Get("/api/apps/{id}/setting/{environment}/detail")] - Task> GetAsync(long id, string environment, CancellationToken cancellationToken = default); - - [Post("/api/apps/{id}/setting/{environment}")] - Task CreateAsync(long id, string environment, [Header("x-format")] string format, [Body] SettingEditDto data, CancellationToken cancellationToken = default); - - [Put("/api/apps/{id}/setting/{environment}")] - Task UpdateAsync(long id, string environment, [Header("x-format")] string format, [Body] SettingEditDto data, CancellationToken cancellationToken = default); - - [Delete("/api/apps/{id}/setting/{environment}")] - Task DeleteAsync(long id, string environment, CancellationToken cancellationToken = default); - - [Put("/api/apps/{id}/setting/{environment}/{key}")] - Task UpdateItemValueAsync(long id, string environment, string key, [Body] SettingValueUpdateDto data, CancellationToken cancellationToken = default); - - [Post("/api/apps/{id}/setting/{environment}/publish")] - Task PublishAsync(long id, string environment, [Body] SettingPublishDto data, CancellationToken cancellationToken = default); - - [Get("/api/apps/{id}/setting/{environment}/archive")] - Task> GetArchivedAsync(long id, string environment, CancellationToken cancellationToken = default); - - [Post("/api/apps/{id}/setting/{environment}/redis")] - Task PushRedisAsync(long id, string environment, [Body] PushRedisRequestDto data); -} \ No newline at end of file diff --git a/Source/Starfish.Webapp/Rest/ServiceCollectionExtensions.cs b/Source/Starfish.Webapp/Rest/ServiceCollectionExtensions.cs index 549df2b..53c4ade 100644 --- a/Source/Starfish.Webapp/Rest/ServiceCollectionExtensions.cs +++ b/Source/Starfish.Webapp/Rest/ServiceCollectionExtensions.cs @@ -40,7 +40,7 @@ public static IServiceCollection AddHttpClientApi(this IServiceCollection servic .AddTransient(provider => provider.GetRestService(HTTP_CLIENT_NAME)) .AddTransient(provider => provider.GetRestService(HTTP_CLIENT_NAME)) .AddTransient(provider => provider.GetRestService(HTTP_CLIENT_NAME)) - .AddTransient(provider => provider.GetRestService(HTTP_CLIENT_NAME)); + .AddTransient(provider => provider.GetRestService(HTTP_CLIENT_NAME)); services.AddHttpClient(HTTP_CLIENT_NAME, (provider, client) => { diff --git a/Source/Starfish.Webapp/Seedwork/Constants.cs b/Source/Starfish.Webapp/Seedwork/Constants.cs index 00286a9..1a755a1 100644 --- a/Source/Starfish.Webapp/Seedwork/Constants.cs +++ b/Source/Starfish.Webapp/Seedwork/Constants.cs @@ -28,7 +28,7 @@ public static class Query public const int Count = 20; } - public static class Setting + public static class Configuration { public const string FormatJson = "plain/json"; public const string FormatText = "plain/text"; From a186b9e00511059f5b0c105bff1eab5e19a83e22 Mon Sep 17 00:00:00 2001 From: damon Date: Sun, 28 Jan 2024 22:55:35 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StarfishConfigurationProvider.cs | 3 +- Source/Starfish.Common/AssemblyInfo.cs | 1 + .../Constants.cs | 14 ++++++- .../ConfigurationApplicationService.cs | 1 - .../Subscribers/LoggingEventSubscriber.cs | 6 +-- .../Domain/Aggregates/AppInfo.cs | 1 - .../Domain/Aggregates/Configuration.cs | 8 ++-- .../Domain/Aggregates/User.cs | 1 - .../Domain/Business/AppInfoGeneralBusiness.cs | 3 +- .../Business/ConfigurationArchiveBusiness.cs | 1 - .../Properties/Resources.resx | 18 ++++---- .../Contexts/InMemoryModelBuilder.cs | 8 ++-- .../Repository/Contexts/MssqlModelBuilder.cs | 8 ++-- .../Repository/Contexts/MysqlModelBuilder.cs | 8 ++-- .../Repository/Contexts/PgsqlModelBuilder.cs | 8 ++-- .../Repository/Contexts/SqliteModelBuilder.cs | 8 ++-- .../Starfish.Service/Starfish.Service.csproj | 1 + .../UseCases/Apps/AppInfoAuthorizeUseCase.cs | 1 - .../ConfigurationCreateUseCase.cs | 5 +-- .../ConfigurationUpdateUseCase.cs | 1 - .../Configuration/PushRedisUseCase.cs | 1 - .../Identity/ChangePasswordUseCase.cs | 1 - .../Identity/GrantWithPasswordUseCase.cs | 1 - .../Controllers/AppsController.cs | 2 +- .../Extensions/SwaggerExtensions.cs | 2 +- Source/Starfish.Webapi/Starfish.Webapi.csproj | 1 + .../Rest/Handlers/AuthorizationHandler.cs | 2 +- Source/Starfish.Webapp/Seedwork/Constants.cs | 41 ------------------- .../Seedwork/ExceptionExtensions.cs | 2 +- .../Seedwork/ExceptionRecipient.cs | 6 +-- .../Seedwork/InternalConstants.cs | 15 +++++++ .../JwtAuthenticationStateProvider.cs | 8 ++-- .../Seedwork/TaskExtensions.cs | 6 +-- Source/Starfish.Webapp/Starfish.Webapp.csproj | 1 + 34 files changed, 85 insertions(+), 109 deletions(-) rename Source/{Starfish.Webapi => Starfish.Common}/Constants.cs (77%) delete mode 100644 Source/Starfish.Webapp/Seedwork/Constants.cs create mode 100644 Source/Starfish.Webapp/Seedwork/InternalConstants.cs diff --git a/Source/Starfish.Client/StarfishConfigurationProvider.cs b/Source/Starfish.Client/StarfishConfigurationProvider.cs index 0b302af..e120c96 100644 --- a/Source/Starfish.Client/StarfishConfigurationProvider.cs +++ b/Source/Starfish.Client/StarfishConfigurationProvider.cs @@ -1,5 +1,4 @@ -using System.IO.Compression; -using System.Text.Json; +using System.Text.Json; using Microsoft.Extensions.Configuration; using Nerosoft.Starfish.Common; diff --git a/Source/Starfish.Common/AssemblyInfo.cs b/Source/Starfish.Common/AssemblyInfo.cs index 02cc124..11a3d89 100644 --- a/Source/Starfish.Common/AssemblyInfo.cs +++ b/Source/Starfish.Common/AssemblyInfo.cs @@ -2,4 +2,5 @@ [assembly: InternalsVisibleTo("Starfish.Service")] [assembly: InternalsVisibleTo("Starfish.WebApi")] +[assembly: InternalsVisibleTo("Starfish.WebApp")] [assembly: InternalsVisibleTo("Starfish.Client")] \ No newline at end of file diff --git a/Source/Starfish.Webapi/Constants.cs b/Source/Starfish.Common/Constants.cs similarity index 77% rename from Source/Starfish.Webapi/Constants.cs rename to Source/Starfish.Common/Constants.cs index 041b900..d3b38b6 100644 --- a/Source/Starfish.Webapi/Constants.cs +++ b/Source/Starfish.Common/Constants.cs @@ -1,7 +1,19 @@ -namespace Nerosoft.Starfish.Webapi; +namespace Nerosoft.Starfish.Common; internal class Constants { + public static bool IsDebug + { + get + { +#if DEBUG + return true; +#else + return false; +#endif + } + } + public static class RequestHeaders { public const string Team = "starfish-team"; diff --git a/Source/Starfish.Service/Application/Implements/ConfigurationApplicationService.cs b/Source/Starfish.Service/Application/Implements/ConfigurationApplicationService.cs index aaf01f9..d15ea44 100644 --- a/Source/Starfish.Service/Application/Implements/ConfigurationApplicationService.cs +++ b/Source/Starfish.Service/Application/Implements/ConfigurationApplicationService.cs @@ -1,5 +1,4 @@ using Nerosoft.Euonia.Application; -using Nerosoft.Starfish.Common; using Nerosoft.Starfish.Transit; using Nerosoft.Starfish.UseCases; diff --git a/Source/Starfish.Service/Application/Subscribers/LoggingEventSubscriber.cs b/Source/Starfish.Service/Application/Subscribers/LoggingEventSubscriber.cs index c244ed8..12b9bd4 100644 --- a/Source/Starfish.Service/Application/Subscribers/LoggingEventSubscriber.cs +++ b/Source/Starfish.Service/Application/Subscribers/LoggingEventSubscriber.cs @@ -179,7 +179,7 @@ public Task HandleAsync(ConfigurationCreatedEvent @event, MessageContext context var command = new OperateLogCreateCommand { - Module = "setting", + Module = "config", Type = "create", Description = description, OperateTime = DateTime.Now, @@ -204,7 +204,7 @@ public Task HandleAsync(ConfigurationDeletedEvent @event, MessageContext context var command = new OperateLogCreateCommand { - Module = "setting", + Module = "config", Type = "delete", Description = description, OperateTime = DateTime.Now, @@ -221,7 +221,7 @@ public Task HandleAsync(ConfigurationPublishedEvent @event, MessageContext conte var command = new OperateLogCreateCommand { - Module = "setting", + Module = "config", Type = "publish", Description = description, OperateTime = DateTime.Now, diff --git a/Source/Starfish.Service/Domain/Aggregates/AppInfo.cs b/Source/Starfish.Service/Domain/Aggregates/AppInfo.cs index ec92dd8..68ea1fe 100644 --- a/Source/Starfish.Service/Domain/Aggregates/AppInfo.cs +++ b/Source/Starfish.Service/Domain/Aggregates/AppInfo.cs @@ -1,6 +1,5 @@ using System.Text.RegularExpressions; using Nerosoft.Euonia.Domain; -using Nerosoft.Starfish.Common; namespace Nerosoft.Starfish.Domain; diff --git a/Source/Starfish.Service/Domain/Aggregates/Configuration.cs b/Source/Starfish.Service/Domain/Aggregates/Configuration.cs index 37d6973..5d29beb 100644 --- a/Source/Starfish.Service/Domain/Aggregates/Configuration.cs +++ b/Source/Starfish.Service/Domain/Aggregates/Configuration.cs @@ -73,17 +73,17 @@ private Configuration() internal static Configuration Create(long appId, string environment, IDictionary items) { - var setting = new Configuration + var configuration = new Configuration { AppId = appId, Environment = environment, Status = ConfigurationStatus.Pending }; - setting.AddOrUpdateItem(items); + configuration.AddOrUpdateItem(items); - setting.RaiseEvent(new ConfigurationCreatedEvent(setting)); - return setting; + configuration.RaiseEvent(new ConfigurationCreatedEvent(configuration)); + return configuration; } internal void AddOrUpdateItem(IDictionary items) diff --git a/Source/Starfish.Service/Domain/Aggregates/User.cs b/Source/Starfish.Service/Domain/Aggregates/User.cs index c35c38b..b7a51e6 100644 --- a/Source/Starfish.Service/Domain/Aggregates/User.cs +++ b/Source/Starfish.Service/Domain/Aggregates/User.cs @@ -1,5 +1,4 @@ using Nerosoft.Euonia.Domain; -using Nerosoft.Starfish.Common; namespace Nerosoft.Starfish.Domain; diff --git a/Source/Starfish.Service/Domain/Business/AppInfoGeneralBusiness.cs b/Source/Starfish.Service/Domain/Business/AppInfoGeneralBusiness.cs index db716f6..60d6eb4 100644 --- a/Source/Starfish.Service/Domain/Business/AppInfoGeneralBusiness.cs +++ b/Source/Starfish.Service/Domain/Business/AppInfoGeneralBusiness.cs @@ -1,5 +1,4 @@ -using System.Threading; -using Nerosoft.Euonia.Business; +using Nerosoft.Euonia.Business; using Nerosoft.Euonia.Domain; using Nerosoft.Starfish.Repository; using Nerosoft.Starfish.Service; diff --git a/Source/Starfish.Service/Domain/Business/ConfigurationArchiveBusiness.cs b/Source/Starfish.Service/Domain/Business/ConfigurationArchiveBusiness.cs index 1ce2ddb..b945e8e 100644 --- a/Source/Starfish.Service/Domain/Business/ConfigurationArchiveBusiness.cs +++ b/Source/Starfish.Service/Domain/Business/ConfigurationArchiveBusiness.cs @@ -1,6 +1,5 @@ using Nerosoft.Euonia.Business; using Nerosoft.Euonia.Domain; -using Nerosoft.Starfish.Common; using Newtonsoft.Json; namespace Nerosoft.Starfish.Domain; diff --git a/Source/Starfish.Service/Properties/Resources.resx b/Source/Starfish.Service/Properties/Resources.resx index c3d7702..f60ee07 100644 --- a/Source/Starfish.Service/Properties/Resources.resx +++ b/Source/Starfish.Service/Properties/Resources.resx @@ -199,19 +199,19 @@ Data format required. - Setting was disabled, [App]:{0}, [Env]:{1}. + Configuration was disabled, [App]:{0}, [Env]:{1}. - Setting was duplicated, [App]:{0}, [Env]:{1}. + Configuration was duplicated, [App]:{0}, [Env]:{1}. - Setting key '{0}' exists. + Configuration key '{0}' exists. - Setting key '{0}' not exists. + Configuration key '{0}' not exists. - Setting not exists, [App]:{0}, [Env]:{1}. + Configuration not exists, [App]:{0}, [Env]:{1}. No pending item to publish. @@ -295,15 +295,15 @@ User authenticate successfully. - Create setting, [App]:{0}, [Env]:{1}. + Create configuration, [App]:{0}, [Env]:{1}. - Delete setting, [App]:{0}, [Env]:{1}. + Delete configuration, [App]:{0}, [Env]:{1}. - Publish setting, [App]:{0}, [Env]:{1}. + Publish configuration, [App]:{0}, [Env]:{1}. - Update setting, [App]:{0}, [Env]:{1}. + Update configuration, [App]:{0}, [Env]:{1}. \ No newline at end of file diff --git a/Source/Starfish.Service/Repository/Contexts/InMemoryModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/InMemoryModelBuilder.cs index e47a189..640f468 100644 --- a/Source/Starfish.Service/Repository/Contexts/InMemoryModelBuilder.cs +++ b/Source/Starfish.Service/Repository/Contexts/InMemoryModelBuilder.cs @@ -82,7 +82,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting"); + entity.ToTable("configuration"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId); entity.HasIndex(t => t.Environment); @@ -112,7 +112,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting_item"); + entity.ToTable("configuration_item"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.ConfigurationId); @@ -133,7 +133,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting_revision"); + entity.ToTable("configuration_revision"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.ConfigurationId); @@ -149,7 +149,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting_archive"); + entity.ToTable("configuration_archive"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId) .HasDatabaseName("IDX_CONFIG_ARCHIVE_APP_ID"); diff --git a/Source/Starfish.Service/Repository/Contexts/MssqlModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/MssqlModelBuilder.cs index 13d8e5a..4272eb0 100644 --- a/Source/Starfish.Service/Repository/Contexts/MssqlModelBuilder.cs +++ b/Source/Starfish.Service/Repository/Contexts/MssqlModelBuilder.cs @@ -78,7 +78,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting"); + entity.ToTable("configuration"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId); entity.HasIndex(t => t.Environment); @@ -108,7 +108,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting_item"); + entity.ToTable("configuration_item"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.ConfigurationId); @@ -129,7 +129,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting_revision"); + entity.ToTable("configuration_revision"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.ConfigurationId); @@ -145,7 +145,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting_archive"); + entity.ToTable("configuration_archive"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId) .HasDatabaseName("IDX_CONFIG_ARCHIVE_APP_ID"); diff --git a/Source/Starfish.Service/Repository/Contexts/MysqlModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/MysqlModelBuilder.cs index 8decc77..eb84a01 100644 --- a/Source/Starfish.Service/Repository/Contexts/MysqlModelBuilder.cs +++ b/Source/Starfish.Service/Repository/Contexts/MysqlModelBuilder.cs @@ -78,7 +78,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting"); + entity.ToTable("configuration"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId); entity.HasIndex(t => t.Environment); @@ -108,7 +108,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting_item"); + entity.ToTable("configuration_item"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.ConfigurationId); @@ -129,7 +129,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting_revision"); + entity.ToTable("configuration_revision"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.ConfigurationId); @@ -145,7 +145,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting_archive"); + entity.ToTable("configuration_archive"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId) .HasDatabaseName("IDX_CONFIG_ARCHIVE_APP_ID"); diff --git a/Source/Starfish.Service/Repository/Contexts/PgsqlModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/PgsqlModelBuilder.cs index 1c5bb84..4215071 100644 --- a/Source/Starfish.Service/Repository/Contexts/PgsqlModelBuilder.cs +++ b/Source/Starfish.Service/Repository/Contexts/PgsqlModelBuilder.cs @@ -78,7 +78,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting"); + entity.ToTable("configuration"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId); entity.HasIndex(t => t.Environment); @@ -108,7 +108,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting_item"); + entity.ToTable("configuration_item"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.ConfigurationId); @@ -129,7 +129,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting_revision"); + entity.ToTable("configuration_revision"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.ConfigurationId); @@ -145,7 +145,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting_archive"); + entity.ToTable("configuration_archive"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId) .HasDatabaseName("IDX_CONFIG_ARCHIVE_APP_ID"); diff --git a/Source/Starfish.Service/Repository/Contexts/SqliteModelBuilder.cs b/Source/Starfish.Service/Repository/Contexts/SqliteModelBuilder.cs index 916002f..7ff4bc4 100644 --- a/Source/Starfish.Service/Repository/Contexts/SqliteModelBuilder.cs +++ b/Source/Starfish.Service/Repository/Contexts/SqliteModelBuilder.cs @@ -82,7 +82,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting"); + entity.ToTable("configuration"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId); entity.HasIndex(t => t.Environment); @@ -112,7 +112,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting_item"); + entity.ToTable("configuration_item"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.ConfigurationId); @@ -133,7 +133,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting_revision"); + entity.ToTable("configuration_revision"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.ConfigurationId); @@ -149,7 +149,7 @@ public void Configure(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.ToTable("setting_archive"); + entity.ToTable("configuration_archive"); entity.HasKey(t => t.Id); entity.HasIndex(t => t.AppId) .HasDatabaseName("IDX_CONFIG_ARCHIVE_APP_ID"); diff --git a/Source/Starfish.Service/Starfish.Service.csproj b/Source/Starfish.Service/Starfish.Service.csproj index f16ef35..42a7642 100644 --- a/Source/Starfish.Service/Starfish.Service.csproj +++ b/Source/Starfish.Service/Starfish.Service.csproj @@ -56,6 +56,7 @@ + diff --git a/Source/Starfish.Service/UseCases/Apps/AppInfoAuthorizeUseCase.cs b/Source/Starfish.Service/UseCases/Apps/AppInfoAuthorizeUseCase.cs index a2e382e..9f117bf 100644 --- a/Source/Starfish.Service/UseCases/Apps/AppInfoAuthorizeUseCase.cs +++ b/Source/Starfish.Service/UseCases/Apps/AppInfoAuthorizeUseCase.cs @@ -1,5 +1,4 @@ using Nerosoft.Euonia.Application; -using Nerosoft.Starfish.Common; using Nerosoft.Starfish.Domain; namespace Nerosoft.Starfish.UseCases; diff --git a/Source/Starfish.Service/UseCases/Configuration/ConfigurationCreateUseCase.cs b/Source/Starfish.Service/UseCases/Configuration/ConfigurationCreateUseCase.cs index 9faa19a..22527a6 100644 --- a/Source/Starfish.Service/UseCases/Configuration/ConfigurationCreateUseCase.cs +++ b/Source/Starfish.Service/UseCases/Configuration/ConfigurationCreateUseCase.cs @@ -1,7 +1,6 @@ using Nerosoft.Euonia.Application; using Nerosoft.Euonia.Bus; using Nerosoft.Starfish.Application; -using Nerosoft.Starfish.Common; using Nerosoft.Starfish.Transit; namespace Nerosoft.Starfish.UseCases; @@ -26,8 +25,8 @@ public Task ExecuteAsync(ConfigurationCreateInput input, CancellationToken var format = input.Format?.Normalize(TextCaseType.Lower).Trim(TextTrimType.All); var parserName = format switch { - "plain/text" => "text", - "plain/json" => "json", + Constants.Configuration.FormatText => "text", + Constants.Configuration.FormatJson => "json", "" => throw new ArgumentNullException(Resources.IDS_ERROR_CONFIG_DATA_FORMAT_REQUIRED), null => throw new ArgumentNullException(Resources.IDS_ERROR_CONFIG_DATA_FORMAT_REQUIRED), _ => throw new InvalidOperationException(Resources.IDS_ERROR_CONFIG_DATA_FORMAT_NOT_SUPPORTED) diff --git a/Source/Starfish.Service/UseCases/Configuration/ConfigurationUpdateUseCase.cs b/Source/Starfish.Service/UseCases/Configuration/ConfigurationUpdateUseCase.cs index 8595a88..7fd715c 100644 --- a/Source/Starfish.Service/UseCases/Configuration/ConfigurationUpdateUseCase.cs +++ b/Source/Starfish.Service/UseCases/Configuration/ConfigurationUpdateUseCase.cs @@ -1,7 +1,6 @@ using Nerosoft.Euonia.Application; using Nerosoft.Euonia.Bus; using Nerosoft.Starfish.Application; -using Nerosoft.Starfish.Common; using Nerosoft.Starfish.Transit; namespace Nerosoft.Starfish.UseCases; diff --git a/Source/Starfish.Service/UseCases/Configuration/PushRedisUseCase.cs b/Source/Starfish.Service/UseCases/Configuration/PushRedisUseCase.cs index ea7bec0..7c892c4 100644 --- a/Source/Starfish.Service/UseCases/Configuration/PushRedisUseCase.cs +++ b/Source/Starfish.Service/UseCases/Configuration/PushRedisUseCase.cs @@ -1,7 +1,6 @@ using System.Text.Json; using Nerosoft.Euonia.Application; using Nerosoft.Euonia.Claims; -using Nerosoft.Starfish.Common; using Nerosoft.Starfish.Domain; using Nerosoft.Starfish.Transit; using StackExchange.Redis; diff --git a/Source/Starfish.Service/UseCases/Identity/ChangePasswordUseCase.cs b/Source/Starfish.Service/UseCases/Identity/ChangePasswordUseCase.cs index c48db36..30ea98c 100644 --- a/Source/Starfish.Service/UseCases/Identity/ChangePasswordUseCase.cs +++ b/Source/Starfish.Service/UseCases/Identity/ChangePasswordUseCase.cs @@ -3,7 +3,6 @@ using Nerosoft.Euonia.Bus; using Nerosoft.Euonia.Claims; using Nerosoft.Starfish.Application; -using Nerosoft.Starfish.Common; using Nerosoft.Starfish.Domain; namespace Nerosoft.Starfish.UseCases; diff --git a/Source/Starfish.Service/UseCases/Identity/GrantWithPasswordUseCase.cs b/Source/Starfish.Service/UseCases/Identity/GrantWithPasswordUseCase.cs index 2d68cbd..48e9c41 100644 --- a/Source/Starfish.Service/UseCases/Identity/GrantWithPasswordUseCase.cs +++ b/Source/Starfish.Service/UseCases/Identity/GrantWithPasswordUseCase.cs @@ -3,7 +3,6 @@ using Nerosoft.Euonia.Bus; using Nerosoft.Euonia.Domain; using Nerosoft.Starfish.Application; -using Nerosoft.Starfish.Common; using Nerosoft.Starfish.Domain; namespace Nerosoft.Starfish.UseCases; diff --git a/Source/Starfish.Webapi/Controllers/AppsController.cs b/Source/Starfish.Webapi/Controllers/AppsController.cs index bf71b4a..f1973ad 100644 --- a/Source/Starfish.Webapi/Controllers/AppsController.cs +++ b/Source/Starfish.Webapi/Controllers/AppsController.cs @@ -9,7 +9,7 @@ namespace Nerosoft.Starfish.Webapi.Controllers; /// 应用管理接口 ///
[Route("api/[controller]")] -[ApiController, ApiExplorerSettings(GroupName = "setting")] +[ApiController, ApiExplorerSettings(GroupName = "configuration")] [Authorize] public class AppsController : ControllerBase { diff --git a/Source/Starfish.Webapi/Extensions/SwaggerExtensions.cs b/Source/Starfish.Webapi/Extensions/SwaggerExtensions.cs index 37e715c..7011a12 100644 --- a/Source/Starfish.Webapi/Extensions/SwaggerExtensions.cs +++ b/Source/Starfish.Webapi/Extensions/SwaggerExtensions.cs @@ -9,7 +9,7 @@ internal static class SwaggerExtensions { private static readonly Dictionary _apiGroups = new() { - ["setting"] = "setting", + ["configuration"] = "configuration", ["identity"] = "identity", ["system"] = "system" }; diff --git a/Source/Starfish.Webapi/Starfish.Webapi.csproj b/Source/Starfish.Webapi/Starfish.Webapi.csproj index 809a8bb..184ab70 100644 --- a/Source/Starfish.Webapi/Starfish.Webapi.csproj +++ b/Source/Starfish.Webapi/Starfish.Webapi.csproj @@ -57,6 +57,7 @@ + diff --git a/Source/Starfish.Webapp/Rest/Handlers/AuthorizationHandler.cs b/Source/Starfish.Webapp/Rest/Handlers/AuthorizationHandler.cs index 0b0670d..8a17983 100644 --- a/Source/Starfish.Webapp/Rest/Handlers/AuthorizationHandler.cs +++ b/Source/Starfish.Webapp/Rest/Handlers/AuthorizationHandler.cs @@ -14,7 +14,7 @@ public AuthorizationHandler(ILocalStorageService storageService) protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { - var token = await _storageService.GetItemAsStringAsync(Constants.LocalStorage.AccessToken, cancellationToken); + var token = await _storageService.GetItemAsStringAsync(InternalConstants.LocalStorage.AccessToken, cancellationToken); if (!string.IsNullOrWhiteSpace(token) && TokenHelper.Validate(token)) { request.Headers!.Authorization = new AuthenticationHeaderValue("Bearer", token); diff --git a/Source/Starfish.Webapp/Seedwork/Constants.cs b/Source/Starfish.Webapp/Seedwork/Constants.cs deleted file mode 100644 index 1a755a1..0000000 --- a/Source/Starfish.Webapp/Seedwork/Constants.cs +++ /dev/null @@ -1,41 +0,0 @@ -namespace Nerosoft.Starfish.Webapp; - -internal class Constants -{ - public static bool IsDebug - { - get - { -#if DEBUG - return true; -#else - return false; -#endif - } - } - - - - public static class LocalStorage - { - public const string AccessToken = "session_access_token"; - public const string RefreshToken = "session_refresh_token"; - } - - public static class Query - { - public const int Skip = 0; - public const int Count = 20; - } - - public static class Configuration - { - public const string FormatJson = "plain/json"; - public const string FormatText = "plain/text"; - } - - public static class Message - { - public const string ExceptionThrown = "exception_thrown"; - } -} \ No newline at end of file diff --git a/Source/Starfish.Webapp/Seedwork/ExceptionExtensions.cs b/Source/Starfish.Webapp/Seedwork/ExceptionExtensions.cs index f198ef3..55d0b98 100644 --- a/Source/Starfish.Webapp/Seedwork/ExceptionExtensions.cs +++ b/Source/Starfish.Webapp/Seedwork/ExceptionExtensions.cs @@ -33,7 +33,7 @@ public static string GetPromptMessage(this Exception exception) }; } - public static void Send(this Exception exception, string token = Constants.Message.ExceptionThrown) + public static void Send(this Exception exception, string token = InternalConstants.Message.ExceptionThrown) { WeakReferenceMessenger.Default.Send(exception, token); } diff --git a/Source/Starfish.Webapp/Seedwork/ExceptionRecipient.cs b/Source/Starfish.Webapp/Seedwork/ExceptionRecipient.cs index 317e678..3a89210 100644 --- a/Source/Starfish.Webapp/Seedwork/ExceptionRecipient.cs +++ b/Source/Starfish.Webapp/Seedwork/ExceptionRecipient.cs @@ -6,8 +6,8 @@ internal sealed class ExceptionRecipient : IDisposable { public ExceptionRecipient() { - WeakReferenceMessenger.Default.Unregister(this, Constants.Message.ExceptionThrown); - WeakReferenceMessenger.Default.Register(this, Constants.Message.ExceptionThrown, OnExceptionThrown); + WeakReferenceMessenger.Default.Unregister(this, InternalConstants.Message.ExceptionThrown); + WeakReferenceMessenger.Default.Register(this, InternalConstants.Message.ExceptionThrown, OnExceptionThrown); } private Action Handle { get; set; } @@ -15,7 +15,7 @@ public ExceptionRecipient() public void Dispose() { Handle = null; - WeakReferenceMessenger.Default.Unregister(this, Constants.Message.ExceptionThrown); + WeakReferenceMessenger.Default.Unregister(this, InternalConstants.Message.ExceptionThrown); } public void Subscribe(Action handle) diff --git a/Source/Starfish.Webapp/Seedwork/InternalConstants.cs b/Source/Starfish.Webapp/Seedwork/InternalConstants.cs new file mode 100644 index 0000000..bab7093 --- /dev/null +++ b/Source/Starfish.Webapp/Seedwork/InternalConstants.cs @@ -0,0 +1,15 @@ +namespace Nerosoft.Starfish.Webapp; + +internal class InternalConstants +{ + public static class LocalStorage + { + public const string AccessToken = "session_access_token"; + public const string RefreshToken = "session_refresh_token"; + } + + public static class Message + { + public const string ExceptionThrown = "exception_thrown"; + } +} \ No newline at end of file diff --git a/Source/Starfish.Webapp/Seedwork/JwtAuthenticationStateProvider.cs b/Source/Starfish.Webapp/Seedwork/JwtAuthenticationStateProvider.cs index 8d0d272..c3433cb 100644 --- a/Source/Starfish.Webapp/Seedwork/JwtAuthenticationStateProvider.cs +++ b/Source/Starfish.Webapp/Seedwork/JwtAuthenticationStateProvider.cs @@ -24,11 +24,11 @@ private async void OnReceiveMessage(object recipient, AuthenticationStateMessage switch (message.Type) { case "logout": - await _storageService.RemoveItemsAsync([Constants.LocalStorage.AccessToken, Constants.LocalStorage.RefreshToken]); + await _storageService.RemoveItemsAsync([InternalConstants.LocalStorage.AccessToken, InternalConstants.LocalStorage.RefreshToken]); break; case "login": - await _storageService.SetItemAsStringAsync(Constants.LocalStorage.AccessToken, message.AccessToken); - await _storageService.SetItemAsStringAsync(Constants.LocalStorage.RefreshToken, message.RefreshToken); + await _storageService.SetItemAsStringAsync(InternalConstants.LocalStorage.AccessToken, message.AccessToken); + await _storageService.SetItemAsStringAsync(InternalConstants.LocalStorage.RefreshToken, message.RefreshToken); break; } @@ -39,7 +39,7 @@ public override async Task GetAuthenticationStateAsync() { ClaimsIdentity identity; - var token = await _storageService.GetItemAsStringAsync(Constants.LocalStorage.AccessToken); + var token = await _storageService.GetItemAsStringAsync(InternalConstants.LocalStorage.AccessToken); var jwt = TokenHelper.Resolve(token); if (jwt != null && jwt.ValidTo > DateTime.UtcNow) { diff --git a/Source/Starfish.Webapp/Seedwork/TaskExtensions.cs b/Source/Starfish.Webapp/Seedwork/TaskExtensions.cs index 4ac4436..6e94bfa 100644 --- a/Source/Starfish.Webapp/Seedwork/TaskExtensions.cs +++ b/Source/Starfish.Webapp/Seedwork/TaskExtensions.cs @@ -1,6 +1,4 @@ using CommunityToolkit.Mvvm.Messaging; -using Nerosoft.Starfish.Webapp.Rest; -using Refit; namespace Nerosoft.Starfish.Webapp; @@ -14,7 +12,7 @@ public static async Task Guard(this Task task, Func handler = n } catch (Exception exception) { - WeakReferenceMessenger.Default.Send(exception, Constants.Message.ExceptionThrown); + WeakReferenceMessenger.Default.Send(exception, InternalConstants.Message.ExceptionThrown); if (handler != null) { await handler(exception); @@ -34,7 +32,7 @@ public static async Task Guard(this Task task, Func + From f5231307b228357e5b4cb6b33726f5b6acb93cbb Mon Sep 17 00:00:00 2001 From: damon Date: Sun, 28 Jan 2024 23:48:55 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Domain/Aggregates/Configuration.cs | 2 +- .../Business/ConfigurationGeneralBusiness.cs | 3 +- .../Starfish.Webapp/Pages/User/Detail.razor | 55 ------------------- Source/Starfish.Webapp/Pages/User/Index.razor | 2 +- 4 files changed, 3 insertions(+), 59 deletions(-) delete mode 100644 Source/Starfish.Webapp/Pages/User/Detail.razor diff --git a/Source/Starfish.Service/Domain/Aggregates/Configuration.cs b/Source/Starfish.Service/Domain/Aggregates/Configuration.cs index 5d29beb..3c4d3f6 100644 --- a/Source/Starfish.Service/Domain/Aggregates/Configuration.cs +++ b/Source/Starfish.Service/Domain/Aggregates/Configuration.cs @@ -7,7 +7,7 @@ namespace Nerosoft.Starfish.Domain; /// /// 设置聚合根 /// -public class Configuration : Aggregate, IAuditing +public sealed class Configuration : Aggregate, IAuditing { private Configuration() { diff --git a/Source/Starfish.Service/Domain/Business/ConfigurationGeneralBusiness.cs b/Source/Starfish.Service/Domain/Business/ConfigurationGeneralBusiness.cs index ce3c9d0..8fe5f00 100644 --- a/Source/Starfish.Service/Domain/Business/ConfigurationGeneralBusiness.cs +++ b/Source/Starfish.Service/Domain/Business/ConfigurationGeneralBusiness.cs @@ -1,5 +1,4 @@ -using Google.Protobuf.WellKnownTypes; -using Nerosoft.Euonia.Business; +using Nerosoft.Euonia.Business; using Nerosoft.Starfish.Service; // ReSharper disable MemberCanBePrivate.Global diff --git a/Source/Starfish.Webapp/Pages/User/Detail.razor b/Source/Starfish.Webapp/Pages/User/Detail.razor deleted file mode 100644 index 776e789..0000000 --- a/Source/Starfish.Webapp/Pages/User/Detail.razor +++ /dev/null @@ -1,55 +0,0 @@ -@page "/user/{Id:long}" - -@attribute [Authorize(Roles = "SA")] - -@inject IUserApi Api - - - @(Resources.IDS_MENU_TEXT_HOME) - @(Resources.IDS_MENU_TEXT_USER) - @(Resources.IDS_BREADCRUMB_USER_DETAIL) - - - - - - - - @Data.UserName - @Data.CreateTime.Date - - Roles - - - Blazor - - - Microsoft - - - Azure - - - - Operations - - 编辑信息 - 修改密码 - 重置密码 - - - - - - - - - - -@code { - - [Parameter] - public long Id { get; set; } - - private UserDetailDto Data { get; } = new(); -} \ No newline at end of file diff --git a/Source/Starfish.Webapp/Pages/User/Index.razor b/Source/Starfish.Webapp/Pages/User/Index.razor index b47ead3..bb02812 100644 --- a/Source/Starfish.Webapp/Pages/User/Index.razor +++ b/Source/Starfish.Webapp/Pages/User/Index.razor @@ -82,7 +82,7 @@ private async Task OnDetailClicked(long id) { - Navigation.NavigateTo($"/user/{id}"); + //Navigation.NavigateTo($"/user/{id}"); await Task.CompletedTask; } From 682448b102d8b3d5c0a3b1ec0ab3771601c9fd4f Mon Sep 17 00:00:00 2001 From: damon Date: Mon, 29 Jan 2024 00:16:42 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Starfish.Webapp/Layout/MainLayout.razor | 2 +- Source/Starfish.Webapp/Pages/Apps/Index.razor | 35 ++++++++++--------- .../Starfish.Webapp/Pages/Config/Index.razor | 15 ++++---- .../Pages/Logging/Detail.razor | 6 ---- .../Starfish.Webapp/Pages/Logging/Index.razor | 3 +- Source/Starfish.Webapp/Pages/Team/Index.razor | 18 ++++++---- Source/Starfish.Webapp/Pages/User/Index.razor | 6 ++-- 7 files changed, 43 insertions(+), 42 deletions(-) diff --git a/Source/Starfish.Webapp/Layout/MainLayout.razor b/Source/Starfish.Webapp/Layout/MainLayout.razor index f9cff99..ff6e614 100644 --- a/Source/Starfish.Webapp/Layout/MainLayout.razor +++ b/Source/Starfish.Webapp/Layout/MainLayout.razor @@ -78,7 +78,7 @@ Nerosoft © @(DateTime.Today.Year). All rights reserved. diff --git a/Source/Starfish.Webapp/Pages/Apps/Index.razor b/Source/Starfish.Webapp/Pages/Apps/Index.razor index 8e4daa6..0fd3bdb 100644 --- a/Source/Starfish.Webapp/Pages/Apps/Index.razor +++ b/Source/Starfish.Webapp/Pages/Apps/Index.razor @@ -16,11 +16,11 @@ - + @@ -124,14 +127,14 @@ var tasks = new List { ConfigurationApi.GetItemListAsync(Id, Environment, request.StartIndex, Pagination.ItemsPerPage, request.CancellationToken) - .EnsureSuccess(result => items = result, request.CancellationToken) + .EnsureSuccess(result => items = result, request.CancellationToken) }; if (request.StartIndex == 0) { tasks.Add( ConfigurationApi.GetItemCountAsync(Id, Environment, request.CancellationToken) - .EnsureSuccess(result => Total = result, request.CancellationToken) + .EnsureSuccess(result => Total = result, request.CancellationToken) ); } @@ -155,8 +158,8 @@ private Task LoadConfigurationDetailAsync(CancellationToken cancellationToken = default) { return ConfigurationApi.GetAsync(Id, Environment, cancellationToken) - .EnsureSuccess(result => ConfigurationDetail = result, cancellationToken) - .Guard(); + .EnsureSuccess(result => ConfigurationDetail = result, cancellationToken) + .Guard(); } private Task LoadAppDetailAsync() @@ -252,7 +255,7 @@ try { await ConfigurationApi.DeleteAsync(Id, Environment) - .EnsureSuccess(); + .EnsureSuccess(); await Pagination.SetCurrentPageIndexAsync(0); StateHasChanged(); } diff --git a/Source/Starfish.Webapp/Pages/Logging/Detail.razor b/Source/Starfish.Webapp/Pages/Logging/Detail.razor index 1bf3de8..e97604a 100644 --- a/Source/Starfish.Webapp/Pages/Logging/Detail.razor +++ b/Source/Starfish.Webapp/Pages/Logging/Detail.razor @@ -11,12 +11,6 @@ - - diff --git a/Source/Starfish.Webapp/Pages/Logging/Index.razor b/Source/Starfish.Webapp/Pages/Logging/Index.razor index 2f5324f..bcf3ef2 100644 --- a/Source/Starfish.Webapp/Pages/Logging/Index.razor +++ b/Source/Starfish.Webapp/Pages/Logging/Index.razor @@ -26,8 +26,7 @@ ItemSize="46" GenerateHeader="GenerateHeaderOption.Sticky" TGridItem="OperateLogDto" - GridTemplateColumns="0.2fr 1fr 0.8fr 0.2fr 0.4fr 0.2fr"> - + GridTemplateColumns="1fr 0.8fr 0.2fr 0.4fr 0.2fr"> diff --git a/Source/Starfish.Webapp/Pages/Team/Index.razor b/Source/Starfish.Webapp/Pages/Team/Index.razor index ea62ce0..9bfd5d9 100644 --- a/Source/Starfish.Webapp/Pages/Team/Index.razor +++ b/Source/Starfish.Webapp/Pages/Team/Index.razor @@ -22,17 +22,21 @@ - - + @(context.Name) - - - - + + + + - + diff --git a/Source/Starfish.Webapp/Pages/User/Index.razor b/Source/Starfish.Webapp/Pages/User/Index.razor index bb02812..83509f0 100644 --- a/Source/Starfish.Webapp/Pages/User/Index.razor +++ b/Source/Starfish.Webapp/Pages/User/Index.razor @@ -22,15 +22,15 @@ - - + @(context.UserName) -