package purchase import "cls/internal/domain/purchase" // PurchaseDTO 购买记录DTO type PurchaseDTO struct { Id uint64 `json:"id"` UserId uint64 `json:"userId"` ContentId uint64 `json:"contentId"` ContentType purchase.ContentType `json:"contentType"` Price float64 `json:"price"` Status int8 `json:"status"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt"` } // ToDTO 转换为DTO func ToDTO(p *purchase.Purchase) *PurchaseDTO { if p == nil { return nil } return &PurchaseDTO{ Id: p.Id, UserId: p.UserId, ContentId: p.ContentId, ContentType: p.ContentType, Price: p.Price, Status: p.Status, CreatedAt: p.CreatedAt.Format("2006-01-02 15:04:05"), UpdatedAt: p.UpdatedAt.Format("2006-01-02 15:04:05"), } }