chore(init): 初始化解忧商行项目并完成 Phase 0 基座
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hfb_sys/backend/internal/model"
|
||||
)
|
||||
|
||||
// ListingChatCreatorAdapter 适配器,实现 listing.ListingChatCreator 接口
|
||||
type ListingChatCreatorAdapter struct {
|
||||
// 无需字段,直接调用包级函数
|
||||
}
|
||||
|
||||
func NewListingChatCreatorAdapter() *ListingChatCreatorAdapter {
|
||||
return &ListingChatCreatorAdapter{}
|
||||
}
|
||||
|
||||
// EnsureListingConversation 实现接口
|
||||
func (a *ListingChatCreatorAdapter) EnsureListingConversation(tx *gorm.DB, listing model.RentalListing, supportAdminID uint64) (uint64, error) {
|
||||
conv, err := EnsureListingConversation(tx, listing, supportAdminID)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return conv.ID, nil
|
||||
}
|
||||
|
||||
// OrderChatArchiverAdapter 适配器,实现 order.OrderChatArchiver 接口,
|
||||
// 供订单封存时在同一事务内解散关联的发布群。
|
||||
type OrderChatArchiverAdapter struct{}
|
||||
|
||||
func NewOrderChatArchiverAdapter() *OrderChatArchiverAdapter {
|
||||
return &OrderChatArchiverAdapter{}
|
||||
}
|
||||
|
||||
// ArchiveListingConversation 将商品关联的发布群标记为已归档(解散),
|
||||
// 写入一条系统消息提示群聊已被客服解散。会话不存在时静默跳过。
|
||||
func (a *OrderChatArchiverAdapter) ArchiveListingConversation(tx *gorm.DB, listingID uint64, reason string) error {
|
||||
return ArchiveListingConversation(tx, listingID, reason)
|
||||
}
|
||||
Reference in New Issue
Block a user