Add play count to song best api
This commit is contained in:
parent
45947f0492
commit
fdbeb3b4bb
@ -14,6 +14,8 @@ public class SongBestData
|
||||
|
||||
public Difficulty Difficulty { get; set; }
|
||||
|
||||
public int PlayCount { get; set; }
|
||||
|
||||
public uint BestScore { get; set; }
|
||||
|
||||
public uint BestRate { get; set; }
|
||||
|
@ -10,10 +10,14 @@ public class PlayDataController : BaseController<PlayDataController>
|
||||
|
||||
private readonly ISongBestDatumService songBestDatumService;
|
||||
|
||||
public PlayDataController(IUserDatumService userDatumService, ISongBestDatumService songBestDatumService)
|
||||
private readonly ISongPlayDatumService songPlayDatumService;
|
||||
|
||||
public PlayDataController(IUserDatumService userDatumService, ISongBestDatumService songBestDatumService,
|
||||
ISongPlayDatumService songPlayDatumService)
|
||||
{
|
||||
this.userDatumService = userDatumService;
|
||||
this.songBestDatumService = songBestDatumService;
|
||||
this.songPlayDatumService = songPlayDatumService;
|
||||
}
|
||||
|
||||
[HttpGet("{baid}")]
|
||||
@ -26,6 +30,12 @@ public class PlayDataController : BaseController<PlayDataController>
|
||||
}
|
||||
|
||||
var songBestRecords = await songBestDatumService.GetAllSongBestAsModel(baid);
|
||||
var songPlayLogs = await songPlayDatumService.GetSongPlayDatumByBaid(baid);
|
||||
foreach (var songBestData in songBestRecords)
|
||||
{
|
||||
songBestData.PlayCount = songPlayLogs.Count(datum => datum.SongId == songBestData.SongId &&
|
||||
datum.Difficulty == songBestData.Difficulty);
|
||||
}
|
||||
var favoriteSongs = await userDatumService.GetFavoriteSongIds(baid);
|
||||
var favoriteSet = favoriteSongs.ToHashSet();
|
||||
foreach (var songBestRecord in songBestRecords.Where(songBestRecord => favoriteSet.Contains(songBestRecord.SongId)))
|
||||
|
Loading…
Reference in New Issue
Block a user