You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.0 KiB
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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"`
Duration int `json:"duration"` // 购买时长文章为0表示永久
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"),
}
}