Adapt to old_id
This commit is contained in:
@@ -15,6 +15,7 @@ type PackageItemResponse struct {
|
||||
// ProductInfoResponse 产品详情响应
|
||||
type ProductInfoResponse struct {
|
||||
ID string `json:"id" comment:"产品ID"`
|
||||
OldID *string `json:"old_id,omitempty" comment:"旧产品ID"`
|
||||
Name string `json:"name" comment:"产品名称"`
|
||||
Code string `json:"code" comment:"产品编号"`
|
||||
Description string `json:"description" comment:"产品简介"`
|
||||
@@ -59,6 +60,7 @@ type ProductSearchResponse struct {
|
||||
// ProductSimpleResponse 产品简单信息响应
|
||||
type ProductSimpleResponse struct {
|
||||
ID string `json:"id" comment:"产品ID"`
|
||||
OldID *string `json:"old_id,omitempty" comment:"旧产品ID"`
|
||||
Name string `json:"name" comment:"产品名称"`
|
||||
Code string `json:"code" comment:"产品编号"`
|
||||
Description string `json:"description" comment:"产品简介"`
|
||||
@@ -79,6 +81,7 @@ type ProductStatsResponse struct {
|
||||
// ProductAdminInfoResponse 管理员产品详情响应
|
||||
type ProductAdminInfoResponse struct {
|
||||
ID string `json:"id" comment:"产品ID"`
|
||||
OldID *string `json:"old_id,omitempty" comment:"旧产品ID"`
|
||||
Name string `json:"name" comment:"产品名称"`
|
||||
Code string `json:"code" comment:"产品编号"`
|
||||
Description string `json:"description" comment:"产品简介"`
|
||||
|
||||
@@ -436,9 +436,14 @@ func (s *ProductApplicationServiceImpl) GetProductByIDForAdmin(ctx context.Conte
|
||||
// GetProductByIDForUser 根据ID获取产品(用户端专用)
|
||||
// 业务流程:1. 获取产品信息 2. 验证产品可见性 3. 构建用户响应数据
|
||||
func (s *ProductApplicationServiceImpl) GetProductByIDForUser(ctx context.Context, query *appQueries.GetProductDetailQuery) (*responses.ProductInfoWithDocumentResponse, error) {
|
||||
// 首先尝试通过新ID查找产品
|
||||
product, err := s.productManagementService.GetProductWithCategory(ctx, query.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// 如果通过新ID找不到,尝试通过旧ID查找
|
||||
product, err = s.productManagementService.GetProductByOldIDWithCategory(ctx, query.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// 用户端只能查看可见的产品
|
||||
@@ -452,7 +457,7 @@ func (s *ProductApplicationServiceImpl) GetProductByIDForUser(ctx context.Contex
|
||||
|
||||
// 如果需要包含文档信息
|
||||
if query.WithDocument != nil && *query.WithDocument {
|
||||
doc, err := s.documentationAppService.GetDocumentationByProductID(ctx, query.ID)
|
||||
doc, err := s.documentationAppService.GetDocumentationByProductID(ctx, product.ID)
|
||||
if err == nil && doc != nil {
|
||||
response.Documentation = doc
|
||||
}
|
||||
@@ -465,6 +470,7 @@ func (s *ProductApplicationServiceImpl) GetProductByIDForUser(ctx context.Contex
|
||||
func (s *ProductApplicationServiceImpl) convertToProductInfoResponse(product *entities.Product) *responses.ProductInfoResponse {
|
||||
response := &responses.ProductInfoResponse{
|
||||
ID: product.ID,
|
||||
OldID: product.OldID,
|
||||
Name: product.Name,
|
||||
Code: product.Code,
|
||||
Description: product.Description,
|
||||
@@ -507,6 +513,7 @@ func (s *ProductApplicationServiceImpl) convertToProductInfoResponse(product *en
|
||||
func (s *ProductApplicationServiceImpl) convertToProductAdminInfoResponse(product *entities.Product) *responses.ProductAdminInfoResponse {
|
||||
response := &responses.ProductAdminInfoResponse{
|
||||
ID: product.ID,
|
||||
OldID: product.OldID,
|
||||
Name: product.Name,
|
||||
Code: product.Code,
|
||||
Description: product.Description,
|
||||
|
||||
@@ -231,6 +231,7 @@ func (s *SubscriptionApplicationServiceImpl) convertToSubscriptionInfoResponse(s
|
||||
func (s *SubscriptionApplicationServiceImpl) convertToProductSimpleResponse(product *entities.Product) *responses.ProductSimpleResponse {
|
||||
return &responses.ProductSimpleResponse{
|
||||
ID: product.ID,
|
||||
OldID: product.OldID,
|
||||
Name: product.Name,
|
||||
Code: product.Code,
|
||||
Description: product.Description,
|
||||
|
||||
Reference in New Issue
Block a user