feat: enrich content item fields
This commit is contained in:
@@ -479,8 +479,12 @@ func (s *content) ListTopics(ctx context.Context) ([]content_dto.Topic, error) {
|
||||
func (s *content) toContentItemDTO(item *models.Content, price float64, authorIsFollowing bool) content_dto.ContentItem {
|
||||
dto := content_dto.ContentItem{
|
||||
ID: item.ID,
|
||||
TenantID: item.TenantID,
|
||||
UserID: item.UserID,
|
||||
Title: item.Title,
|
||||
Genre: item.Genre,
|
||||
Status: string(item.Status),
|
||||
Visibility: string(item.Visibility),
|
||||
AuthorID: item.UserID,
|
||||
Views: int(item.Views),
|
||||
Likes: int(item.Likes),
|
||||
@@ -488,6 +492,9 @@ func (s *content) toContentItemDTO(item *models.Content, price float64, authorIs
|
||||
Price: price,
|
||||
AuthorIsFollowing: authorIsFollowing,
|
||||
}
|
||||
if !item.PublishedAt.IsZero() {
|
||||
dto.PublishedAt = item.PublishedAt.Format("2006-01-02")
|
||||
}
|
||||
if item.Author != nil {
|
||||
dto.AuthorName = item.Author.Nickname
|
||||
dto.AuthorAvatar = item.Author.Avatar
|
||||
|
||||
@@ -705,14 +705,21 @@ func (s *super) toSuperContentTenant(tenant *models.Tenant) *super_dto.SuperCont
|
||||
func (s *super) toSuperContentDTO(item *models.Content, price *models.ContentPrice) *v1_dto.ContentItem {
|
||||
dto := &v1_dto.ContentItem{
|
||||
ID: item.ID,
|
||||
TenantID: item.TenantID,
|
||||
UserID: item.UserID,
|
||||
Title: item.Title,
|
||||
Genre: item.Genre,
|
||||
Status: string(item.Status),
|
||||
Visibility: string(item.Visibility),
|
||||
AuthorID: item.UserID,
|
||||
Views: int(item.Views),
|
||||
Likes: int(item.Likes),
|
||||
CreatedAt: item.CreatedAt.Format("2006-01-02"),
|
||||
IsPurchased: false,
|
||||
}
|
||||
if !item.PublishedAt.IsZero() {
|
||||
dto.PublishedAt = item.PublishedAt.Format("2006-01-02")
|
||||
}
|
||||
if price != nil {
|
||||
dto.Price = float64(price.PriceAmount) / 100.0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user