Browse Source

make StoreOwner has its own application service and management pages

pull/81/head
RayMMond 6 years ago
parent
commit
530f82e061
  1. 1
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/IOrderManager.cs
  2. 41
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Payments/PaymentAppService.cs
  3. 25
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Refunds/RefundAppService.cs
  4. 8
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Permissions/BasicStorePermissionAuthorizationHandler.cs
  5. 5
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/StoreOwners/Dtos/StoreOwnerDto.cs
  6. 3
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/StoreOwners/IStoreOwnerAppService.cs
  7. 13
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerDuplicatedException.cs
  8. 5
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Stores/Dtos/CreateUpdateStoreDto.cs
  9. 2
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Stores/Dtos/StoreDto.cs
  10. 32
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerAppService.cs
  11. 43
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/Stores/StoreAppService.cs
  12. 9
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoresApplicationAutoMapperProfile.cs
  13. 7
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/cs.json
  14. 7
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/en.json
  15. 7
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/pl.json
  16. 7
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/pt-BR.json
  17. 7
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/sl.json
  18. 7
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/tr.json
  19. 7
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/vi.json
  20. 7
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/zh-Hans.json
  21. 7
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/zh-Hant.json
  22. 10
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/StoreOwners/IStoreOwnerStore.cs
  23. 1
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp.EShop.Stores.Domain.csproj
  24. 4
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/StoreOwners/IStoreOwnerRepository.cs
  25. 24
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerCacheItem.cs
  26. 81
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerStore.cs
  27. 14
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Stores/IStoreManager.cs
  28. 58
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Stores/StoreManager.cs
  29. 3
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.EntityFrameworkCore/EasyAbp/EShop/Stores/EntityFrameworkCore/StoresDbContextModelCreatingExtensions.cs
  30. 15
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.EntityFrameworkCore/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerRepository.cs
  31. 30
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.HttpApi/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerController.cs
  32. 34
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/EasyAbp.EShop.Stores.Web.csproj
  33. 7
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Menus/StoresMenuContributor.cs
  34. 2
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Menus/StoresMenus.cs
  35. 19
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/CreateModal.cshtml
  36. 46
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/CreateModal.cshtml.cs
  37. 20
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/EditModal.cshtml
  38. 53
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/EditModal.cshtml.cs
  39. 61
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/Index.cshtml
  40. 21
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/Index.cshtml.cs
  41. 0
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/Index.css
  42. 87
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/Index.js
  43. 17
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/ViewModels/CreateStoreOwnerViewModel.cs
  44. 2
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Stores/Store/CreateModal.cshtml.cs
  45. 21
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Stores/Store/EditModal.cshtml.cs
  46. 4
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Stores/Store/Index.cshtml
  47. 5
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Stores/Store/ViewModels/CreateEditStoreViewModel.cs
  48. 12
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/StoresWebAutoMapperProfile.cs

1
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/IOrderManager.cs

@ -7,7 +7,6 @@ namespace EasyAbp.EShop.Orders.Orders
public interface IOrderManager : IDomainService
{
Task<Order> DiscountAsync(Order order, Dictionary<string, object> inputExtraProperties);
Task<Order> DiscountAsync(Order order);
Task<Order> CompleteAsync(Order order);
}

41
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Payments/PaymentAppService.cs

@ -26,7 +26,8 @@ namespace EasyAbp.EShop.Payments.Payments
private readonly IPayableChecker _payableChecker;
private readonly IDistributedEventBus _distributedEventBus;
private readonly IOrderAppService _orderAppService;
private readonly IPaymentRepository _repository;
public PaymentAppService(
IPayableChecker payableChecker,
IDistributedEventBus distributedEventBus,
@ -36,33 +37,21 @@ namespace EasyAbp.EShop.Payments.Payments
_payableChecker = payableChecker;
_distributedEventBus = distributedEventBus;
_orderAppService = orderAppService;
_repository = repository;
}
public override async Task<PaymentDto> GetAsync(Guid id)
{
var payment = await base.GetAsync(id);
await AuthorizationService.CheckAsync(GetPolicyName);
if (payment.UserId != CurrentUser.GetId())
{
if (payment.StoreId.HasValue)
{
if (await AuthorizationService.IsStoreOwnerGrantedAsync(payment.StoreId.Value,
PaymentsPermissions.Payments.Manage))
{
return payment;
}
await AuthorizationService.CheckAsync(PaymentsPermissions.Payments.CrossStore);
}
await AuthorizationService.CheckAsync(PaymentsPermissions.Payments.Manage);
}
return payment;
}
protected override IQueryable<Payment> CreateFilteredQuery(GetPaymentListDto input)
{
var query = base.CreateFilteredQuery(input);
@ -80,40 +69,24 @@ namespace EasyAbp.EShop.Payments.Payments
if (input.UserId != CurrentUser.GetId())
{
await AuthorizationService.CheckAsync(PaymentsPermissions.Payments.Manage);
if (input.StoreId.HasValue)
{
await AuthorizationService.CheckStoreOwnerAsync(input.StoreId.Value,
PaymentsPermissions.Payments.Manage);
}
else
{
await AuthorizationService.CheckAsync(PaymentsPermissions.Payments.CrossStore);
}
}
return await base.GetListAsync(input);
}
[Authorize(PaymentsPermissions.Payments.Create)]
public virtual async Task CreateAsync(CreatePaymentDto input)
{
// Todo: should avoid duplicate creations. (concurrent lock)
var orders = new List<OrderDto>();
foreach (var orderId in input.OrderIds)
{
orders.Add(await _orderAppService.GetAsync(orderId));
}
var extraProperties = new Dictionary<string, object> { { "StoreId", orders.First().StoreId } };
await _payableChecker.CheckAsync(input, orders, extraProperties);
// Todo: should avoid duplicate creations.
await _distributedEventBus.PublishAsync(new CreatePaymentEto
var createPaymentEto = new CreatePaymentEto
{
TenantId = CurrentTenant.Id,
UserId = CurrentUser.GetId(),

25
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Refunds/RefundAppService.cs

@ -21,7 +21,7 @@ namespace EasyAbp.EShop.Payments.Refunds
private readonly IPaymentRepository _paymentRepository;
private readonly IRefundRepository _repository;
public RefundAppService(
IPaymentRepository paymentRepository,
IRefundRepository repository) : base(repository)
@ -35,22 +35,15 @@ namespace EasyAbp.EShop.Payments.Refunds
var refund = await base.GetAsync(id);
var payment = await _paymentRepository.GetAsync(refund.PaymentId);
if (payment.UserId != CurrentUser.GetId())
{
if (payment.StoreId.HasValue)
{
await AuthorizationService.CheckStoreOwnerAsync(payment.StoreId.Value, PaymentsPermissions.Refunds.Manage);
}
else
{
await AuthorizationService.CheckAsync(PaymentsPermissions.Refunds.Manage);
}
await AuthorizationService.CheckAsync(PaymentsPermissions.Refunds.Manage);
}
return refund;
}
protected override IQueryable<Refund> CreateFilteredQuery(GetRefundListDto input)
{
var query = input.UserId.HasValue ? _repository.GetQueryableByUserId(input.UserId.Value) : _repository;
@ -63,16 +56,6 @@ namespace EasyAbp.EShop.Payments.Refunds
if (input.UserId != CurrentUser.GetId())
{
await AuthorizationService.CheckAsync(PaymentsPermissions.Refunds.Manage);
if (input.StoreId.HasValue)
{
await AuthorizationService.CheckStoreOwnerAsync(input.StoreId.Value,
PaymentsPermissions.Refunds.Manage);
}
else
{
await AuthorizationService.CheckAsync(PaymentsPermissions.Refunds.CrossStore);
}
}
return await base.GetListAsync(input);

8
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Permissions/BasicStorePermissionAuthorizationHandler.cs

@ -9,13 +9,13 @@ namespace EasyAbp.EShop.Stores.Permissions
{
public class BasicStorePermissionAuthorizationHandler : AuthorizationHandler<StorePermissionAuthorizationRequirement>
{
private readonly IStoreOwnerAppService _storeOwnerAppService;
private readonly IStoreOwnerStore _storeOwnerStore;
private readonly IPermissionChecker _permissionChecker;
public BasicStorePermissionAuthorizationHandler(IStoreOwnerAppService storeOwnerAppService,
public BasicStorePermissionAuthorizationHandler(IStoreOwnerStore storeOwnerStore,
IPermissionChecker permissionChecker)
{
_storeOwnerAppService = storeOwnerAppService;
_storeOwnerStore = storeOwnerStore;
_permissionChecker = permissionChecker;
}
@ -24,7 +24,7 @@ namespace EasyAbp.EShop.Stores.Permissions
var userId = context.User?.FindUserId();
if (userId.HasValue)
{
var isStoreOwner = await _storeOwnerAppService.IsStoreOwnerAsync(requirement.StoreId, userId.Value);
var isStoreOwner = await _storeOwnerStore.IsStoreOwnerAsync(requirement.StoreId, userId.Value);
if (isStoreOwner)
{

5
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/StoreOwners/Dtos/StoreOwnerDto.cs

@ -1,12 +1,15 @@
using System;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos;
namespace EasyAbp.EShop.Stores.StoreOwners.Dtos
{
public class StoreOwnerDto : AuditedEntityDto<Guid>
public class StoreOwnerDto : ExtensibleFullAuditedEntityDto<Guid>
{
[Required]
public Guid StoreId { get; set; }
[Required]
public Guid OwnerId { get; set; }
}
}

3
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/StoreOwners/IStoreOwnerAppService.cs

@ -6,11 +6,10 @@ using Volo.Abp.Application.Services;
namespace EasyAbp.EShop.Stores.StoreOwners
{
public interface IStoreOwnerAppService :
IReadOnlyAppService<
ICrudAppService<
StoreOwnerDto,
Guid,
GetStoreOwnerListDto>
{
Task<bool> IsStoreOwnerAsync(Guid storeId, Guid userId);
}
}

13
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerDuplicatedException.cs

@ -0,0 +1,13 @@
using System;
using Volo.Abp;
namespace EasyAbp.EShop.Stores.StoreOwners
{
public class StoreOwnerDuplicatedException : BusinessException
{
public StoreOwnerDuplicatedException(Guid storeId, Guid ownerId) : base(
message: $"Owner {ownerId} is duplicate for the store {storeId}")
{
}
}
}

5
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Stores/Dtos/CreateUpdateStoreDto.cs

@ -10,9 +10,6 @@ namespace EasyAbp.EShop.Stores.Stores.Dtos
{
[Required]
[DisplayName("StoreName")]
public string Name { get; set; }
[DisplayName("StoreOwner")]
public ICollection<Guid> OwnerIds { get; set; }
public string Name { get; set; }
}
}

2
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Stores/Dtos/StoreDto.cs

@ -1,10 +1,12 @@
using System;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos;
namespace EasyAbp.EShop.Stores.Stores.Dtos
{
public class StoreDto : ExtensibleAuditedEntityDto<Guid>
{
[Required]
public string Name { get; set; }
}
}

32
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerAppService.cs

@ -8,9 +8,13 @@ using Volo.Abp.Application.Services;
namespace EasyAbp.EShop.Stores.StoreOwners
{
public class StoreOwnerAppService : ReadOnlyAppService<StoreOwner, StoreOwnerDto, Guid, GetStoreOwnerListDto>,
public class StoreOwnerAppService : CrudAppService<StoreOwner, StoreOwnerDto, Guid, GetStoreOwnerListDto>,
IStoreOwnerAppService
{
protected override string CreatePolicyName { get; set; } = StoresPermissions.Stores.Manage;
protected override string DeletePolicyName { get; set; } = StoresPermissions.Stores.Manage;
protected override string UpdatePolicyName { get; set; } = StoresPermissions.Stores.Manage;
protected override string GetPolicyName { get; set; } = StoresPermissions.Stores.Manage;
protected override string GetListPolicyName { get; set; } = StoresPermissions.Stores.Manage;
private readonly IStoreOwnerRepository _repository;
@ -20,6 +24,16 @@ namespace EasyAbp.EShop.Stores.StoreOwners
_repository = repository;
}
public override async Task<StoreOwnerDto> CreateAsync(StoreOwnerDto input)
{
if (await _repository.IsExistAsync(input.StoreId, input.OwnerId))
{
throw new StoreOwnerDuplicatedException(input.StoreId, input.OwnerId);
}
return await base.CreateAsync(input);
}
protected override IQueryable<StoreOwner> CreateFilteredQuery(GetStoreOwnerListDto input)
{
var queryable = Repository.AsQueryable();
@ -36,19 +50,5 @@ namespace EasyAbp.EShop.Stores.StoreOwners
return queryable;
}
[RemoteService(false)]
public override Task<StoreOwnerDto> GetAsync(Guid id)
{
throw new NotSupportedException();
}
[RemoteService(false)]
public async Task<bool> IsStoreOwnerAsync(Guid storeId, Guid userId)
{
var storeOwner = await _repository.FindAsync(x => x.OwnerId == userId && x.StoreId == storeId, false);
return storeOwner != null;
}
}
}
}

43
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/Stores/StoreAppService.cs

@ -1,22 +1,27 @@
using EasyAbp.EShop.Stores.Stores.Dtos;
using System;
using System.Threading.Tasks;
using EasyAbp.EShop.Stores.Permissions;
using EasyAbp.EShop.Stores.Stores.Dtos;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
namespace EasyAbp.EShop.Stores.Stores
{
public class StoreAppService : CrudAppService<Store, StoreDto, Guid, PagedAndSortedResultRequestDto, CreateUpdateStoreDto, CreateUpdateStoreDto>,
public class StoreAppService : CrudAppService<Store, StoreDto, Guid, PagedAndSortedResultRequestDto,
CreateUpdateStoreDto, CreateUpdateStoreDto>,
IStoreAppService
{
protected override string CreatePolicyName { get; set; } = StoresPermissions.Stores.Create;
protected override string DeletePolicyName { get; set; } = StoresPermissions.Stores.Delete;
protected override string UpdatePolicyName { get; set; } = StoresPermissions.Stores.Update;
protected override string GetPolicyName { get; set; } = StoresPermissions.Stores.Default;
protected override string GetListPolicyName { get; set; } = StoresPermissions.Stores.Default;
private readonly IStoreRepository _repository;
private readonly IStoreManager _storeManager;
public StoreAppService(IStoreRepository repository,
IStoreManager storeManager) : base(repository)
public StoreAppService(IStoreRepository repository) : base(repository)
{
_repository = repository;
_storeManager = storeManager;
}
public async Task<StoreDto> GetDefaultAsync()
@ -24,31 +29,5 @@ namespace EasyAbp.EShop.Stores.Stores
// Todo: need to be improved
return ObjectMapper.Map<Store, StoreDto>(await _repository.FindDefaultStoreAsync());
}
public override async Task<StoreDto> CreateAsync(CreateUpdateStoreDto input)
{
await CheckCreatePolicyAsync();
var entity = MapToEntity(input);
TryToSetTenantId(entity);
entity = await _storeManager.CreateAsync(entity, input.OwnerIds);
return MapToGetOutputDto(entity);
}
public override async Task<StoreDto> UpdateAsync(Guid id, CreateUpdateStoreDto input)
{
await CheckUpdatePolicyAsync();
var entity = await GetEntityByIdAsync(id);
MapToEntity(input, entity);
entity = await _storeManager.UpdateAsync(entity, input.OwnerIds);
return MapToGetOutputDto(entity);
}
}
}

9
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoresApplicationAutoMapperProfile.cs

@ -17,11 +17,12 @@ namespace EasyAbp.EShop.Stores
CreateMap<Store, StoreDto>()
.MapExtraProperties(MappingPropertyDefinitionChecks.Both);
CreateMap<CreateUpdateStoreDto, Store>(MemberList.Source)
.MapExtraProperties(MappingPropertyDefinitionChecks.Both)
.ForSourceMember(x => x.OwnerIds, opt => opt.DoNotValidate());
CreateMap<StoreOwner, StoreOwnerDto>();
.MapExtraProperties(MappingPropertyDefinitionChecks.Both);
CreateMap<StoreOwner, StoreOwnerDto>()
.MapExtraProperties(MappingPropertyDefinitionChecks.Both);
CreateMap<StoreOwnerDto, StoreOwner>(MemberList.Source)
.MapExtraProperties(MappingPropertyDefinitionChecks.Both);
}
}
}

7
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/cs.json

@ -7,6 +7,11 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"StoreOwner": "StoreOwner",
"Menu:StoreOwner": "MenuStoreOwner",
"CreateStoreOwner": "CreateStoreOwner",
"EditStoreOwner": "EditStoreOwner",
"StoreOwnerDeletionConfirmationMessage": "Are you sure to delete the store owner {0}?"
}
}

