diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/IRatingPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/IRatingPublicAppService.cs index aa0aba48b4..39d6b01ccb 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/IRatingPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/IRatingPublicAppService.cs @@ -1,7 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; -using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; namespace Volo.CmsKit.Public.Ratings @@ -11,8 +9,6 @@ namespace Volo.CmsKit.Public.Ratings Task CreateAsync(string entityType, string entityId, CreateUpdateRatingInput input); Task DeleteAsync(string entityType, string entityId); - - Task GetCurrentUserRatingAsync(string entityType, string entityId); Task> GetGroupedStarCountsAsync(string entityType, string entityId); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Ratings/RatingPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Ratings/RatingPublicAppService.cs index 848dbeda28..4341157763 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Ratings/RatingPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Ratings/RatingPublicAppService.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; -using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.Authorization; using Volo.Abp.Users; @@ -66,16 +64,6 @@ namespace Volo.CmsKit.Public.Ratings await RatingRepository.DeleteAsync(rating.Id); } - [Authorize] - public virtual async Task GetCurrentUserRatingAsync(string entityType, string entityId) - { - var currentUserId = CurrentUser.GetId(); - - var rating = await RatingRepository.GetCurrentUserRatingAsync(entityType, entityId, currentUserId); - - return ObjectMapper.Map(rating); - } - public virtual async Task> GetGroupedStarCountsAsync(string entityType, string entityId) { diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Ratings/RatingPublicController.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Ratings/RatingPublicController.cs index e136c4564d..1a10919f8c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Ratings/RatingPublicController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Ratings/RatingPublicController.cs @@ -34,13 +34,6 @@ namespace Volo.CmsKit.Public.Ratings return RatingPublicAppService.DeleteAsync(entityType, entityId); } - [HttpGet] - [Route("{entityType}/{entityId}")] - public virtual Task GetCurrentUserRatingAsync(string entityType, string entityId) - { - return RatingPublicAppService.GetCurrentUserRatingAsync(entityType, entityId); - } - [HttpGet] [Route("{entityType}/{entityId}")] public virtual Task> GetGroupedStarCountsAsync(string entityType, string entityId) diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Ratings/RatingPublicAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Ratings/RatingPublicAppService_Tests.cs index 92e384a1d4..dabcbb6c91 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Ratings/RatingPublicAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Ratings/RatingPublicAppService_Tests.cs @@ -1,6 +1,5 @@ using System.Linq; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using NSubstitute; using Shouldly; @@ -52,16 +51,16 @@ namespace Volo.CmsKit.Ratings .ShouldBeTrue(); }); } - + [Fact] public async Task CreateAsync_Should_Update_If_Rating_Is_Exist() { _currentUser.Id.Returns(_cmsKitTestData.User1Id); var entity = - await _ratingAppService.GetCurrentUserRatingAsync(_cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1); - + (await _ratingAppService.GetGroupedStarCountsAsync(_cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1)).FirstOrDefault(); + var updatedEntity = await _ratingAppService.CreateAsync( _cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1, @@ -69,34 +68,10 @@ namespace Volo.CmsKit.Ratings { StarCount = 5 }); - - entity.Id.ShouldBe(updatedEntity.Id); - entity.EntityId.ShouldBe(updatedEntity.EntityId); - entity.EntityType.ShouldBe(updatedEntity.EntityType); + entity.StarCount.ShouldBe(updatedEntity.StarCount); } - [Fact] - public async Task GetCurrentUserRatingAsync() - { - _currentUser.Id.Returns(_cmsKitTestData.User1Id); - - var rating = await _ratingAppService.GetCurrentUserRatingAsync( - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1 - ); - - UsingDbContext(context => - { - var ratings = context.Set().Where(x => - x.EntityId == _cmsKitTestData.EntityId1 && x.EntityType == _cmsKitTestData.EntityType1).ToList(); - - ratings - .Any(c => c.Id == rating.Id && c.EntityId == rating.EntityId && c.EntityType == rating.EntityType) - .ShouldBeTrue(); - }); - } - [Fact] public async Task GetGroupedStarCountsAsync() {