Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
EShop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
EShop
Commits
3cc79680
Commit
3cc79680
authored
Apr 29, 2020
by
gdlcf88
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Permission check for unpublished products, close #14
parent
1898c1ac
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
78 additions
and
15 deletions
+78
-15
IProductAppService.cs
...cts/EasyAbp/EShop/Products/Products/IProductAppService.cs
+2
-0
CategoryAppService.cs
...n/EasyAbp/EShop/Products/Categories/CategoryAppService.cs
+7
-4
NotAllowedToGetCategoryListWithShowHiddenException.cs
...ies/NotAllowedToGetCategoryListWithShowHiddenException.cs
+12
-0
NotAllowedToGetProductListWithShowHiddenException.cs
...ucts/NotAllowedToGetProductListWithShowHiddenException.cs
+13
-0
ProductAppService.cs
...tion/EasyAbp/EShop/Products/Products/ProductAppService.cs
+39
-6
EditModal.cshtml.cs
...Pages/EShop/Products/Products/Product/EditModal.cshtml.cs
+2
-2
CreateModal.cshtml.cs
.../EShop/Products/Products/ProductSku/CreateModal.cshtml.cs
+1
-1
EditModal.cshtml.cs
...es/EShop/Products/Products/ProductSku/EditModal.cshtml.cs
+1
-1
Index.cshtml.cs
.../Pages/EShop/Products/Products/ProductSku/Index.cshtml.cs
+1
-1
No files found.
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/IProductAppService.cs
View file @
3cc79680
...
@@ -20,6 +20,8 @@ namespace EasyAbp.EShop.Products.Products
...
@@ -20,6 +20,8 @@ namespace EasyAbp.EShop.Products.Products
Task
<
ProductDto
>
UpdateSkuAsync
(
Guid
productId
,
Guid
productSkuId
,
Guid
storeId
,
UpdateProductSkuDto
input
);
Task
<
ProductDto
>
UpdateSkuAsync
(
Guid
productId
,
Guid
productSkuId
,
Guid
storeId
,
UpdateProductSkuDto
input
);
Task
<
ProductDto
>
GetAsync
(
Guid
id
,
Guid
storeId
);
Task
<
ProductDto
>
DeleteSkuAsync
(
Guid
productId
,
Guid
productSkuId
,
Guid
storeId
);
Task
<
ProductDto
>
DeleteSkuAsync
(
Guid
productId
,
Guid
productSkuId
,
Guid
storeId
);
}
}
}
}
\ No newline at end of file
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Categories/CategoryAppService.cs
View file @
3cc79680
...
@@ -32,14 +32,17 @@ namespace EasyAbp.EShop.Products.Categories
...
@@ -32,14 +32,17 @@ 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
)
public
override
async
Task
<
PagedResultDto
<
CategoryDto
>>
GetListAsync
(
GetCategoryListDto
input
)
{
{
if
(
input
.
ShowHidden
)
// Todo: Check if current user is an admin of the store.
var
isCurrentUserStoreAdmin
=
true
;
if
(
input
.
ShowHidden
&&
(!
isCurrentUserStoreAdmin
||
!
await
AuthorizationService
.
IsGrantedAsync
(
ProductsPermissions
.
Categories
.
Default
)))
{
{
AuthorizationService
.
CheckAsync
(
ProductsPermissions
.
Products
.
Default
);
throw
new
NotAllowedToGetCategoryListWithShowHiddenException
(
);
}
}
return
base
.
GetListAsync
(
input
);
return
await
base
.
GetListAsync
(
input
);
}
}
}
}
}
}
\ No newline at end of file
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Categories/NotAllowedToGetCategoryListWithShowHiddenException.cs
0 → 100644
View file @
3cc79680
using
Volo.Abp
;
namespace
EasyAbp.EShop.Products.Categories
{
public
class
NotAllowedToGetCategoryListWithShowHiddenException
:
BusinessException
{
public
NotAllowedToGetCategoryListWithShowHiddenException
()
:
base
(
message
:
$"You have no permission to get category list with hidden categories."
)
{
}
}
}
\ No newline at end of file
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/NotAllowedToGetProductListWithShowHiddenException.cs
0 → 100644
View file @
3cc79680
using
System
;
using
Volo.Abp
;
namespace
EasyAbp.EShop.Products.Products
{
public
class
NotAllowedToGetProductListWithShowHiddenException
:
BusinessException
{
public
NotAllowedToGetProductListWithShowHiddenException
()
:
base
(
message
:
$"You have no permission to get product list with hidden products."
)
{
}
}
}
\ No newline at end of file
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductAppService.cs
View file @
3cc79680
...
@@ -163,29 +163,62 @@ namespace EasyAbp.EShop.Products.Products
...
@@ -163,29 +163,62 @@ namespace EasyAbp.EShop.Products.Products
}
}
[
RemoteService
(
false
)]
[
RemoteService
(
false
)]
public
override
async
Task
DeleteAsync
(
Guid
id
)
public
override
Task
DeleteAsync
(
Guid
id
)
{
{
throw
new
NotImplementedException
();
throw
new
NotImplementedException
();
}
}
public
override
async
Task
<
ProductDto
>
GetAsync
(
Guid
id
)
[
RemoteService
(
false
)]
public
override
Task
<
ProductDto
>
GetAsync
(
Guid
id
)
{
throw
new
NotImplementedException
();
}
public
virtual
async
Task
<
ProductDto
>
GetAsync
(
Guid
id
,
Guid
storeId
)
{
{
var
dto
=
await
base
.
GetAsync
(
id
);
var
dto
=
await
base
.
GetAsync
(
id
);
if
(!
dto
.
IsPublished
)
{
await
CheckStoreIsProductOwnerAsync
(
id
,
storeId
);
}
dto
.
CategoryIds
=
(
await
_productCategoryRepository
.
GetListByProductIdAsync
(
dto
.
Id
))
dto
.
CategoryIds
=
(
await
_productCategoryRepository
.
GetListByProductIdAsync
(
dto
.
Id
))
.
Select
(
x
=>
x
.
CategoryId
).
ToList
();
.
Select
(
x
=>
x
.
CategoryId
).
ToList
();
return
dto
;
return
dto
;
}
}
public
override
Task
<
PagedResultDto
<
ProductDto
>>
GetListAsync
(
GetProductListDto
input
)
public
override
async
Task
<
PagedResultDto
<
ProductDto
>>
GetListAsync
(
GetProductListDto
input
)
{
{
if
(
input
.
ShowHidden
)
await
CheckGetListPolicyAsync
();
// Todo: Check if current user is an admin of the store.
var
isCurrentUserStoreAdmin
=
true
;
if
(
input
.
ShowHidden
&&
(!
isCurrentUserStoreAdmin
||
!
await
AuthorizationService
.
IsGrantedAsync
(
ProductsPermissions
.
Products
.
Default
)))
{
{
AuthorizationService
.
CheckAsync
(
ProductsPermissions
.
Products
.
Default
);
throw
new
NotAllowedToGetProductListWithShowHiddenException
(
);
}
}
return
base
.
GetListAsync
(
input
);
var
query
=
CreateFilteredQuery
(
input
);
if
(!
isCurrentUserStoreAdmin
)
{
query
=
query
.
Where
(
x
=>
x
.
IsPublished
);
}
var
totalCount
=
await
AsyncQueryableExecuter
.
CountAsync
(
query
);
query
=
ApplySorting
(
query
,
input
);
query
=
ApplyPaging
(
query
,
input
);
var
entities
=
await
AsyncQueryableExecuter
.
ToListAsync
(
query
);
return
new
PagedResultDto
<
ProductDto
>(
totalCount
,
entities
.
Select
(
MapToGetListOutputDto
).
ToList
()
);
}
}
public
async
Task
DeleteAsync
(
Guid
id
,
Guid
storeId
)
public
async
Task
DeleteAsync
(
Guid
id
,
Guid
storeId
)
...
...
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/Pages/EShop/Products/Products/Product/EditModal.cshtml.cs
View file @
3cc79680
...
@@ -58,7 +58,7 @@ namespace EasyAbp.EShop.Products.Web.Pages.EShop.Products.Products.Product
...
@@ -58,7 +58,7 @@ namespace EasyAbp.EShop.Products.Web.Pages.EShop.Products.Products.Product
{
MaxResultCount
=
LimitedResultRequestDto
.
MaxMaxResultCount
}))?.
Items
{
MaxResultCount
=
LimitedResultRequestDto
.
MaxMaxResultCount
}))?.
Items
.
Select
(
dto
=>
new
SelectListItem
(
dto
.
DisplayName
,
dto
.
Id
.
ToString
())).
ToList
();
.
Select
(
dto
=>
new
SelectListItem
(
dto
.
DisplayName
,
dto
.
Id
.
ToString
())).
ToList
();
var
productDto
=
await
_service
.
GetAsync
(
Id
);
var
productDto
=
await
_service
.
GetAsync
(
Id
,
storeId
);
var
detailDto
=
await
_productDetailAppService
.
GetAsync
(
productDto
.
ProductDetailId
);
var
detailDto
=
await
_productDetailAppService
.
GetAsync
(
productDto
.
ProductDetailId
);
...
@@ -75,7 +75,7 @@ namespace EasyAbp.EShop.Products.Web.Pages.EShop.Products.Products.Product
...
@@ -75,7 +75,7 @@ namespace EasyAbp.EShop.Products.Web.Pages.EShop.Products.Products.Product
public
virtual
async
Task
<
IActionResult
>
OnPostAsync
()
public
virtual
async
Task
<
IActionResult
>
OnPostAsync
()
{
{
var
product
=
await
_service
.
GetAsync
(
Id
);
var
product
=
await
_service
.
GetAsync
(
Id
,
Product
.
StoreId
);
var
detail
=
await
_productDetailAppService
.
GetAsync
(
product
.
ProductDetailId
);
var
detail
=
await
_productDetailAppService
.
GetAsync
(
product
.
ProductDetailId
);
...
...
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/Pages/EShop/Products/Products/ProductSku/CreateModal.cshtml.cs
View file @
3cc79680
...
@@ -44,7 +44,7 @@ namespace EasyAbp.EShop.Products.Web.Pages.EShop.Products.Products.ProductSku
...
@@ -44,7 +44,7 @@ namespace EasyAbp.EShop.Products.Web.Pages.EShop.Products.Products.ProductSku
public
virtual
async
Task
OnGetAsync
()
public
virtual
async
Task
OnGetAsync
()
{
{
var
product
=
await
_productAppService
.
GetAsync
(
ProductId
);
var
product
=
await
_productAppService
.
GetAsync
(
ProductId
,
StoreId
);
Attributes
=
new
Dictionary
<
string
,
ICollection
<
SelectListItem
>>();
Attributes
=
new
Dictionary
<
string
,
ICollection
<
SelectListItem
>>();
...
...
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/Pages/EShop/Products/Products/ProductSku/EditModal.cshtml.cs
View file @
3cc79680
...
@@ -36,7 +36,7 @@ namespace EasyAbp.EShop.Products.Web.Pages.EShop.Products.Products.ProductSku
...
@@ -36,7 +36,7 @@ namespace EasyAbp.EShop.Products.Web.Pages.EShop.Products.Products.ProductSku
public
virtual
async
Task
OnGetAsync
()
public
virtual
async
Task
OnGetAsync
()
{
{
var
product
=
await
_productAppService
.
GetAsync
(
ProductId
);
var
product
=
await
_productAppService
.
GetAsync
(
ProductId
,
StoreId
);
ProductSku
=
ProductSku
=
ObjectMapper
.
Map
<
ProductSkuDto
,
CreateEditProductSkuViewModel
>(
ObjectMapper
.
Map
<
ProductSkuDto
,
CreateEditProductSkuViewModel
>(
...
...
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/Pages/EShop/Products/Products/ProductSku/Index.cshtml.cs
View file @
3cc79680
...
@@ -25,7 +25,7 @@ namespace EasyAbp.EShop.Products.Web.Pages.EShop.Products.Products.ProductSku
...
@@ -25,7 +25,7 @@ namespace EasyAbp.EShop.Products.Web.Pages.EShop.Products.Products.ProductSku
public
virtual
async
Task
OnGetAsync
()
public
virtual
async
Task
OnGetAsync
()
{
{
ProductDisplayName
=
(
await
_productAppService
.
GetAsync
(
ProductId
)).
DisplayName
;
ProductDisplayName
=
(
await
_productAppService
.
GetAsync
(
ProductId
,
StoreId
)).
DisplayName
;
}
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment