|
|
@@ -32,17 +32,19 @@ namespace ShwasherSys.ProductInfo
|
|
|
{
|
|
|
public ProductPropertyAppService(
|
|
|
ICacheManager cacheManager,
|
|
|
- IRepository<ProductProperty, int> repository, IRepository<Product, string> productRepository, IRepository<BusinessLog> logRepository) : base(repository, "Id")
|
|
|
+ IRepository<ProductProperty, int> repository, IRepository<Product, string> productRepository, IRepository<SemiProducts, string> semiProductRepository, IRepository<BusinessLog> logRepository) : base(repository, "Id")
|
|
|
{
|
|
|
LogRepository = logRepository;
|
|
|
ProductRepository = productRepository;
|
|
|
CacheManager = cacheManager;
|
|
|
+ SemiProductRepository = semiProductRepository;
|
|
|
}
|
|
|
|
|
|
protected override bool KeyIsAuto { get; set; } = true;
|
|
|
|
|
|
protected IRepository<BusinessLog> LogRepository;
|
|
|
protected IRepository<Product, string> ProductRepository { get; }
|
|
|
+ protected IRepository<SemiProducts, string> SemiProductRepository { get; }
|
|
|
|
|
|
#region GetSelect
|
|
|
|
|
|
@@ -186,9 +188,10 @@ namespace ShwasherSys.ProductInfo
|
|
|
string propertyNo = input.PropertyNo;
|
|
|
string type = input.PropertyType;
|
|
|
Product entity = await IsExistProduct(type, propertyNo);
|
|
|
- if (entity != null)
|
|
|
+ SemiProducts semiEntity = await IsExistSemiProduct(type, propertyNo);
|
|
|
+ if (entity != null || semiEntity != null)
|
|
|
{
|
|
|
- CheckErrors($"该属性已经被产品使用,不可进行修改!产品编号:[{entity.Id}]");
|
|
|
+ CheckErrors($"该属性已经被产品使用,不可进行修改!产品编号:[{entity?.Id}--{semiEntity.Id}]");
|
|
|
}
|
|
|
var checkEntity =
|
|
|
(await Repository.GetAllListAsync(i =>
|
|
|
@@ -206,9 +209,10 @@ namespace ShwasherSys.ProductInfo
|
|
|
{
|
|
|
var checkEntity = Repository.Get(input.Id);
|
|
|
Product entity = await IsExistProduct(checkEntity.PropertyType, checkEntity.PropertyNo);
|
|
|
- if (entity != null)
|
|
|
+ SemiProducts semiEntity = await IsExistSemiProduct(checkEntity.PropertyType, checkEntity.PropertyNo);
|
|
|
+ if (entity != null || semiEntity != null)
|
|
|
{
|
|
|
- CheckErrors($"该属性已经被产品使用,不可进行删除!产品编号:[{entity.Id}]");
|
|
|
+ CheckErrors($"该属性已经被产品使用,不可进行删除!产品编号:[{entity?.Id}--{semiEntity.Id}]");
|
|
|
}
|
|
|
await Repository.DeleteAsync(input.Id);
|
|
|
}
|
|
|
@@ -236,6 +240,30 @@ namespace ShwasherSys.ProductInfo
|
|
|
|
|
|
return entity;
|
|
|
}
|
|
|
+ private async Task<SemiProducts> IsExistSemiProduct(string type, string propertyNo)
|
|
|
+ {
|
|
|
+ SemiProducts entity = null;
|
|
|
+ switch (type)
|
|
|
+ {
|
|
|
+ case "1":
|
|
|
+ entity = await SemiProductRepository.FirstOrDefaultAsync(i => i.ModelNo == propertyNo);
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ entity = await SemiProductRepository.FirstOrDefaultAsync(i => i.MaterialNo == propertyNo);
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ entity = await SemiProductRepository.FirstOrDefaultAsync(i => i.RigidityNo == propertyNo);
|
|
|
+ break;
|
|
|
+ case "4":
|
|
|
+ entity = await SemiProductRepository.FirstOrDefaultAsync(i => i.SurfaceColorNo == propertyNo);
|
|
|
+ break;
|
|
|
+ case "5":
|
|
|
+ entity = await SemiProductRepository.FirstOrDefaultAsync(i => i.SpecialNo == propertyNo);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ return entity;
|
|
|
+ }
|
|
|
[DisableAuditing]
|
|
|
[AbpAuthorize(PermissionNames.PagesProductInfoProductPropertyQuery)]
|
|
|
public override async Task<PagedResultDto<ProductPropertyDto>> GetAll(IwbPagedRequestDto input)
|