Adapt to old_id

This commit is contained in:
2025-08-02 20:44:09 +08:00
parent 719cd14269
commit 14c3a23752
7 changed files with 72 additions and 2 deletions

View File

@@ -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,