From 75735a167794dd5e43247cd317f785877de29e5c Mon Sep 17 00:00:00 2001 From: kentah <158997636+KentaHizume@users.noreply.github.com> Date: Thu, 26 Dec 2024 22:14:50 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E5=90=8D?= =?UTF-8?q?=E3=81=AEByAdmin=E3=82=92ForAdmin=E3=81=AB=E4=BF=AE=E6=AD=A3=20?= =?UTF-8?q?(#2186)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CatalogApplicationService.cs | 12 ++++---- .../Resources/LogMessages.Designer.cs | 16 +++++------ .../Resources/LogMessages.resx | 8 +++--- .../Controllers/CatalogItemsController.cs | 4 +-- .../CatalogApplicationServiceTest.cs | 28 +++++++++---------- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/ApplicationService/CatalogApplicationService.cs b/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/ApplicationService/CatalogApplicationService.cs index f7f4eff84..c7afd3ac8 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/ApplicationService/CatalogApplicationService.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/ApplicationService/CatalogApplicationService.cs @@ -277,9 +277,9 @@ public async Task UpdateCatalogItemAsync( /// キャンセルトークン。 /// カタログページと総アイテム数のタプルを返す非同期処理を表すタスク。 /// 更新権限がない場合。 - public async Task<(IReadOnlyList ItemsOnPage, int TotalItems)> GetCatalogItemsByAdminAsync(int skip, int take, long? brandId, long? categoryId, CancellationToken cancellationToken = default) + public async Task<(IReadOnlyList ItemsOnPage, int TotalItems)> GetCatalogItemsForAdminAsync(int skip, int take, long? brandId, long? categoryId, CancellationToken cancellationToken = default) { - this.logger.LogDebug(Events.DebugEvent, LogMessages.CatalogApplicationService_GetCatalogItemsByAdminAsyncStart, brandId, categoryId); + this.logger.LogDebug(Events.DebugEvent, LogMessages.CatalogApplicationService_GetCatalogItemsForAdminAsyncStart, brandId, categoryId); if (!this.userStore.IsInRole(Roles.Admin)) { @@ -298,7 +298,7 @@ public async Task UpdateCatalogItemAsync( scope.Complete(); } - this.logger.LogDebug(Events.DebugEvent, LogMessages.CatalogApplicationService_GetCatalogItemsByAdminAsyncEnd, brandId, categoryId); + this.logger.LogDebug(Events.DebugEvent, LogMessages.CatalogApplicationService_GetCatalogItemsForAdminAsyncEnd, brandId, categoryId); return (ItemsOnPage: itemsOnPage, TotalItems: totalItems); } @@ -310,9 +310,9 @@ public async Task UpdateCatalogItemAsync( /// カタログアイテム。 /// 更新権限がない場合。 /// 取得対象のカタログアイテムが存在しなかった場合。 - public async Task GetCatalogItemByAdminAsync(long catalogItemId, CancellationToken cancellationToken = default) + public async Task GetCatalogItemForAdminAsync(long catalogItemId, CancellationToken cancellationToken = default) { - this.logger.LogDebug(Events.DebugEvent, LogMessages.CatalogApplicationService_GetCatalogItemByAdminAsyncStart, catalogItemId); + this.logger.LogDebug(Events.DebugEvent, LogMessages.CatalogApplicationService_GetCatalogItemForAdminAsyncStart, catalogItemId); if (!this.userStore.IsInRole(Roles.Admin)) { @@ -332,7 +332,7 @@ public async Task UpdateCatalogItemAsync( scope.Complete(); } - this.logger.LogDebug(Events.DebugEvent, LogMessages.CatalogApplicationService_GetCatalogItemByAdminAsyncEnd, catalogItemId); + this.logger.LogDebug(Events.DebugEvent, LogMessages.CatalogApplicationService_GetCatalogItemForAdminAsyncEnd, catalogItemId); return catalogItem; } } diff --git a/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Resources/LogMessages.Designer.cs b/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Resources/LogMessages.Designer.cs index 06e9653ff..db5cb0c52 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Resources/LogMessages.Designer.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Resources/LogMessages.Designer.cs @@ -126,18 +126,18 @@ internal static string CatalogApplicationService_DeleteItemFromCatalogAsyncStart /// /// 管理者がカタログアイテム ID: {CatalogItemId} のカタログアイテムを取得しました。 に類似しているローカライズされた文字列を検索します。 /// - internal static string CatalogApplicationService_GetCatalogItemByAdminAsyncEnd { + internal static string CatalogApplicationService_GetCatalogItemForAdminAsyncEnd { get { - return ResourceManager.GetString("CatalogApplicationService_GetCatalogItemByAdminAsyncEnd", resourceCulture); + return ResourceManager.GetString("CatalogApplicationService_GetCatalogItemForAdminAsyncEnd", resourceCulture); } } /// /// 管理者がカタログアイテム ID: {CatalogItemId} のカタログアイテムを取得します。 に類似しているローカライズされた文字列を検索します。 /// - internal static string CatalogApplicationService_GetCatalogItemByAdminAsyncStart { + internal static string CatalogApplicationService_GetCatalogItemForAdminAsyncStart { get { - return ResourceManager.GetString("CatalogApplicationService_GetCatalogItemByAdminAsyncStart", resourceCulture); + return ResourceManager.GetString("CatalogApplicationService_GetCatalogItemForAdminAsyncStart", resourceCulture); } } @@ -162,18 +162,18 @@ internal static string CatalogApplicationService_GetCatalogItemsAsyncStart { /// /// 管理者がカタログブランド ID: {CatalogBrandId} 、カタログカテゴリ ID: {CatalogCategoryId} のカタログ情報を取得しました。 に類似しているローカライズされた文字列を検索します。 /// - internal static string CatalogApplicationService_GetCatalogItemsByAdminAsyncEnd { + internal static string CatalogApplicationService_GetCatalogItemsForAdminAsyncEnd { get { - return ResourceManager.GetString("CatalogApplicationService_GetCatalogItemsByAdminAsyncEnd", resourceCulture); + return ResourceManager.GetString("CatalogApplicationService_GetCatalogItemsForAdminAsyncEnd", resourceCulture); } } /// /// 管理者がカタログブランド ID: {CatalogBrandId} 、カタログカテゴリ ID: {CatalogCategoryId} のカタログ情報を取得します。 に類似しているローカライズされた文字列を検索します。 /// - internal static string CatalogApplicationService_GetCatalogItemsByAdminAsyncStart { + internal static string CatalogApplicationService_GetCatalogItemsForAdminAsyncStart { get { - return ResourceManager.GetString("CatalogApplicationService_GetCatalogItemsByAdminAsyncStart", resourceCulture); + return ResourceManager.GetString("CatalogApplicationService_GetCatalogItemsForAdminAsyncStart", resourceCulture); } } diff --git a/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Resources/LogMessages.resx b/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Resources/LogMessages.resx index 03c70fffe..21cf2715c 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Resources/LogMessages.resx +++ b/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Resources/LogMessages.resx @@ -138,10 +138,10 @@ カタログアイテム ID: {CatalogItemId} のカタログアイテムを削除します。 - + 管理者がカタログアイテム ID: {CatalogItemId} のカタログアイテムを取得しました。 - + 管理者がカタログアイテム ID: {CatalogItemId} のカタログアイテムを取得します。 @@ -150,10 +150,10 @@ カタログブランド ID: {CatalogBrandId} 、カタログカテゴリ ID: {CatalogCategoryId} のカテゴリ情報を取得します。 - + 管理者がカタログブランド ID: {CatalogBrandId} 、カタログカテゴリ ID: {CatalogCategoryId} のカタログ情報を取得しました。 - + 管理者がカタログブランド ID: {CatalogBrandId} 、カタログカテゴリ ID: {CatalogCategoryId} のカタログ情報を取得します。 diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web.Admin/Controllers/CatalogItemsController.cs b/samples/Dressca/dressca-backend/src/Dressca.Web.Admin/Controllers/CatalogItemsController.cs index f656703b8..abb70881c 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web.Admin/Controllers/CatalogItemsController.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web.Admin/Controllers/CatalogItemsController.cs @@ -72,7 +72,7 @@ public async Task GetCatalogItemAsync(long catalogItemId) try { - catalogItem = await this.service.GetCatalogItemByAdminAsync(catalogItemId); + catalogItem = await this.service.GetCatalogItemForAdminAsync(catalogItemId); } catch (PermissionDeniedException ex) { @@ -114,7 +114,7 @@ public async Task GetByQueryAsync([FromQuery] FindCatalogItemsQue try { itemsAndCount = - await this.service.GetCatalogItemsByAdminAsync( + await this.service.GetCatalogItemsForAdminAsync( skip: query.GetSkipCount(), take: query.PageSize, brandId: query.BrandId, diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.ApplicationCore/ApplicationService/CatalogApplicationServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.ApplicationCore/ApplicationService/CatalogApplicationServiceTest.cs index 185b8f52c..66f1e4afd 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.ApplicationCore/ApplicationService/CatalogApplicationServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.ApplicationCore/ApplicationService/CatalogApplicationServiceTest.cs @@ -618,7 +618,7 @@ public async Task UpdateCatalogItemAsync_権限なし_PermissionDeniedException } [Fact] - public async Task GetCatalogItemsByAdminAsync_リポジトリのFindAsyncを一度だけ呼び出す() + public async Task GetCatalogItemsForAdminAsync_リポジトリのFindAsyncを一度だけ呼び出す() { // Arrange var catalogRepositoryMock = new Mock(); @@ -635,7 +635,7 @@ public async Task GetCatalogItemsByAdminAsync_リポジトリのFindAsyncを一 var targetCategoryId = 1; // Act - _ = await service.GetCatalogItemsByAdminAsync(skip, take, targetBrandId, targetCategoryId); + _ = await service.GetCatalogItemsForAdminAsync(skip, take, targetBrandId, targetCategoryId); // Assert catalogRepositoryMock.Verify( @@ -644,7 +644,7 @@ public async Task GetCatalogItemsByAdminAsync_リポジトリのFindAsyncを一 } [Fact] - public async Task GetCatalogItemsByAdminAsync_リポジトリのCountAsyncを1回呼出す() + public async Task GetCatalogItemsForAdminAsync_リポジトリのCountAsyncを1回呼出す() { // Arrange var catalogRepositoryMock = new Mock(); @@ -661,7 +661,7 @@ public async Task GetCatalogItemsByAdminAsync_リポジトリのCountAsyncを1 var targetCategoryId = 1; // Act - _ = await service.GetCatalogItemsByAdminAsync(skip, take, targetBrandId, targetCategoryId); + _ = await service.GetCatalogItemsForAdminAsync(skip, take, targetBrandId, targetCategoryId); // Assert catalogRepositoryMock.Verify( @@ -670,7 +670,7 @@ public async Task GetCatalogItemsByAdminAsync_リポジトリのCountAsyncを1 } [Fact] - public async Task GetCatalogItemsByAdminAsync_ページネーションされたアイテムと総アイテム数が返却される() + public async Task GetCatalogItemsForAdminAsync_ページネーションされたアイテムと総アイテム数が返却される() { // Arrange var skip = 0; @@ -693,7 +693,7 @@ public async Task GetCatalogItemsByAdminAsync_ページネーションされた var service = new CatalogApplicationService(catalogRepositoryMock.Object, catalogBrandRepositoryMock.Object, catalogCategoryRepositoryMock.Object, userStoreMock.Object, catalogDomainServiceMock, logger); // Act - var (list, totalItems) = await service.GetCatalogItemsByAdminAsync(skip, take, targetBrandId, targetCategoryId); + var (list, totalItems) = await service.GetCatalogItemsForAdminAsync(skip, take, targetBrandId, targetCategoryId); // Assert Assert.Equal(targetItems, list); @@ -701,7 +701,7 @@ public async Task GetCatalogItemsByAdminAsync_ページネーションされた } [Fact] - public async Task GetCatalogItemsByAdminAsync_権限なし_PermissionDeniedExceptionが発生() + public async Task GetCatalogItemsForAdminAsync_権限なし_PermissionDeniedExceptionが発生() { // Arrange var catalogRepositoryMock = new Mock(); @@ -718,14 +718,14 @@ public async Task GetCatalogItemsByAdminAsync_権限なし_PermissionDeniedExcep var targetCategoryId = 1; // Act - var action = () => service.GetCatalogItemsByAdminAsync(skip, take, targetBrandId, targetCategoryId); + var action = () => service.GetCatalogItemsForAdminAsync(skip, take, targetBrandId, targetCategoryId); // Assert await Assert.ThrowsAsync(action); } [Fact] - public async Task GetCatalogItemByAdminAsync_リポジトリのGetAsyncを一度だけ呼び出す() + public async Task GetCatalogItemForAdminAsync_リポジトリのGetAsyncを一度だけ呼び出す() { // Arrange var targetId = 1; @@ -743,14 +743,14 @@ public async Task GetCatalogItemByAdminAsync_リポジトリのGetAsyncを一度 var service = new CatalogApplicationService(catalogRepositoryMock.Object, catalogBrandRepository, catalogCategoryRepository, userStoreMock.Object, catalogDomainServiceMock, logger); // Act - _ = await service.GetCatalogItemByAdminAsync(targetId); + _ = await service.GetCatalogItemForAdminAsync(targetId); // Assert catalogRepositoryMock.Verify(r => r.GetAsync(targetId, AnyToken), Times.Once); } [Fact] - public async Task GetCatalogItemByAdminAsync_権限なし_PermissionDeniedExceptionが発生() + public async Task GetCatalogItemForAdminAsync_権限なし_PermissionDeniedExceptionが発生() { // Arrange var targetId = 1; @@ -768,14 +768,14 @@ public async Task GetCatalogItemByAdminAsync_権限なし_PermissionDeniedExcept var service = new CatalogApplicationService(catalogRepositoryMock.Object, catalogBrandRepository, catalogCategoryRepository, userStoreMock.Object, catalogDomainServiceMock, logger); // Act - var action = () => service.GetCatalogItemByAdminAsync(targetId); + var action = () => service.GetCatalogItemForAdminAsync(targetId); // Assert await Assert.ThrowsAsync(action); } [Fact] - public async Task GetCatalogItemByAdminAsync_対象のアイテムが存在しない_CatalogItemNotExistingInRepositoryExceptionが発生() + public async Task GetCatalogItemForAdminAsync_対象のアイテムが存在しない_CatalogItemNotExistingInRepositoryExceptionが発生() { // Arrange var targetId = 999; @@ -792,7 +792,7 @@ public async Task GetCatalogItemByAdminAsync_対象のアイテムが存在し var service = new CatalogApplicationService(catalogRepositoryMock.Object, catalogBrandRepository, catalogCategoryRepository, userStoreMock.Object, catalogDomainServiceMock, logger); // Act - var action = () => service.GetCatalogItemByAdminAsync(targetId); + var action = () => service.GetCatalogItemForAdminAsync(targetId); // Assert await Assert.ThrowsAsync(action);