feat: 更新上传接口,使用新的上传表单结构并添加价格字段
This commit is contained in:
@@ -122,6 +122,19 @@ func (s *creator) ListContents(
|
||||
return nil, errorx.ErrDatabaseError.WithCause(err)
|
||||
}
|
||||
|
||||
// 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()
|
||||
for _, p := range prices {
|
||||
priceMap[p.ContentID] = float64(p.PriceAmount) / 100.0
|
||||
}
|
||||
}
|
||||
|
||||
var data []creator_dto.CreatorContentItem
|
||||
for _, item := range list {
|
||||
data = append(data, creator_dto.CreatorContentItem{
|
||||
@@ -129,6 +142,7 @@ func (s *creator) ListContents(
|
||||
Title: item.Title,
|
||||
Genre: item.Genre,
|
||||
Key: item.Key,
|
||||
Price: priceMap[item.ID],
|
||||
Views: int(item.Views),
|
||||
Likes: int(item.Likes),
|
||||
IsPurchased: false,
|
||||
|
||||
Reference in New Issue
Block a user