feat: 添加内容创建时间字段,优化内容列表和详情视图,更新价格获取逻辑
This commit is contained in:
@@ -138,7 +138,7 @@ func (s *creator) ListContents(
|
||||
}
|
||||
|
||||
var list []*models.Content
|
||||
err = q.Order(tbl.CreatedAt.Desc()).
|
||||
err = q.Order(tbl.ID.Desc()).
|
||||
UnderlyingDB().
|
||||
Preload("ContentAssets").
|
||||
Preload("ContentAssets.Asset").
|
||||
@@ -148,13 +148,14 @@ func (s *creator) ListContents(
|
||||
}
|
||||
|
||||
// Fetch Prices
|
||||
ids := make([]int64, len(list))
|
||||
for i, item := range list {
|
||||
ids[i] = item.ID
|
||||
}
|
||||
priceMap := make(map[int64]float64)
|
||||
if len(ids) > 0 {
|
||||
prices, _ := models.ContentPriceQuery.WithContext(ctx).Where(models.ContentPriceQuery.ContentID.In(ids...)).Find()
|
||||
if len(list) > 0 {
|
||||
ids := make([]int64, len(list))
|
||||
for i, item := range list {
|
||||
ids[i] = item.ID
|
||||
}
|
||||
pTbl, pQ := models.ContentPriceQuery.QueryContext(ctx)
|
||||
prices, _ := pQ.Where(pTbl.ContentID.In(ids...)).Find()
|
||||
for _, p := range prices {
|
||||
priceMap[p.ContentID] = float64(p.PriceAmount) / 100.0
|
||||
}
|
||||
@@ -207,6 +208,7 @@ func (s *creator) ListContents(
|
||||
VideoCount: videoCount,
|
||||
AudioCount: audioCount,
|
||||
Status: string(item.Status),
|
||||
CreatedAt: item.CreatedAt.Format("2006-01-02 15:04"),
|
||||
IsPinned: item.IsPinned,
|
||||
IsPurchased: false,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user