This commit is contained in:
2026-03-30 11:07:30 +08:00
parent 2c44b3a4b2
commit d4a8e71733
74 changed files with 1751 additions and 421 deletions

View File

@@ -44,7 +44,9 @@ public class ProductService : IProductService
var qry = _dbContext.Products
.AsNoTracking()
.Include(p => p.Category)
.Where(p => !p.Deleted && p.UserId == userId);
.Where(p => !p.Deleted);
if (userId.HasValue)
qry = qry.Where(p => p.UserId == userId);
if (model.CategoryId > 0)
{
var categoryPath = (await _dbContext.Categories
@@ -74,7 +76,8 @@ public class ProductService : IProductService
public async Task<ApiResponse> EditAsync(EditProductParams model)
{
var userId = _claimsService.GetCurrentUserId();
var userId = _claimsService.GetCurrentUserId()!.Value;
EF.Models.Product? product = null;
if (model.Id > 0)
{
@@ -112,7 +115,7 @@ public class ProductService : IProductService
public async Task<ApiResponse> DeleteAsync(ProductIdParams model)
{
var userId = _claimsService.GetCurrentUserId();
var userId = _claimsService.GetCurrentUserId()!.Value;
var product = await _dbContext.Products
.FirstOrDefaultAsync(p =>
p.Id == model.ProductId
@@ -169,11 +172,11 @@ public class ProductService : IProductService
CreateTime = product.CreateTime.ToFormatted(),
Description = product.Description,
Id = product.Id,
LogoUrl = _fileService.GetFileUrl(Models.UploadScences.Product, product.Logo),
MinimumUnit = product.MinimumUnit,
Name = product.Name,
UnitPrice = product.UnitPrice,
SoldAmount = product.SoldAmount,
LogoUrl = _fileService.GetFileUrl(Models.UploadScences.Product, product.Logo)
};
if (result is ProductInfo)
{
@@ -184,10 +187,5 @@ public class ProductService : IProductService
return result;
}
private string BuildCategoryPath(int categoryId)
{
return $"/{categoryId}/";
}
#endregion
}