feat: 添加内容创建时间字段,优化内容列表和详情视图;添加创作者内容列表接口;优化上传和删除功能
This commit is contained in:
@@ -50,7 +50,7 @@ func (s *content) List(ctx context.Context, filter *content_dto.ContentListFilte
|
||||
case "price_asc":
|
||||
q = q.Order(tbl.ID.Desc())
|
||||
default: // latest
|
||||
q = q.Order(tbl.PublishedAt.Desc())
|
||||
q = q.Order(tbl.ID.Desc())
|
||||
}
|
||||
|
||||
// Pagination
|
||||
@@ -443,13 +443,14 @@ func (s *content) ListTopics(ctx context.Context) ([]content_dto.Topic, error) {
|
||||
|
||||
func (s *content) toContentItemDTO(item *models.Content, price float64) content_dto.ContentItem {
|
||||
dto := content_dto.ContentItem{
|
||||
ID: cast.ToString(item.ID),
|
||||
Title: item.Title,
|
||||
Genre: item.Genre,
|
||||
AuthorID: cast.ToString(item.UserID),
|
||||
Views: int(item.Views),
|
||||
Likes: int(item.Likes),
|
||||
Price: price,
|
||||
ID: cast.ToString(item.ID),
|
||||
Title: item.Title,
|
||||
Genre: item.Genre,
|
||||
AuthorID: cast.ToString(item.UserID),
|
||||
Views: int(item.Views),
|
||||
Likes: int(item.Likes),
|
||||
CreatedAt: item.CreatedAt.Format("2006-01-02"),
|
||||
Price: price,
|
||||
}
|
||||
if item.Author != nil {
|
||||
dto.AuthorName = item.Author.Nickname
|
||||
|
||||
@@ -252,6 +252,7 @@ func (s *creator) ListContents(
|
||||
Items: data,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *creator) CreateContent(ctx context.Context, userID int64, form *creator_dto.ContentCreateForm) error {
|
||||
tid, err := s.getTenantID(ctx, userID)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user