修正订单群聊与发布跳转

This commit is contained in:
yml
2026-06-18 09:45:36 +08:00
parent f4361c9804
commit 58e071d157
5 changed files with 184 additions and 2 deletions
+27 -1
View File
@@ -87,8 +87,34 @@ func (r *Repository) FindConversation(ctx context.Context, principal Principal,
return &dto, nil
}
func (r *Repository) FindOrderConversation(ctx context.Context, userID uint64, orderID uint64) (*ConversationDTO, error) {
var row conversationRow
principal := Principal{Type: "user", ID: userID}
var order model.RentalOrder
if err := r.db.WithContext(ctx).First(&order, orderID).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, ErrConversationNotFound
}
return nil, err
}
if order.ListingID > 0 {
var row conversationRow
err := r.conversationQuery(ctx, principal).
Where("c.listing_id = ? AND c.type = ?", order.ListingID, ConversationTypeListingGroup).
First(&row).Error
if err == nil {
participants, err := r.participants(ctx, row.ID)
if err != nil {
return nil, err
}
dto := row.toDTO(participants)
return &dto, nil
}
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return nil, err
}
}
var row conversationRow
err := r.conversationQuery(ctx, principal).Where("c.order_id = ?", orderID).First(&row).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {