feat: fix issues
This commit is contained in:
0
backend/__debug_bin3572908368
Normal file
0
backend/__debug_bin3572908368
Normal file
Binary file not shown.
@@ -25,6 +25,16 @@ func (c *Controller) List(ctx fiber.Ctx) error {
|
||||
}
|
||||
claim := ctx.Locals(consts.CtxKeyClaim).(*jwt.Claims)
|
||||
|
||||
if filter.Offset != "" {
|
||||
model, err := c.svc.GetMediaByHash(ctx.Context(), claim.TenantID, filter.Offset)
|
||||
if err != nil {
|
||||
log.WithField("action", "medias.Show").WithError(err).Error("GetMediaByHash")
|
||||
return err
|
||||
}
|
||||
|
||||
filter.OffsetID = model.ID
|
||||
}
|
||||
|
||||
items, err := c.svc.List(ctx.Context(), claim.TenantID, claim.UserID, &filter)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -81,7 +81,7 @@ func (svc *Service) GetMediaByID(ctx context.Context, tenantId, userId, id int64
|
||||
}
|
||||
|
||||
func (svc *Service) ModelToListItem(ctx context.Context, m *model.Medias) *ListItem {
|
||||
return &ListItem{
|
||||
item := &ListItem{
|
||||
ID: m.ID,
|
||||
Poster: fmt.Sprintf("/static/%s/poster.jpg", m.Hash),
|
||||
Hash: m.Hash,
|
||||
@@ -93,7 +93,10 @@ func (svc *Service) ModelToListItem(ctx context.Context, m *model.Medias) *ListI
|
||||
Resources: m.Resources,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
Bought: false,
|
||||
}
|
||||
|
||||
return item
|
||||
}
|
||||
|
||||
// List
|
||||
@@ -146,7 +149,11 @@ func (svc *Service) List(ctx context.Context, tenantId, userId int64, filter *Li
|
||||
}
|
||||
|
||||
items := lo.Map(dest, func(m model.Medias, _ int) *ListItem {
|
||||
return svc.ModelToListItem(ctx, &m)
|
||||
item := svc.ModelToListItem(ctx, &m)
|
||||
if lo.Contains(boughtIDs, m.ID) {
|
||||
item.Bought = true
|
||||
}
|
||||
return item
|
||||
})
|
||||
|
||||
return items, nil
|
||||
|
||||
Reference in New Issue
Block a user