using Mapster; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Volo.Abp.Application.Services; using Yi.Framework.AiHub.Application.Contracts.Dtos; using Yi.Framework.AiHub.Application.Contracts.IServices; using Yi.Framework.AiHub.Domain.Entities; using Yi.Framework.SqlSugarCore.Abstractions; namespace Yi.Framework.AiHub.Application.Services; /// /// 排行榜服务 /// public class RankingService : ApplicationService, IRankingService { private readonly ISqlSugarRepository _repository; public RankingService(ISqlSugarRepository repository) { _repository = repository; } /// /// 获取排行榜列表(全量返回,按得分降序) /// [HttpGet("ranking/list")] [AllowAnonymous] public async Task> GetListAsync([FromQuery] RankingGetListInput input) { var query = _repository._DbQueryable .WhereIF(input.Type.HasValue, x => x.Type == input.Type!.Value) .OrderByDescending(x => x.Score); var entities = await query.ToListAsync(); return entities.Adapt>(); } }