7
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/en.json

@ -8,6 +8,11 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"StoreOwner": "StoreOwner",
"Menu:StoreOwner": "MenuStoreOwner",
"CreateStoreOwner": "CreateStoreOwner",
"EditStoreOwner": "EditStoreOwner",
"StoreOwnerDeletionConfirmationMessage": "Are you sure to delete the store owner {0}?"
}
}

7
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/pl.json

@ -7,6 +7,11 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"StoreOwner": "StoreOwner",
"Menu:StoreOwner": "MenuStoreOwner",
"CreateStoreOwner": "CreateStoreOwner",
"EditStoreOwner": "EditStoreOwner",
"StoreOwnerDeletionConfirmationMessage": "Are you sure to delete the store owner {0}?"
}
}

7
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/pt-BR.json

@ -7,6 +7,11 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"StoreOwner": "StoreOwner",
"Menu:StoreOwner": "MenuStoreOwner",
"CreateStoreOwner": "CreateStoreOwner",
"EditStoreOwner": "EditStoreOwner",
"StoreOwnerDeletionConfirmationMessage": "Are you sure to delete the store owner {0}?"
}
}

7
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/sl.json

@ -8,6 +8,11 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"StoreOwner": "StoreOwner",
"Menu:StoreOwner": "MenuStoreOwner",
"CreateStoreOwner": "CreateStoreOwner",
"EditStoreOwner": "EditStoreOwner",
"StoreOwnerDeletionConfirmationMessage": "Are you sure to delete the store owner {0}?"
}
}

