This commit is contained in:
2025-08-18 14:13:16 +08:00
parent 9e6248efb2
commit 133e8e7e5a
7 changed files with 285 additions and 29 deletions

View File

@@ -214,13 +214,18 @@ func (s *SubscriptionApplicationServiceImpl) convertToSubscriptionInfoResponse(s
}
}
var productResponse *responses.ProductSimpleResponse
if subscription.Product != nil {
productResponse = s.convertToProductSimpleResponse(subscription.Product)
}
return &responses.SubscriptionInfoResponse{
ID: subscription.ID,
UserID: subscription.UserID,
ProductID: subscription.ProductID,
Price: subscription.Price.InexactFloat64(),
User: userInfo,
Product: s.convertToProductSimpleResponse(subscription.Product),
Product: productResponse,
APIUsed: subscription.APIUsed,
CreatedAt: subscription.CreatedAt,
UpdatedAt: subscription.UpdatedAt,
@@ -229,6 +234,11 @@ func (s *SubscriptionApplicationServiceImpl) convertToSubscriptionInfoResponse(s
// convertToProductSimpleResponse 转换为产品简单信息响应
func (s *SubscriptionApplicationServiceImpl) convertToProductSimpleResponse(product *entities.Product) *responses.ProductSimpleResponse {
var categoryResponse *responses.CategorySimpleResponse
if product.Category != nil {
categoryResponse = s.convertToCategorySimpleResponse(product.Category)
}
return &responses.ProductSimpleResponse{
ID: product.ID,
OldID: product.OldID,
@@ -236,13 +246,17 @@ func (s *SubscriptionApplicationServiceImpl) convertToProductSimpleResponse(prod
Code: product.Code,
Description: product.Description,
Price: product.Price.InexactFloat64(),
Category: s.convertToCategorySimpleResponse(product.Category),
Category: categoryResponse,
IsPackage: product.IsPackage,
}
}
// convertToCategorySimpleResponse 转换为分类简单信息响应
func (s *SubscriptionApplicationServiceImpl) convertToCategorySimpleResponse(category *entities.ProductCategory) *responses.CategorySimpleResponse {
if category == nil {
return nil
}
return &responses.CategorySimpleResponse{
ID: category.ID,
Name: category.Name,