Commit 1898c1ac authored by gdlcf88's avatar gdlcf88

Get/GetList permission requirement adjustment, close #13

parent 2f709752
using System; using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using EasyAbp.EShop.Products.Authorization; using EasyAbp.EShop.Products.Authorization;
using EasyAbp.EShop.Products.Categories.Dtos; using EasyAbp.EShop.Products.Categories.Dtos;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
...@@ -13,8 +15,8 @@ namespace EasyAbp.EShop.Products.Categories ...@@ -13,8 +15,8 @@ namespace EasyAbp.EShop.Products.Categories
protected override string CreatePolicyName { get; set; } = ProductsPermissions.Categories.Create; protected override string CreatePolicyName { get; set; } = ProductsPermissions.Categories.Create;
protected override string DeletePolicyName { get; set; } = ProductsPermissions.Categories.Delete; protected override string DeletePolicyName { get; set; } = ProductsPermissions.Categories.Delete;
protected override string UpdatePolicyName { get; set; } = ProductsPermissions.Categories.Update; protected override string UpdatePolicyName { get; set; } = ProductsPermissions.Categories.Update;
protected override string GetPolicyName { get; set; } = ProductsPermissions.Categories.Default; protected override string GetPolicyName { get; set; } = null;
protected override string GetListPolicyName { get; set; } = ProductsPermissions.Categories.Default; protected override string GetListPolicyName { get; set; } = null;
private readonly ICategoryRepository _repository; private readonly ICategoryRepository _repository;
...@@ -29,5 +31,15 @@ namespace EasyAbp.EShop.Products.Categories ...@@ -29,5 +31,15 @@ namespace EasyAbp.EShop.Products.Categories
return input.ShowHidden ? query : query.Where(x => !x.IsHidden); return input.ShowHidden ? query : query.Where(x => !x.IsHidden);
} }
public override Task<PagedResultDto<CategoryDto>> GetListAsync(GetCategoryListDto input)
{
if (input.ShowHidden)
{
AuthorizationService.CheckAsync(ProductsPermissions.Products.Default);
}
return base.GetListAsync(input);
}
} }
} }
\ No newline at end of file
...@@ -16,7 +16,7 @@ namespace EasyAbp.EShop.Products.ProductDetails ...@@ -16,7 +16,7 @@ namespace EasyAbp.EShop.Products.ProductDetails
protected override string CreatePolicyName { get; set; } = ProductsPermissions.Products.Create; protected override string CreatePolicyName { get; set; } = ProductsPermissions.Products.Create;
protected override string DeletePolicyName { get; set; } = ProductsPermissions.Products.Delete; protected override string DeletePolicyName { get; set; } = ProductsPermissions.Products.Delete;
protected override string UpdatePolicyName { get; set; } = ProductsPermissions.Products.Update; protected override string UpdatePolicyName { get; set; } = ProductsPermissions.Products.Update;
protected override string GetPolicyName { get; set; } = ProductsPermissions.Products.Default; protected override string GetPolicyName { get; set; } = null;
protected override string GetListPolicyName { get; set; } = ProductsPermissions.Products.Default; protected override string GetListPolicyName { get; set; } = ProductsPermissions.Products.Default;
private readonly IProductRepository _productRepository; private readonly IProductRepository _productRepository;
......
...@@ -7,7 +7,9 @@ using EasyAbp.EShop.Products.ProductCategories; ...@@ -7,7 +7,9 @@ using EasyAbp.EShop.Products.ProductCategories;
using EasyAbp.EShop.Products.ProductDetails; using EasyAbp.EShop.Products.ProductDetails;
using EasyAbp.EShop.Products.Products.Dtos; using EasyAbp.EShop.Products.Products.Dtos;
using EasyAbp.EShop.Products.ProductStores; using EasyAbp.EShop.Products.ProductStores;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
...@@ -19,8 +21,8 @@ namespace EasyAbp.EShop.Products.Products ...@@ -19,8 +21,8 @@ namespace EasyAbp.EShop.Products.Products
protected override string CreatePolicyName { get; set; } = ProductsPermissions.Products.Create; protected override string CreatePolicyName { get; set; } = ProductsPermissions.Products.Create;
protected override string DeletePolicyName { get; set; } = ProductsPermissions.Products.Delete; protected override string DeletePolicyName { get; set; } = ProductsPermissions.Products.Delete;
protected override string UpdatePolicyName { get; set; } = ProductsPermissions.Products.Update; protected override string UpdatePolicyName { get; set; } = ProductsPermissions.Products.Update;
protected override string GetPolicyName { get; set; } = ProductsPermissions.Products.Default; protected override string GetPolicyName { get; set; } = null;
protected override string GetListPolicyName { get; set; } = ProductsPermissions.Products.Default; protected override string GetListPolicyName { get; set; } = null;
private readonly ISerializedAttributeOptionIdsFormatter _serializedAttributeOptionIdsFormatter; private readonly ISerializedAttributeOptionIdsFormatter _serializedAttributeOptionIdsFormatter;
private readonly IProductStoreRepository _productStoreRepository; private readonly IProductStoreRepository _productStoreRepository;
...@@ -175,7 +177,17 @@ namespace EasyAbp.EShop.Products.Products ...@@ -175,7 +177,17 @@ namespace EasyAbp.EShop.Products.Products
return dto; return dto;
} }
public override Task<PagedResultDto<ProductDto>> GetListAsync(GetProductListDto input)
{
if (input.ShowHidden)
{
AuthorizationService.CheckAsync(ProductsPermissions.Products.Default);
}
return base.GetListAsync(input);
}
public async Task DeleteAsync(Guid id, Guid storeId) public async Task DeleteAsync(Guid id, Guid storeId)
{ {
await CheckDeletePolicyAsync(); await CheckDeletePolicyAsync();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment