f
This commit is contained in:
@@ -415,6 +415,27 @@ func (s *ProductApplicationServiceImpl) GetAvailableProducts(ctx context.Context
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ListProductsForAI 获取产品列表(AI专用)
|
||||
// 业务流程:1. 获取全部产品(含禁用/隐藏) 2. 构建AI响应数据(无用户状态、成本价、备注)
|
||||
func (s *ProductApplicationServiceImpl) ListProductsForAI(ctx context.Context, filters map[string]interface{}, options interfaces.ListOptions) (*responses.ProductAIListResponse, error) {
|
||||
products, total, err := s.productManagementService.ListProducts(ctx, filters, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
items := make([]responses.ProductAIInfoResponse, len(products))
|
||||
for i := range products {
|
||||
items[i] = *s.convertToProductAIInfoResponse(products[i])
|
||||
}
|
||||
|
||||
return &responses.ProductAIListResponse{
|
||||
Total: total,
|
||||
Page: options.Page,
|
||||
Size: options.PageSize,
|
||||
Items: items,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ListProductsForAdmin 获取产品列表(管理员专用)
|
||||
// 业务流程:1. 获取所有产品列表(包括隐藏的) 2. 构建管理员响应数据
|
||||
func (s *ProductApplicationServiceImpl) ListProductsForAdmin(ctx context.Context, filters map[string]interface{}, options interfaces.ListOptions) (*responses.ProductAdminListResponse, error) {
|
||||
@@ -546,6 +567,55 @@ func (s *ProductApplicationServiceImpl) convertToProductInfoResponse(product *en
|
||||
return response
|
||||
}
|
||||
|
||||
// convertToProductAIInfoResponse 转换为AI产品信息响应
|
||||
func (s *ProductApplicationServiceImpl) convertToProductAIInfoResponse(product *entities.Product) *responses.ProductAIInfoResponse {
|
||||
response := &responses.ProductAIInfoResponse{
|
||||
ID: product.ID,
|
||||
OldID: product.OldID,
|
||||
Name: product.Name,
|
||||
Code: product.Code,
|
||||
Description: product.Description,
|
||||
Content: product.Content,
|
||||
CategoryID: product.CategoryID,
|
||||
SubCategoryID: product.SubCategoryID,
|
||||
Price: product.Price.InexactFloat64(),
|
||||
IsEnabled: product.IsEnabled,
|
||||
IsVisible: product.IsVisible,
|
||||
IsPackage: product.IsPackage,
|
||||
SellUIComponent: product.SellUIComponent,
|
||||
UIComponentPrice: product.UIComponentPrice.InexactFloat64(),
|
||||
SEOTitle: product.SEOTitle,
|
||||
SEODescription: product.SEODescription,
|
||||
SEOKeywords: product.SEOKeywords,
|
||||
CreatedAt: product.CreatedAt,
|
||||
UpdatedAt: product.UpdatedAt,
|
||||
}
|
||||
|
||||
if product.Category != nil {
|
||||
response.Category = s.convertToCategoryInfoResponse(product.Category)
|
||||
}
|
||||
|
||||
if product.SubCategory != nil {
|
||||
response.SubCategory = s.convertToSubCategoryInfoResponse(product.SubCategory)
|
||||
}
|
||||
|
||||
if product.IsPackage && len(product.PackageItems) > 0 {
|
||||
response.PackageItems = make([]*responses.PackageItemAIResponse, len(product.PackageItems))
|
||||
for i, item := range product.PackageItems {
|
||||
response.PackageItems[i] = &responses.PackageItemAIResponse{
|
||||
ID: item.ID,
|
||||
ProductID: item.ProductID,
|
||||
ProductCode: item.Product.Code,
|
||||
ProductName: item.Product.Name,
|
||||
SortOrder: item.SortOrder,
|
||||
Price: item.Product.Price.InexactFloat64(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
// convertToProductAdminInfoResponse 转换为管理员产品信息响应
|
||||
func (s *ProductApplicationServiceImpl) convertToProductAdminInfoResponse(product *entities.Product) *responses.ProductAdminInfoResponse {
|
||||
response := &responses.ProductAdminInfoResponse{
|
||||
|
||||
Reference in New Issue
Block a user