7
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/tr.json

@ -8,6 +8,11 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"StoreOwner": "StoreOwner",
"Menu:StoreOwner": "MenuStoreOwner",
"CreateStoreOwner": "CreateStoreOwner",
"EditStoreOwner": "EditStoreOwner",
"StoreOwnerDeletionConfirmationMessage": "Are you sure to delete the store owner {0}?"
}
}

7
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/vi.json

@ -7,6 +7,11 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"StoreOwner": "StoreOwner",
"Menu:StoreOwner": "MenuStoreOwner",
"CreateStoreOwner": "CreateStoreOwner",
"EditStoreOwner": "EditStoreOwner",
"StoreOwnerDeletionConfirmationMessage": "Are you sure to delete the store owner {0}?"
}
}

7
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/zh-Hans.json

@ -8,6 +8,11 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"StoreOwner": "StoreOwner",
"Menu:StoreOwner": "MenuStoreOwner",
"CreateStoreOwner": "CreateStoreOwner",
"EditStoreOwner": "EditStoreOwner",
"StoreOwnerDeletionConfirmationMessage": "Are you sure to delete the store owner {0}?"
}
}

7
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/zh-Hant.json

@ -8,6 +8,11 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"StoreOwner": "StoreOwner",
"Menu:StoreOwner": "MenuStoreOwner",
"CreateStoreOwner": "CreateStoreOwner",
"EditStoreOwner": "EditStoreOwner",
"StoreOwnerDeletionConfirmationMessage": "Are you sure to delete the store owner {0}?"
}
}

10
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/StoreOwners/IStoreOwnerStore.cs

@ -0,0 +1,10 @@
using System;
using System.Threading.Tasks;
namespace EasyAbp.EShop.Stores.StoreOwners
{
public interface IStoreOwnerStore
{
Task<bool> IsStoreOwnerAsync(Guid storeId, Guid userId);
}
}

1
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp.EShop.Stores.Domain.csproj

@ -8,6 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Caching" Version="3.0.5" />
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="3.0.5" />
<ProjectReference Include="..\EasyAbp.EShop.Stores.Domain.Shared\EasyAbp.EShop.Stores.Domain.Shared.csproj" />
</ItemGroup>

4
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/StoreOwners/IStoreOwnerRepository.cs

@ -11,5 +11,7 @@ namespace EasyAbp.EShop.Stores.StoreOwners
Task<List<StoreOwner>> GetListByStoreIdAsync(Guid storeId, CancellationToken cancellationToken = default);
Task<List<StoreOwner>> GetListByOwnerIdAsync(Guid ownerId, CancellationToken cancellationToken = default);
Task<bool> IsExistAsync(Guid storeId, Guid ownerId, CancellationToken cancellationToken = default);
}
}
}

24
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerCacheItem.cs

@ -0,0 +1,24 @@
using System;
namespace EasyAbp.EShop.Stores.StoreOwners
{
[Serializable]
public class StoreOwnerCacheItem
{
public bool IsOwner { get; set; }
public StoreOwnerCacheItem()
{
}
public StoreOwnerCacheItem(bool isOwner)
{
IsOwner = isOwner;
}
public static string CalculateCacheKey(Guid storeId, Guid userId)
{
return "s:" + storeId.ToString("D") + ",u:" + userId.ToString("D");
}
}
}

81
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerStore.cs

@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection;
namespace EasyAbp.EShop.Stores.StoreOwners
{
public class StoreOwnerStore : IStoreOwnerStore, ITransientDependency
{
protected ILogger<StoreOwnerStore> Logger { get; }
protected IStoreOwnerRepository StoreOwnerRepository { get; }
protected IDistributedCache<StoreOwnerCacheItem> Cache { get; }
public StoreOwnerStore(ILogger<StoreOwnerStore> logger,
IStoreOwnerRepository storeOwnerRepository,
IDistributedCache<StoreOwnerCacheItem> cache)
{
StoreOwnerRepository = storeOwnerRepository;
Cache = cache;
Logger = logger ?? NullLogger<StoreOwnerStore>.Instance;
}
public async Task<bool> IsStoreOwnerAsync(Guid storeId, Guid userId)
{
return (await GetCacheItemAsync(storeId, userId)).IsOwner;
}
protected virtual async Task<StoreOwnerCacheItem> GetCacheItemAsync(Guid storeId, Guid userId)
{
var cacheKey = CalculateCacheKey(storeId, userId);
Logger.LogDebug($"StoreOwnerStore.GetCacheItemAsync: {cacheKey}");
var cacheItem = await Cache.GetAsync(cacheKey);
if (cacheItem != null)
{
Logger.LogDebug($"Found in the cache: {cacheKey}");
return cacheItem;
}
Logger.LogDebug($"Not found in the cache: {cacheKey}");
cacheItem = new StoreOwnerCacheItem(false);
await SetCacheItemsAsync(storeId, userId, cacheItem);
return cacheItem;
}
protected virtual async Task SetCacheItemsAsync(
Guid storeId, Guid userId,
StoreOwnerCacheItem currentCacheItem)
{
var storeOwners = await StoreOwnerRepository.GetListByStoreIdAsync(storeId);
Logger.LogDebug(
$"Getting all store owner in store: {storeId}");
Logger.LogDebug($"Setting the cache items. Count: {storeOwners.Count}");
var cacheItems = new Dictionary<string, StoreOwnerCacheItem>();
foreach (var storeOwner in storeOwners)
{
cacheItems.Add(CalculateCacheKey(storeOwner.StoreId, storeOwner.OwnerId),
new StoreOwnerCacheItem(true));
if (storeOwner.StoreId == storeId && storeOwner.OwnerId == userId)
{
currentCacheItem.IsOwner = true;
}
}
await Cache.SetManyAsync(cacheItems);
Logger.LogDebug($"Finished setting the cache items. Count: {storeOwners.Count}");
}
protected virtual string CalculateCacheKey(Guid storeId, Guid userId)
{
return StoreOwnerCacheItem.CalculateCacheKey(storeId, userId);
}
}
}

14
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Stores/IStoreManager.cs

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Domain.Services;
namespace EasyAbp.EShop.Stores.Stores
{
public interface IStoreManager : IDomainService
{
Task<Store> CreateAsync(Store store, IEnumerable<Guid> ownerIds = null);
Task<Store> UpdateAsync(Store store, IEnumerable<Guid> ownerIds = null);
}
}

58
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Stores/StoreManager.cs

@ -1,58 +0,0 @@
using EasyAbp.EShop.Stores.StoreOwners;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Domain.Services;
namespace EasyAbp.EShop.Stores.Stores
{
public class StoreManager : DomainService, IStoreManager
{
private readonly IStoreRepository _storeRepository;
private readonly IStoreOwnerRepository _storeOwnerRepository;
public StoreManager(IStoreRepository storeRepository,
IStoreOwnerRepository storeOwnerRepository)
{
_storeRepository = storeRepository;
_storeOwnerRepository = storeOwnerRepository;
}
public async Task<Store> CreateAsync(Store store, IEnumerable<Guid> ownerIds = null)
{
store = await _storeRepository.InsertAsync(store);
await UpdateStoreOwnersAsync(store.Id, ownerIds);
return store;
}
public async Task<Store> UpdateAsync(Store store, IEnumerable<Guid> ownerIds = null)
{
store = await _storeRepository.UpdateAsync(store);
await UpdateStoreOwnersAsync(store.Id, ownerIds);
return store;
}
protected virtual async Task UpdateStoreOwnersAsync(Guid storeId, IEnumerable<Guid> ownerIds)
{
ownerIds ??= new List<Guid>();
var storeOwners = await _storeOwnerRepository.GetListByStoreIdAsync(storeId);
foreach (var storeOwner in storeOwners.Where(x => !ownerIds.Contains(x.OwnerId)).ToList())
{
await _storeOwnerRepository.DeleteAsync(storeOwner, true);
}
foreach (var ownerId in ownerIds.Except(storeOwners.Select(x => x.OwnerId).ToList()))
{
await _storeOwnerRepository.InsertAsync(
new StoreOwner(GuidGenerator.Create(), storeId, ownerId, CurrentTenant.Id), true);
}
}
}
}

3
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.EntityFrameworkCore/EasyAbp/EShop/Stores/EntityFrameworkCore/StoresDbContextModelCreatingExtensions.cs

@ -54,6 +54,9 @@ namespace EasyAbp.EShop.Stores.EntityFrameworkCore
b.ToTable(options.TablePrefix + "StoreOwners", options.Schema);
b.ConfigureByConvention();
/* Configure more properties here */
b.HasIndex(x => new {x.StoreId, x.OwnerId})
.IsUnique();
});
}
}

15
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.EntityFrameworkCore/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerRepository.cs

@ -16,14 +16,25 @@ namespace EasyAbp.EShop.Stores.StoreOwners
{
}
public async Task<List<StoreOwner>> GetListByStoreIdAsync(Guid storeId, CancellationToken cancellationToken = default)
public async Task<List<StoreOwner>> GetListByStoreIdAsync(Guid storeId,
CancellationToken cancellationToken = default)
{
return await GetQueryable().Where(pc => pc.StoreId == storeId).ToListAsync(cancellationToken);
}
public async Task<List<StoreOwner>> GetListByOwnerIdAsync(Guid ownerId, CancellationToken cancellationToken = default)
public async Task<List<StoreOwner>> GetListByOwnerIdAsync(Guid ownerId,
CancellationToken cancellationToken = default)
{
return await GetQueryable().Where(pc => pc.OwnerId == ownerId).ToListAsync(cancellationToken);
}
public async Task<bool> IsExistAsync(Guid storeId, Guid ownerId, CancellationToken cancellationToken = default)
{
var storeOwner = await GetQueryable().FirstOrDefaultAsync(
x => x.StoreId == storeId && x.OwnerId == ownerId,
cancellationToken: cancellationToken);
return storeOwner != null;
}
}
}

30
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.HttpApi/EasyAbp/EShop/Stores/StoreOwners/StoreOwnerController.cs

@ -1,13 +1,13 @@
using EasyAbp.EShop.Stores.StoreOwners.Dtos;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
using EasyAbp.EShop.Stores.StoreOwners.Dtos;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
namespace EasyAbp.EShop.Stores.StoreOwners
{
[RemoteService(Name = "EShopStores")]
[RemoteService(Name = "EShopStoreOwners")]
[Route("/api/eShop/stores/storeOwner")]
public class StoreOwnerController : StoresController
{
@ -18,8 +18,8 @@ namespace EasyAbp.EShop.Stores.StoreOwners
_service = service;
}
[NonAction]
[RemoteService(false)]
[HttpGet]
[Route("{id}")]
public Task<StoreOwnerDto> GetAsync(Guid id)
{
return _service.GetAsync(id);
@ -30,5 +30,25 @@ namespace EasyAbp.EShop.Stores.StoreOwners
{
return _service.GetListAsync(input);
}
[HttpPost]
public Task<StoreOwnerDto> CreateAsync(StoreOwnerDto input)
{
return _service.CreateAsync(input);
}
[HttpPut]
[Route("{id}")]
public Task<StoreOwnerDto> UpdateAsync(Guid id, StoreOwnerDto input)
{
return _service.UpdateAsync(id, input);
}
[HttpDelete]
[Route("{id}")]
public Task DeleteAsync(Guid id)
{
return _service.DeleteAsync(id);
}
}
}

34
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/EasyAbp.EShop.Stores.Web.csproj

@ -32,10 +32,44 @@
<Content Remove="Pages\**\*.css" />
<Content Remove="Pages\**\*.js" />
<Content Remove="wwwroot\**\*.*" />
<Content Update="Pages\EShop\Stores\Stores\StoreOwner\CreateModal.cshtml">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="Pages\EShop\Stores\Stores\StoreOwner\EditModal.cshtml">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="Pages\EShop\Stores\Stores\StoreOwner\Index.cshtml">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="Pages\EShop\Stores\StoreOwners" />
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<Compile Update="Pages\EShop\Stores\Stores\StoreOwner\CreateModal.cshtml.cs">
<DependentUpon>CreateModal.cshtml</DependentUpon>
</Compile>
<Compile Update="Pages\EShop\Stores\Stores\StoreOwner\EditModal.cshtml.cs">
<DependentUpon>EditModal.cshtml</DependentUpon>
</Compile>
<Compile Update="Pages\EShop\Stores\Stores\StoreOwner\Index.cshtml.cs">
<DependentUpon>Index.cshtml</DependentUpon>
</Compile>
<Compile Update="Pages\EShop\Stores\StoreOwners\StoreOwner\CreateModal.cshtml.cs">
<DependentUpon>CreateModal.cshtml</DependentUpon>
</Compile>
<Compile Update="Pages\EShop\Stores\StoreOwners\StoreOwner\EditModal.cshtml.cs">
<DependentUpon>EditModal.cshtml</DependentUpon>
</Compile>
<Compile Update="Pages\EShop\Stores\StoreOwners\StoreOwner\Index.cshtml.cs">
<DependentUpon>Index.cshtml</DependentUpon>
</Compile>
</ItemGroup>
</Project>

7
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Menus/StoresMenuContributor.cs

@ -29,6 +29,13 @@ namespace EasyAbp.EShop.Stores.Web.Menus
);
}
if (await context.IsGrantedAsync(StoresPermissions.Stores.Manage))
{
storeManagementMenuItem.AddItem(
new ApplicationMenuItem(StoresMenus.StoreOwner, l["Menu:StoreOwner"], "/EShop/Stores/StoreOwners/StoreOwner")
);
}
if (!storeManagementMenuItem.Items.IsNullOrEmpty())
{
var eShopMenuItem = context.Menu.Items.GetOrAdd(i => i.Name == StoresMenus.ModuleGroupPrefix,

2
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Menus/StoresMenus.cs

@ -7,6 +7,8 @@
public const string Prefix = ModuleGroupPrefix + ".Stores";
public const string Store = Prefix + ".Store";
public const string StoreOwner = Prefix + ".StoreOwner";
//Add your menu items here...
//public const string Home = Prefix + ".MyNewMenuItem";

19
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/CreateModal.cshtml

@ -0,0 +1,19 @@
@page
@using EasyAbp.EShop.Stores.Localization
@using Microsoft.AspNetCore.Mvc.Localization
@using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.StoreOwners.StoreOwner
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
@inject IHtmlLocalizer<StoresResource> L
@model CreateModalModel
@{
Layout = null;
}
<abp-dynamic-form abp-model="StoreOwner" data-ajaxForm="true" asp-page="CreateModal">
<abp-modal>
<abp-modal-header title="@L["CreateStoreOwner"].Value"></abp-modal-header>
<abp-modal-body>
<abp-form-content />
</abp-modal-body>
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer>
</abp-modal>
</abp-dynamic-form>

46
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/CreateModal.cshtml.cs

@ -0,0 +1,46 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EasyAbp.EShop.Stores.StoreOwners;
using EasyAbp.EShop.Stores.StoreOwners.Dtos;
using EasyAbp.EShop.Stores.Stores;
using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.StoreOwners.StoreOwner.ViewModels;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Identity;
namespace EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.StoreOwners.StoreOwner
{
public class CreateModalModel : StoresPageModel
{
[BindProperty]
public CreateEditStoreOwnerViewModel StoreOwner { get; set; }
private readonly IStoreAppService _storeService;
private readonly IIdentityUserAppService _userAppService;
private readonly IStoreOwnerAppService _storeOwnerAppService;
public CreateModalModel(IStoreAppService storeService,
IIdentityUserAppService userAppService,
IStoreOwnerAppService storeOwnerAppService)
{
_storeService = storeService;
_userAppService = userAppService;
_storeOwnerAppService = storeOwnerAppService;
}
public virtual Task OnGetAsync()
{
return Task.CompletedTask;
}
public async Task<IActionResult> OnPostAsync()
{
var createDto = ObjectMapper.Map<CreateEditStoreOwnerViewModel, StoreOwnerDto>(StoreOwner);
var storeOwner = await _storeOwnerAppService.CreateAsync(createDto);
return NoContent();
}
}
}

20
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/EditModal.cshtml

@ -0,0 +1,20 @@
@page
@using EasyAbp.EShop.Stores.Localization
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
@using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.StoreOwners.StoreOwner
@inject IHtmlLocalizer<StoresResource> L
@model EditModalModel
@{
Layout = null;
}
<abp-dynamic-form abp-model="StoreOwner" data-ajaxForm="true" asp-page="EditModal">
<abp-modal>
<abp-modal-header title="@L["EditStore"].Value"></abp-modal-header>
<abp-modal-body>
<abp-input asp-for="Id" />
<abp-form-content />
</abp-modal-body>
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer>
</abp-modal>
</abp-dynamic-form>

53
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/EditModal.cshtml.cs

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EasyAbp.EShop.Stores.StoreOwners;
using EasyAbp.EShop.Stores.StoreOwners.Dtos;
using EasyAbp.EShop.Stores.Stores;
using EasyAbp.EShop.Stores.Stores.Dtos;
using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.StoreOwners.StoreOwner.ViewModels;
using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Stores.Store.ViewModels;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Identity;
namespace EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.StoreOwners.StoreOwner
{
public class EditModalModel : StoresPageModel
{
[HiddenInput]
[BindProperty(SupportsGet = true)]
public Guid Id { get; set; }
[BindProperty] public CreateEditStoreOwnerViewModel StoreOwner { get; set; }
private readonly IStoreAppService _storeService;
private readonly IIdentityUserAppService _userAppService;
private readonly IStoreOwnerAppService _storeOwnerAppService;
public EditModalModel(IStoreAppService storeService,
IIdentityUserAppService userAppService,
IStoreOwnerAppService storeOwnerAppService)
{
_storeService = storeService;
_userAppService = userAppService;
_storeOwnerAppService = storeOwnerAppService;
}
public async Task OnGetAsync()
{
var dto = await _storeOwnerAppService.GetAsync(Id);
StoreOwner = ObjectMapper.Map<StoreOwnerDto, CreateEditStoreOwnerViewModel>(dto);
}
public async Task<IActionResult> OnPostAsync()
{
await _storeOwnerAppService.UpdateAsync(Id,
ObjectMapper.Map<CreateEditStoreOwnerViewModel, StoreOwnerDto>( StoreOwner));
return NoContent();
}
}
}

61
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/Index.cshtml

@ -0,0 +1,61 @@
@page
@using EasyAbp.EShop.Stores.Permissions
@using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.StoreOwners.StoreOwner
@using EasyAbp.EShop.Stores.Localization
@using EasyAbp.EShop.Stores.Web.Menus
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Layout
@model IndexModel
@inject IPageLayout PageLayout
@inject IHtmlLocalizer<StoresResource> L
@inject IAuthorizationService Authorization
@{
PageLayout.Content.Title = L["StoreOwner"].Value;
PageLayout.Content.BreadCrumb.Add(L["Menu:StoreOwner"].Value);
PageLayout.Content.MenuItemName = StoresMenus.StoreOwner;
}
@section scripts
{
<abp-script src="/Pages/EShop/Stores/StoreOwners/StoreOwner/index.js"/>
}
@section styles
{
<abp-style src="/Pages/EShop/Stores/StoreOwners/StoreOwner/index.css"/>
}
<script>
let storeId = '@Model.StoreId';
</script>
<abp-card>
<abp-card-header>
<abp-row>
<abp-column size-md="_6">
<abp-card-title>@L["StoreOwner"]</abp-card-title>
</abp-column>
<abp-column size-md="_6" class="text-right">
@if (await Authorization.IsGrantedAsync(StoresPermissions.Stores.Manage))
{
<abp-button id="NewStoreOwnerButton"
text="@L["CreateStoreOwner"].Value"
icon="plus"
button-type="Primary"/>
}
</abp-column>
</abp-row>
</abp-card-header>
<abp-card-body>
<abp-table striped-rows="true" id="StoreOwnerTable">
<thead>
<tr>
<th>@L["Actions"]</th>
<th>@L["StoreName"]</th>
<th>@L["OwnerName"]</th>
</tr>
</thead>
</abp-table>
</abp-card-body>
</abp-card>

21
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/Index.cshtml.cs

@ -0,0 +1,21 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.StoreOwners.StoreOwner
{
public class IndexModel : StoresPageModel
{
[BindProperty(SupportsGet = true)]
public Guid? StoreId { get; set; }
public IndexModel()
{
}
public Task OnGetAsync()
{
return Task.CompletedTask;
}
}
}

0
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/Index.css

87
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/Index.js

@ -0,0 +1,87 @@
$(function () {
var l = abp.localization.getResource('EasyAbpEShopStores');
var service = easyAbp.eShop.stores.storeOwners.storeOwner;
var storeService = easyAbp.eShop.stores.stores.store;
var userService = volo.abp.identity.identityUser;
var createModal = new abp.ModalManager(abp.appPath + 'EShop/Stores/StoreOwners/StoreOwner/CreateModal');
var editModal = new abp.ModalManager(abp.appPath + 'EShop/Stores/StoreOwners/StoreOwner/EditModal');
var dataTable = $('#StoreOwnerTable').DataTable(abp.libs.datatables.normalizeConfiguration({
processing: true,
serverSide: true,
paging: true,
searching: false,
autoWidth: false,
scrollCollapse: true,
order: [[1, "asc"]],
ajax: abp.libs.datatables.createAjax(service.getList, function () {
return {storeId: storeId}
}),
columnDefs: [
{
rowAction: {
items:
[
{
text: l('Edit'),
action: function (data) {
editModal.open({id: data.record.id});
}
},
{
text: l('Delete'),
confirmMessage: function (data) {
return l('StoreDeletionConfirmationMessage', data.record.id);
},
action: function (data) {
service.delete(data.record.id)
.then(function () {
abp.notify.info(l('SuccessfullyDeleted'));
dataTable.ajax.reload();
});
}
}
]
}
},
{
data: "storeId",
render: function (data, type, row, meta) {
var currentCell = $("#StoreOwnerTable").DataTable().cells({"row":meta.row, "column":meta.col}).nodes(0);
storeService.get(data).then(
x => {
$(currentCell).html(x.name);
});
return '...';
}
},
{
data: "ownerId",
render: function (data, type, row, meta) {
var currentCell = $("#StoreOwnerTable").DataTable().cells({"row":meta.row, "column":meta.col}).nodes(0);
userService.get(data).then(
x=>{
$(currentCell).html(x.userName);
}
);
return '...';
}
}
]
}));
createModal.onResult(function () {
dataTable.ajax.reload();
});
editModal.onResult(function () {
dataTable.ajax.reload();
});
$('#NewStoreOwnerButton').click(function (e) {
e.preventDefault();
createModal.open({storeId: storeId});
});
});

17
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/StoreOwners/StoreOwner/ViewModels/CreateStoreOwnerViewModel.cs

@ -0,0 +1,17 @@
using System;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form;
using Volo.Abp.ObjectExtending;
namespace EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.StoreOwners.StoreOwner.ViewModels
{
public class CreateEditStoreOwnerViewModel : ExtensibleObject
{
[Required]
public Guid StoreId { get; set; }
[Required]
public Guid OwnerId { get; set; }
}
}

2
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Stores/Store/CreateModal.cshtml.cs

@ -39,7 +39,7 @@ namespace EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Stores.Store
public async Task<IActionResult> OnPostAsync()
{
var createDto = ObjectMapper.Map<CreateEditStoreViewModel, CreateUpdateStoreDto>(Store);
var product = await _service.CreateAsync(createDto);
var store = await _service.CreateAsync(createDto);
return NoContent();
}

21
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Stores/Store/EditModal.cshtml.cs

@ -23,36 +23,17 @@ namespace EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Stores.Store
[BindProperty]
public CreateEditStoreViewModel Store { get; set; }
public ICollection<SelectListItem> StoreOwners { get; set; }
private readonly IStoreAppService _service;
private readonly IIdentityUserAppService _userAppService;
private readonly IStoreOwnerAppService _storeOwnerAppService;
public EditModalModel(IStoreAppService service,
IIdentityUserAppService userAppService,
IStoreOwnerAppService storeOwnerAppService)
public EditModalModel(IStoreAppService service)
{
_service = service;
_userAppService = userAppService;
_storeOwnerAppService = storeOwnerAppService;
}
public async Task OnGetAsync()
{
StoreOwners =
(await _userAppService.GetListAsync(new GetIdentityUsersInput
{ MaxResultCount = LimitedResultRequestDto.MaxMaxResultCount })).Items
.Select(x => new SelectListItem(x.UserName, x.Id.ToString())).ToList();
var dto = await _service.GetAsync(Id);
Store = ObjectMapper.Map<StoreDto, CreateEditStoreViewModel>(dto);
Store.OwnerIds = (await _storeOwnerAppService.GetListAsync(new GetStoreOwnerListDto
{
StoreId = Id,
MaxResultCount = LimitedResultRequestDto.MaxMaxResultCount
})).Items.Select(x => x.OwnerId).ToList();
}
public async Task<IActionResult> OnPostAsync()

4
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Stores/Store/Index.cshtml

@ -11,8 +11,8 @@
@inject IHtmlLocalizer<StoresResource> L
@inject IAuthorizationService Authorization
@{
PageLayout.Content.Title = L["BasketItem"].Value;
PageLayout.Content.BreadCrumb.Add(L["Menu:BasketItem"].Value);
PageLayout.Content.Title = L["Store"].Value;
PageLayout.Content.BreadCrumb.Add(L["Menu:Store"].Value);
PageLayout.Content.MenuItemName = StoresMenus.Store;
}

5
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Stores/Store/ViewModels/CreateEditStoreViewModel.cs

@ -11,10 +11,5 @@ namespace EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Stores.Store.ViewModels
[Required]
[Display(Name = "StoreName")]
public string Name { get; set; }
[SelectItems("StoreOwners")]
[Display(Name = "StoreOwner")]
public List<Guid> OwnerIds { get; set; }
}
}

