feat: 更新上传接口,使用新的上传表单结构并添加价格字段

This commit is contained in:
2025-12-31 16:41:19 +08:00
parent b82a69689d
commit 5a364a995a
5 changed files with 33 additions and 16 deletions

View File

@@ -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,