diff --git a/pkg/repository/database/season.go b/pkg/repository/database/season.go index 7a53b96..00acf3d 100644 --- a/pkg/repository/database/season.go +++ b/pkg/repository/database/season.go @@ -147,7 +147,7 @@ func (e *Season) BatchGet(ctx context.Context, ids []string) (entity.Seasons, er strings.Join(fields, ","), strings.Repeat(",?", len(newIDs)-1), ) - rows, err := e.db.QueryContext(ctx, query, newIDs) + rows, err := e.db.QueryContext(ctx, query, convertStringsToAnys(newIDs)...) if err != nil { return nil, errcode.New(err) } @@ -155,12 +155,19 @@ func (e *Season) BatchGet(ctx context.Context, ids []string) (entity.Seasons, er var seasons entity.Seasons var multiErr error for rows.Next() { - var s entity.Season - if err = rows.Scan(&s); err != nil { + season := &entity.Season{} + err = rows.Scan( + &season.ID, + &season.SeriesID, + &season.DisplayName, + &season.ImageURL, + &season.DisplayOrder, + ) + if err != nil { multiErr = multierr.Append(multiErr, err) - continue + break } - seasons = append(seasons, &s) + seasons = append(seasons, season) } if cerr := rows.Close(); cerr != nil { diff --git a/pkg/repository/database/series.go b/pkg/repository/database/series.go index 5c9d458..5acf55f 100644 --- a/pkg/repository/database/series.go +++ b/pkg/repository/database/series.go @@ -113,24 +113,31 @@ func (e *Series) BatchGet(ctx context.Context, ids []string) (entity.SeriesMulti } } - fields := []string{"id", "displayName", "description", "imageUrl", "genreId"} + fields := []string{"seriesID", "displayName", "description", "imageURL", "genreID"} query := fmt.Sprintf( "SELECT %s FROM series WHERE seriesID IN(?%s)", strings.Join(fields, ", "), strings.Repeat(",?", len(newIDs)-1), ) - rows, err := e.db.QueryContext(ctx, query, newIDs) + rows, err := e.db.QueryContext(ctx, query, convertStringsToAnys(newIDs)...) var seriesMulti entity.SeriesMulti var multiErr error for rows.Next() { - var series entity.Series - if err := rows.Scan(&series); err != nil { + series := &entity.Series{} + err = rows.Scan( + &series.ID, + &series.DisplayName, + &series.Description, + &series.ImageURL, + &series.GenreID, + ) + if err != nil { multiErr = multierr.Append(multiErr, err) - continue + break } - seriesMulti = append(seriesMulti, &series) + seriesMulti = append(seriesMulti, series) } if err := rows.Close(); err != nil {