Browse Source

Check store to category mapping

pull/157/head
gdlcf88 4 years ago
parent
commit
e4e6116b61
  1. 23
      plugins/Booking/src/EasyAbp.EShop.Orders.Booking.Application/EasyAbp/EShop/Orders/Booking/Authorization/BookingOrderCreationAuthorizationHandler.cs
  2. 12
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/StoreAssetCategories/Dtos/GetStoreAssetCategoryListDto.cs
  3. 2
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/StoreAssetCategories/IStoreAssetCategoryAppService.cs
  4. 17
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/StoreAssetCategories/StoreAssetCategoryAppService.cs
  5. 2
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.HttpApi/EasyAbp/EShop/Plugins/Booking/StoreAssetCategories/StoreAssetCategoryController.cs

23
plugins/Booking/src/EasyAbp.EShop.Orders.Booking.Application/EasyAbp/EShop/Orders/Booking/Authorization/BookingOrderCreationAuthorizationHandler.cs

@ -13,6 +13,8 @@ using EasyAbp.EShop.Plugins.Booking.ProductAssetCategories;
using EasyAbp.EShop.Plugins.Booking.ProductAssetCategories.Dtos;
using EasyAbp.EShop.Plugins.Booking.ProductAssets;
using EasyAbp.EShop.Plugins.Booking.ProductAssets.Dtos;
using EasyAbp.EShop.Plugins.Booking.StoreAssetCategories;
using EasyAbp.EShop.Plugins.Booking.StoreAssetCategories.Dtos;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp;
@ -22,6 +24,7 @@ namespace EasyAbp.EShop.Orders.Booking.Authorization
{
private readonly IPeriodSchemeAppService _periodSchemeAppService;
private readonly IProductAssetAppService _productAssetAppService;
private readonly IStoreAssetCategoryAppService _storeAssetCategoryAppService;
private readonly IProductAssetCategoryAppService _productAssetCategoryAppService;
private readonly IAssetOccupancyAppService _assetOccupancyAppService;
private readonly IBookingProductGroupDefinitionAppService _definitionAppService;
@ -29,12 +32,14 @@ namespace EasyAbp.EShop.Orders.Booking.Authorization
public BookingOrderCreationAuthorizationHandler(
IPeriodSchemeAppService periodSchemeAppService,
IProductAssetAppService productAssetAppService,
IStoreAssetCategoryAppService storeAssetCategoryAppService,
IProductAssetCategoryAppService productAssetCategoryAppService,
IAssetOccupancyAppService assetOccupancyAppService,
IBookingProductGroupDefinitionAppService definitionAppService)
{
_periodSchemeAppService = periodSchemeAppService;
_productAssetAppService = productAssetAppService;
_storeAssetCategoryAppService = storeAssetCategoryAppService;
_productAssetCategoryAppService = productAssetCategoryAppService;
_assetOccupancyAppService = assetOccupancyAppService;
_definitionAppService = definitionAppService;
@ -141,8 +146,10 @@ namespace EasyAbp.EShop.Orders.Booking.Authorization
protected virtual async Task<bool> IsAssetInfoValidAsync(CreateOrderLineDto orderLine,
OrderCreationResource resource)
{
// Todo: check store to asset mapping.
var productAsset = (await _productAssetAppService.GetListAsync(
new GetProductAssetDto
new GetProductAssetListDto
{
MaxResultCount = 1,
StoreId = resource.Input.StoreId,
@ -159,8 +166,20 @@ namespace EasyAbp.EShop.Orders.Booking.Authorization
protected virtual async Task<bool> IsAssetCategoryInfoValidAsync(CreateOrderLineDto orderLine,
OrderCreationResource resource)
{
var mapping = (await _storeAssetCategoryAppService.GetListAsync(new GetStoreAssetCategoryListDto
{
MaxResultCount = 1,
StoreId = resource.Input.StoreId,
AssetCategoryId = orderLine.GetBookingAssetCategoryId()
})).Items.FirstOrDefault();
if (mapping is null)
{
return false;
}
var productAssetCategory = (await _productAssetCategoryAppService.GetListAsync(
new GetProductAssetCategoryDto
new GetProductAssetCategoryListDto
{
MaxResultCount = 1,
StoreId = resource.Input.StoreId,

12
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/StoreAssetCategories/Dtos/GetStoreAssetCategoryListDto.cs

@ -0,0 +1,12 @@
using System;
using Volo.Abp.Application.Dtos;
namespace EasyAbp.EShop.Plugins.Booking.StoreAssetCategories.Dtos;
[Serializable]
public class GetStoreAssetCategoryListDto : PagedAndSortedResultRequestDto
{
public Guid? StoreId { get; set; }
public Guid? AssetCategoryId { get; set; }
}

2
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/StoreAssetCategories/IStoreAssetCategoryAppService.cs

@ -9,7 +9,7 @@ namespace EasyAbp.EShop.Plugins.Booking.StoreAssetCategories
ICrudAppService<
StoreAssetCategoryDto,
Guid,
PagedAndSortedResultRequestDto,
GetStoreAssetCategoryListDto,
CreateUpdateStoreAssetCategoryDto,
CreateUpdateStoreAssetCategoryDto>
{

17
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/StoreAssetCategories/StoreAssetCategoryAppService.cs

@ -1,16 +1,18 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using EasyAbp.EShop.Plugins.Booking.Permissions;
using EasyAbp.EShop.Plugins.Booking.StoreAssetCategories.Dtos;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
namespace EasyAbp.EShop.Plugins.Booking.StoreAssetCategories
{
public class StoreAssetCategoryAppService : CrudAppService<StoreAssetCategory, StoreAssetCategoryDto, Guid, PagedAndSortedResultRequestDto, CreateUpdateStoreAssetCategoryDto, CreateUpdateStoreAssetCategoryDto>,
public class StoreAssetCategoryAppService : CrudAppService<StoreAssetCategory, StoreAssetCategoryDto, Guid,
GetStoreAssetCategoryListDto, CreateUpdateStoreAssetCategoryDto, CreateUpdateStoreAssetCategoryDto>,
IStoreAssetCategoryAppService
{
protected override string GetPolicyName { get; set; } = BookingPermissions.StoreAssetCategory.Default;
protected override string GetListPolicyName { get; set; } = BookingPermissions.StoreAssetCategory.Default;
protected override string GetPolicyName { get; set; } = null;
protected override string GetListPolicyName { get; set; } = null;
protected override string CreatePolicyName { get; set; } = BookingPermissions.StoreAssetCategory.Create;
protected override string UpdatePolicyName { get; set; } = BookingPermissions.StoreAssetCategory.Update;
protected override string DeletePolicyName { get; set; } = BookingPermissions.StoreAssetCategory.Delete;
@ -21,5 +23,12 @@ namespace EasyAbp.EShop.Plugins.Booking.StoreAssetCategories
{
_repository = repository;
}
protected override async Task<IQueryable<StoreAssetCategory>> CreateFilteredQueryAsync(GetStoreAssetCategoryListDto input)
{
return (await base.CreateFilteredQueryAsync(input))
.WhereIf(input.StoreId.HasValue, x => x.StoreId == input.StoreId)
.WhereIf(input.AssetCategoryId.HasValue, x => x.AssetCategoryId == input.AssetCategoryId);
}
}
}

2
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.HttpApi/EasyAbp/EShop/Plugins/Booking/StoreAssetCategories/StoreAssetCategoryController.cs

@ -49,7 +49,7 @@ namespace EasyAbp.EShop.Plugins.Booking.StoreAssetCategories
[HttpGet]
[Route("")]
public virtual Task<PagedResultDto<StoreAssetCategoryDto>> GetListAsync(PagedAndSortedResultRequestDto input)
public virtual Task<PagedResultDto<StoreAssetCategoryDto>> GetListAsync(GetStoreAssetCategoryListDto input)
{
return _service.GetListAsync(input);
}

Loading…
Cancel
Save