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.ProductAssetCategories.Dtos;
using EasyAbp.EShop.Plugins.Booking.ProductAssets; using EasyAbp.EShop.Plugins.Booking.ProductAssets;
using EasyAbp.EShop.Plugins.Booking.ProductAssets.Dtos; 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 Microsoft.AspNetCore.Authorization;
using Volo.Abp; using Volo.Abp;
@ -22,6 +24,7 @@ namespace EasyAbp.EShop.Orders.Booking.Authorization
{ {
private readonly IPeriodSchemeAppService _periodSchemeAppService; private readonly IPeriodSchemeAppService _periodSchemeAppService;
private readonly IProductAssetAppService _productAssetAppService; private readonly IProductAssetAppService _productAssetAppService;
private readonly IStoreAssetCategoryAppService _storeAssetCategoryAppService;
private readonly IProductAssetCategoryAppService _productAssetCategoryAppService; private readonly IProductAssetCategoryAppService _productAssetCategoryAppService;
private readonly IAssetOccupancyAppService _assetOccupancyAppService; private readonly IAssetOccupancyAppService _assetOccupancyAppService;
private readonly IBookingProductGroupDefinitionAppService _definitionAppService; private readonly IBookingProductGroupDefinitionAppService _definitionAppService;
@ -29,12 +32,14 @@ namespace EasyAbp.EShop.Orders.Booking.Authorization
public BookingOrderCreationAuthorizationHandler( public BookingOrderCreationAuthorizationHandler(
IPeriodSchemeAppService periodSchemeAppService, IPeriodSchemeAppService periodSchemeAppService,
IProductAssetAppService productAssetAppService, IProductAssetAppService productAssetAppService,
IStoreAssetCategoryAppService storeAssetCategoryAppService,
IProductAssetCategoryAppService productAssetCategoryAppService, IProductAssetCategoryAppService productAssetCategoryAppService,
IAssetOccupancyAppService assetOccupancyAppService, IAssetOccupancyAppService assetOccupancyAppService,
IBookingProductGroupDefinitionAppService definitionAppService) IBookingProductGroupDefinitionAppService definitionAppService)
{ {
_periodSchemeAppService = periodSchemeAppService; _periodSchemeAppService = periodSchemeAppService;
_productAssetAppService = productAssetAppService; _productAssetAppService = productAssetAppService;
_storeAssetCategoryAppService = storeAssetCategoryAppService;
_productAssetCategoryAppService = productAssetCategoryAppService; _productAssetCategoryAppService = productAssetCategoryAppService;
_assetOccupancyAppService = assetOccupancyAppService; _assetOccupancyAppService = assetOccupancyAppService;
_definitionAppService = definitionAppService; _definitionAppService = definitionAppService;
@ -141,8 +146,10 @@ namespace EasyAbp.EShop.Orders.Booking.Authorization
protected virtual async Task<bool> IsAssetInfoValidAsync(CreateOrderLineDto orderLine, protected virtual async Task<bool> IsAssetInfoValidAsync(CreateOrderLineDto orderLine,
OrderCreationResource resource) OrderCreationResource resource)
{ {
// Todo: check store to asset mapping.
var productAsset = (await _productAssetAppService.GetListAsync( var productAsset = (await _productAssetAppService.GetListAsync(
new GetProductAssetDto new GetProductAssetListDto
{ {
MaxResultCount = 1, MaxResultCount = 1,
StoreId = resource.Input.StoreId, StoreId = resource.Input.StoreId,
@ -159,8 +166,20 @@ namespace EasyAbp.EShop.Orders.Booking.Authorization
protected virtual async Task<bool> IsAssetCategoryInfoValidAsync(CreateOrderLineDto orderLine, protected virtual async Task<bool> IsAssetCategoryInfoValidAsync(CreateOrderLineDto orderLine,
OrderCreationResource resource) 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( var productAssetCategory = (await _productAssetCategoryAppService.GetListAsync(
new GetProductAssetCategoryDto new GetProductAssetCategoryListDto
{ {
MaxResultCount = 1, MaxResultCount = 1,
StoreId = resource.Input.StoreId, 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< ICrudAppService<
StoreAssetCategoryDto, StoreAssetCategoryDto,
Guid, Guid,
PagedAndSortedResultRequestDto, GetStoreAssetCategoryListDto,
CreateUpdateStoreAssetCategoryDto, CreateUpdateStoreAssetCategoryDto,
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;
using System.Linq;
using System.Threading.Tasks;
using EasyAbp.EShop.Plugins.Booking.Permissions; using EasyAbp.EShop.Plugins.Booking.Permissions;
using EasyAbp.EShop.Plugins.Booking.StoreAssetCategories.Dtos; using EasyAbp.EShop.Plugins.Booking.StoreAssetCategories.Dtos;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
namespace EasyAbp.EShop.Plugins.Booking.StoreAssetCategories 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 IStoreAssetCategoryAppService
{ {
protected override string GetPolicyName { get; set; } = BookingPermissions.StoreAssetCategory.Default; protected override string GetPolicyName { get; set; } = null;
protected override string GetListPolicyName { get; set; } = BookingPermissions.StoreAssetCategory.Default; protected override string GetListPolicyName { get; set; } = null;
protected override string CreatePolicyName { get; set; } = BookingPermissions.StoreAssetCategory.Create; protected override string CreatePolicyName { get; set; } = BookingPermissions.StoreAssetCategory.Create;
protected override string UpdatePolicyName { get; set; } = BookingPermissions.StoreAssetCategory.Update; protected override string UpdatePolicyName { get; set; } = BookingPermissions.StoreAssetCategory.Update;
protected override string DeletePolicyName { get; set; } = BookingPermissions.StoreAssetCategory.Delete; protected override string DeletePolicyName { get; set; } = BookingPermissions.StoreAssetCategory.Delete;
@ -21,5 +23,12 @@ namespace EasyAbp.EShop.Plugins.Booking.StoreAssetCategories
{ {
_repository = repository; _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] [HttpGet]
[Route("")] [Route("")]
public virtual Task<PagedResultDto<StoreAssetCategoryDto>> GetListAsync(PagedAndSortedResultRequestDto input) public virtual Task<PagedResultDto<StoreAssetCategoryDto>> GetListAsync(GetStoreAssetCategoryListDto input)
{ {
return _service.GetListAsync(input); return _service.GetListAsync(input);
} }

Loading…
Cancel
Save