12
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/StoresWebAutoMapperProfile.cs

@ -1,5 +1,7 @@
using EasyAbp.EShop.Stores.Stores.Dtos;
using AutoMapper;
using EasyAbp.EShop.Stores.StoreOwners.Dtos;
using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.StoreOwners.StoreOwner.ViewModels;
using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Stores.Store.ViewModels;
using Volo.Abp.AutoMapper;
using Volo.Abp.ObjectExtending;
@ -14,9 +16,13 @@ namespace EasyAbp.EShop.Stores.Web
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<StoreDto, CreateEditStoreViewModel>()
.MapExtraProperties(MappingPropertyDefinitionChecks.Both)
.Ignore(x=>x.OwnerIds);
CreateMap<CreateEditStoreViewModel, CreateUpdateStoreDto>()
.MapExtraProperties(MappingPropertyDefinitionChecks.Both);
CreateMap<CreateEditStoreViewModel, CreateUpdateStoreDto>(MemberList.Source)
.MapExtraProperties(MappingPropertyDefinitionChecks.Both);
CreateMap<StoreOwnerDto, CreateEditStoreOwnerViewModel>()
.MapExtraProperties(MappingPropertyDefinitionChecks.Both);
CreateMap<CreateEditStoreOwnerViewModel, StoreOwnerDto>(MemberList.Source)
.MapExtraProperties(MappingPropertyDefinitionChecks.Both);
}
}

Loading…
Cancel
Save