feat: 完成积分、价值排行榜
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser;
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Analyse;
|
||||
|
||||
public class MoneyTopUserDto
|
||||
/// <summary>
|
||||
/// 用户排行榜
|
||||
/// </summary>
|
||||
public class BaseAnalyseTopUserDto
|
||||
{
|
||||
public Guid UserId { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string? Nick { get; set; }
|
||||
public decimal Money { get; set; }
|
||||
public int Order { get; set; }
|
||||
public string? Icon { get; set; }
|
||||
public int Level { get; set; }
|
||||
@@ -18,5 +21,4 @@ public class MoneyTopUserDto
|
||||
/// 用户限制
|
||||
/// </summary>
|
||||
public UserLimitEnum UserLimit { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Analyse;
|
||||
|
||||
public class MoneyTopUserDto:BaseAnalyseTopUserDto
|
||||
{
|
||||
public decimal Money { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Analyse;
|
||||
|
||||
public class PointsTopUserDto:BaseAnalyseTopUserDto
|
||||
{
|
||||
public int Points { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Analyse;
|
||||
|
||||
public class ValueTopUserDto:BaseAnalyseTopUserDto
|
||||
{
|
||||
public decimal Value { get; set; }
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\digital-collectibles\Yi.Framework.DigitalCollectibles.Application.Contracts\Yi.Framework.DigitalCollectibles.Application.Contracts.csproj" />
|
||||
<ProjectReference Include="..\..\rbac\Yi.Framework.Rbac.Application.Contracts\Yi.Framework.Rbac.Application.Contracts.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Bbs.Domain.Shared\Yi.Framework.Bbs.Domain.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -9,6 +9,7 @@ using Yi.Framework.Bbs.Domain.Entities;
|
||||
using Yi.Framework.Bbs.Domain.Entities.Integral;
|
||||
using Yi.Framework.Bbs.Domain.Managers;
|
||||
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||
using Yi.Framework.DigitalCollectibles.Application.Contracts.IServices;
|
||||
using Yi.Framework.Rbac.Application.Contracts.IServices;
|
||||
using Yi.Framework.Rbac.Domain.Authorization;
|
||||
using Yi.Framework.Rbac.Domain.Shared.Consts;
|
||||
@@ -20,11 +21,16 @@ namespace Yi.Framework.Bbs.Application.Services.Analyses
|
||||
{
|
||||
private BbsUserManager _bbsUserManager;
|
||||
private IOnlineService _onlineService;
|
||||
private readonly IPointAnalyseService _pointAnalyseService;
|
||||
private readonly IValueAnalyseService _valueAnalyseService;
|
||||
|
||||
public BbsUserAnalyseService(BbsUserManager bbsUserManager, IOnlineService onlineService)
|
||||
public BbsUserAnalyseService(BbsUserManager bbsUserManager, IOnlineService onlineService,
|
||||
IPointAnalyseService pointAnalyseService, IValueAnalyseService valueAnalyseService)
|
||||
{
|
||||
_bbsUserManager = bbsUserManager;
|
||||
_onlineService = onlineService;
|
||||
_pointAnalyseService = pointAnalyseService;
|
||||
_valueAnalyseService = valueAnalyseService;
|
||||
}
|
||||
|
||||
|
||||
@@ -169,5 +175,120 @@ namespace Yi.Framework.Bbs.Application.Services.Analyses
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 积分排行榜
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("analyse/dc-user/points-top/{userId?}")]
|
||||
public async Task<PagedResultDto<PointsTopUserDto>> GetPointsTopAsync([FromQuery] PagedResultRequestDto input,
|
||||
[FromRoute] Guid? userId)
|
||||
{
|
||||
var result = await _pointAnalyseService.GetValueTopAsync(input, null);
|
||||
|
||||
RefAsync<int> total = 0;
|
||||
var userIds = result.Items.Select(x => x.UserId).ToList();
|
||||
|
||||
var baseOutput = await _bbsUserManager._userRepository._DbQueryable
|
||||
.Where(u => userIds.Contains(u.Id))
|
||||
.LeftJoin<BbsUserExtraInfoEntity>((u, info) => u.Id == info.UserId)
|
||||
.OrderByDescending((u, info) => info.Money)
|
||||
.Select((u, info) =>
|
||||
new BaseAnalyseTopUserDto
|
||||
{
|
||||
UserName = u.UserName,
|
||||
Nick = u.Nick,
|
||||
Icon = u.Icon,
|
||||
Level = info.Level,
|
||||
UserLimit = info.UserLimit,
|
||||
UserId = info.UserId
|
||||
}
|
||||
).ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
|
||||
|
||||
var output = new List<PointsTopUserDto>();
|
||||
result.Items.ToList().ForEach(x =>
|
||||
{
|
||||
var currentUserInfo = baseOutput.Where(u => u.UserId == x.UserId).FirstOrDefault();
|
||||
|
||||
if (currentUserInfo is not null)
|
||||
{
|
||||
output.Add(new PointsTopUserDto
|
||||
{
|
||||
UserName = currentUserInfo.UserName,
|
||||
Nick = currentUserInfo.Nick,
|
||||
Order = x.Order,
|
||||
Icon = currentUserInfo.Icon,
|
||||
Level = currentUserInfo.Level,
|
||||
LevelName = _bbsUserManager._levelCacheDic[currentUserInfo.Level].Name,
|
||||
UserLimit = UserLimitEnum.Normal,
|
||||
Points = x.Points
|
||||
});
|
||||
}
|
||||
});
|
||||
return new PagedResultDto<PointsTopUserDto>
|
||||
{
|
||||
Items = output,
|
||||
TotalCount = total
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 价值排行榜
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("analyse/dc-user/value-top/{userId?}")]
|
||||
public async Task<PagedResultDto<ValueTopUserDto>> GetValueTopAsync([FromQuery] PagedResultRequestDto input,
|
||||
[FromRoute] Guid? userId)
|
||||
{
|
||||
var result = await _valueAnalyseService.GetValueTopAsync(input, null);
|
||||
|
||||
RefAsync<int> total = 0;
|
||||
var userIds = result.Items.Select(x => x.UserId).ToList();
|
||||
|
||||
var baseOutput = await _bbsUserManager._userRepository._DbQueryable
|
||||
.Where(u => userIds.Contains(u.Id))
|
||||
.LeftJoin<BbsUserExtraInfoEntity>((u, info) => u.Id == info.UserId)
|
||||
.OrderByDescending((u, info) => info.Money)
|
||||
.Select((u, info) =>
|
||||
new BaseAnalyseTopUserDto
|
||||
{
|
||||
UserName = u.UserName,
|
||||
Nick = u.Nick,
|
||||
Icon = u.Icon,
|
||||
Level = info.Level,
|
||||
UserLimit = info.UserLimit,
|
||||
UserId = info.UserId
|
||||
}
|
||||
).ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
|
||||
|
||||
var output = new List<ValueTopUserDto>();
|
||||
result.Items.ToList().ForEach(x =>
|
||||
{
|
||||
var currentUserInfo = baseOutput.Where(u => u.UserId == x.UserId).FirstOrDefault();
|
||||
|
||||
if (currentUserInfo is not null)
|
||||
{
|
||||
output.Add(new ValueTopUserDto
|
||||
{
|
||||
UserName = currentUserInfo.UserName,
|
||||
Nick = currentUserInfo.Nick,
|
||||
Order = x.Order,
|
||||
Icon = currentUserInfo.Icon,
|
||||
Level = currentUserInfo.Level,
|
||||
LevelName = _bbsUserManager._levelCacheDic[currentUserInfo.Level].Name,
|
||||
UserLimit = UserLimitEnum.Normal,
|
||||
Value = x.Value
|
||||
});
|
||||
}
|
||||
});
|
||||
return new PagedResultDto<ValueTopUserDto>
|
||||
{
|
||||
Items = output,
|
||||
TotalCount = total
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user