diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/BbsUser/MoneyTopUserDto.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Analyse/BaseAnalyseTopUserDto.cs similarity index 70% rename from Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/BbsUser/MoneyTopUserDto.cs rename to Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Analyse/BaseAnalyseTopUserDto.cs index e957f079..48386106 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/BbsUser/MoneyTopUserDto.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Analyse/BaseAnalyseTopUserDto.cs @@ -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 +/// +/// 用户排行榜 +/// +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 /// 用户限制 /// public UserLimitEnum UserLimit { get; set; } - } \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Analyse/MoneyTopUserDto.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Analyse/MoneyTopUserDto.cs new file mode 100644 index 00000000..23781369 --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Analyse/MoneyTopUserDto.cs @@ -0,0 +1,7 @@ +namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Analyse; + +public class MoneyTopUserDto:BaseAnalyseTopUserDto +{ + public decimal Money { get; set; } + +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Analyse/PointsTopUserDto.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Analyse/PointsTopUserDto.cs new file mode 100644 index 00000000..573c69aa --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Analyse/PointsTopUserDto.cs @@ -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; } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Analyse/ValueTopUserDto.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Analyse/ValueTopUserDto.cs new file mode 100644 index 00000000..01ef7681 --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Analyse/ValueTopUserDto.cs @@ -0,0 +1,6 @@ +namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Analyse; + +public class ValueTopUserDto:BaseAnalyseTopUserDto +{ + public decimal Value { get; set; } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Yi.Framework.Bbs.Application.Contracts.csproj b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Yi.Framework.Bbs.Application.Contracts.csproj index f7d35469..a4775b67 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Yi.Framework.Bbs.Application.Contracts.csproj +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Yi.Framework.Bbs.Application.Contracts.csproj @@ -3,6 +3,7 @@ + diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Analyses/BbsUserAnalyseService.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Analyses/BbsUserAnalyseService.cs index 63588b25..9156e2cf 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Analyses/BbsUserAnalyseService.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Analyses/BbsUserAnalyseService.cs @@ -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,116 @@ namespace Yi.Framework.Bbs.Application.Services.Analyses return output; } } + + + /// + /// 积分排行榜 + /// + /// + [HttpGet("analyse/dc-user/points-top/{userId?}")] + public async Task> GetPointsTopAsync([FromQuery] PagedResultRequestDto input, + [FromRoute] Guid? userId) + { + var result = await _pointAnalyseService.GetValueTopAsync(input, null); + + var userIds = result.Items.Select(x => x.UserId).ToList(); + + var baseOutput = await _bbsUserManager._userRepository._DbQueryable + .Where(u => userIds.Contains(u.Id)) + .LeftJoin((u, info) => u.Id == info.UserId) + .Select((u, info) => + new BaseAnalyseTopUserDto + { + UserName = u.UserName, + Nick = u.Nick, + Icon = u.Icon, + Level = info.Level, + UserLimit = info.UserLimit, + UserId = info.UserId + } + ).ToListAsync(); + + + var output = new List(); + 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 + { + Items = output, + TotalCount = result.TotalCount + }; + } + + /// + /// 价值排行榜 + /// + /// + [HttpGet("analyse/dc-user/value-top/{userId?}")] + public async Task> GetValueTopAsync([FromQuery] PagedResultRequestDto input, + [FromRoute] Guid? userId) + { + var result = await _valueAnalyseService.GetValueTopAsync(input, null); + + var userIds = result.Items.Select(x => x.UserId).ToList(); + + var baseOutput = await _bbsUserManager._userRepository._DbQueryable + .Where(u => userIds.Contains(u.Id)) + .LeftJoin((u, info) => u.Id == info.UserId) + .Select((u, info) => + new BaseAnalyseTopUserDto + { + UserName = u.UserName, + Nick = u.Nick, + Icon = u.Icon, + Level = info.Level, + UserLimit = info.UserLimit, + UserId = info.UserId + } + ).ToListAsync(); + + + var output = new List(); + 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 + { + Items = output, + TotalCount = result.TotalCount + }; + } } } \ No newline at end of file diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Analyse/DcPointsTopUserDto.cs b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Analyse/DcPointsTopUserDto.cs new file mode 100644 index 00000000..225b407c --- /dev/null +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Analyse/DcPointsTopUserDto.cs @@ -0,0 +1,9 @@ +namespace Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Analyse; + +public class DcPointsTopUserDto +{ + public Guid UserId { get; set; } + public int Points { get; set; } + + public int Order { get; set; } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Analyse/DcValueTopUserDto.cs b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Analyse/DcValueTopUserDto.cs new file mode 100644 index 00000000..46616744 --- /dev/null +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Analyse/DcValueTopUserDto.cs @@ -0,0 +1,9 @@ +namespace Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Analyse; + +public class DcValueTopUserDto +{ + public Guid UserId { get; set; } + public decimal Value { get; set; } + + public int Order { get; set; } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/IServices/IPointAnalyseService.cs b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/IServices/IPointAnalyseService.cs new file mode 100644 index 00000000..d7a1feb2 --- /dev/null +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/IServices/IPointAnalyseService.cs @@ -0,0 +1,16 @@ +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.Application.Dtos; +using Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Analyse; + +namespace Yi.Framework.DigitalCollectibles.Application.Contracts.IServices; + +public interface IPointAnalyseService +{ + /// + /// 积分排行榜 + /// + /// + // [HttpGet("analyse/dc-user/points-top/{userId?}")] + Task> GetValueTopAsync([FromQuery] PagedResultRequestDto input, + [FromRoute] Guid? userId); +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/IServices/IValueAnalyseService.cs b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/IServices/IValueAnalyseService.cs new file mode 100644 index 00000000..5ee848e4 --- /dev/null +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/IServices/IValueAnalyseService.cs @@ -0,0 +1,16 @@ +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.Application.Dtos; +using Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Analyse; + +namespace Yi.Framework.DigitalCollectibles.Application.Contracts.IServices; + +public interface IValueAnalyseService +{ + /// + /// 价值排行榜 + /// + /// + // [HttpGet("analyse/dc-user/value-top/{userId?}")] + Task> GetValueTopAsync([FromQuery] PagedResultRequestDto input, + [FromRoute] Guid? userId); +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Yi.Framework.DigitalCollectibles.Application.Contracts.csproj b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Yi.Framework.DigitalCollectibles.Application.Contracts.csproj index d94c8ceb..5d20f5fd 100644 --- a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Yi.Framework.DigitalCollectibles.Application.Contracts.csproj +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Yi.Framework.DigitalCollectibles.Application.Contracts.csproj @@ -7,8 +7,4 @@ - - - - diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application/Services/Analyses/PointAnalyseService.cs b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application/Services/Analyses/PointAnalyseService.cs new file mode 100644 index 00000000..246024e0 --- /dev/null +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application/Services/Analyses/PointAnalyseService.cs @@ -0,0 +1,54 @@ +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Analyse; +using Yi.Framework.DigitalCollectibles.Application.Contracts.IServices; +using Yi.Framework.DigitalCollectibles.Domain.Entities; +using Yi.Framework.SqlSugarCore.Abstractions; + + +namespace Yi.Framework.DigitalCollectibles.Application.Services.Analyses; + +/// +/// 用户积分分析 +/// +public class PointAnalyseService: ApplicationService,IPointAnalyseService +{ + + private readonly ISqlSugarRepository _repository; + + public PointAnalyseService(ISqlSugarRepository repository) + { + _repository = repository; + } + + /// + /// 积分排行榜 + /// + /// + // [HttpGet("analyse/dc-user/points-top/{userId?}")] + [RemoteService(isEnabled:false)] + public async Task> GetValueTopAsync([FromQuery] PagedResultRequestDto input, + [FromRoute] Guid? userId) + { + + var pageIndex = input.SkipCount; + RefAsync total = 0; + var output = await _repository._DbQueryable + .OrderByDescending(x=>x.PointsNumber) + .Select(x => + new DcPointsTopUserDto{ + UserId = x.UserId, + Points = x.PointsNumber, + Order=SqlFunc.RowNumber(SqlFunc.Desc(x.PointsNumber)) + }) + .ToPageListAsync(pageIndex, input.MaxResultCount, total); + return new PagedResultDto + { + Items = output, + TotalCount = total + }; + + } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application/Services/Analyses/ValueAnalyseService.cs b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application/Services/Analyses/ValueAnalyseService.cs new file mode 100644 index 00000000..5a3ab8d1 --- /dev/null +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application/Services/Analyses/ValueAnalyseService.cs @@ -0,0 +1,48 @@ +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Analyse; +using Yi.Framework.DigitalCollectibles.Application.Contracts.IServices; +using Yi.Framework.DigitalCollectibles.Domain.Entities; +using Yi.Framework.DigitalCollectibles.Domain.Managers; +using Yi.Framework.SqlSugarCore.Abstractions; + +namespace Yi.Framework.DigitalCollectibles.Application.Services.Analyses; + +public class ValueAnalyseService: ApplicationService,IValueAnalyseService +{ + + private readonly CollectiblesManager _manager; + + public ValueAnalyseService( CollectiblesManager manager) + { + _manager = manager; + } + + /// + /// 价值排行榜 + /// + /// + // [HttpGet("analyse/dc-user/value-top/{userId?}")] + [RemoteService(isEnabled:false)] + public async Task> GetValueTopAsync([FromQuery] PagedResultRequestDto input, + [FromRoute] Guid? userId) + { + //每个人的价值需要进行计算才能获取,这里计算时间较长,放入缓存,绝对过期 + var allValue= await _manager.GetAllAccountValueByCacheAsync(); + var output = allValue.OrderByDescending(x => x.Value).Select((x, index) => new DcValueTopUserDto + { + UserId = x.UserId, + Value = x.Value, + Order = index + 1 + }).Skip((input.SkipCount - 1) * input.MaxResultCount) // 跳过前面(当前页码 - 1)* 每页数量条记录 + .Take(input.MaxResultCount).ToList(); + return new PagedResultDto + { + Items = output, + TotalCount = allValue.Count + }; + + } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Domain.Shared/Caches/CollectiblesValueCacheItem.cs b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Domain.Shared/Caches/CollectiblesValueCacheItem.cs new file mode 100644 index 00000000..62c44e73 --- /dev/null +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Domain.Shared/Caches/CollectiblesValueCacheItem.cs @@ -0,0 +1,7 @@ +namespace Yi.Framework.DigitalCollectibles.Domain.Shared.Caches; + +public class CollectiblesValueCacheItem +{ + public Guid UserId { get; set; } + public decimal Value { get; set; } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Domain/Managers/CollectiblesManager.cs b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Domain/Managers/CollectiblesManager.cs index b0e3bdd3..406b486f 100644 --- a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Domain/Managers/CollectiblesManager.cs +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Domain/Managers/CollectiblesManager.cs @@ -1,6 +1,9 @@ -using Volo.Abp.Domain.Services; +using Microsoft.Extensions.Caching.Distributed; +using Volo.Abp.Caching; +using Volo.Abp.Domain.Services; using Volo.Abp.Users; using Yi.Framework.DigitalCollectibles.Domain.Entities; +using Yi.Framework.DigitalCollectibles.Domain.Shared.Caches; using Yi.Framework.SqlSugarCore.Abstractions; namespace Yi.Framework.DigitalCollectibles.Domain.Managers; @@ -11,13 +14,20 @@ namespace Yi.Framework.DigitalCollectibles.Domain.Managers; public class CollectiblesManager:DomainService { private readonly ISqlSugarRepository _collectiblesUserStoreRepository; - - public CollectiblesManager(ISqlSugarRepository collectiblesUserStoreRepository) + private readonly ISqlSugarRepository _collectiblesRepository; + private readonly IDistributedCache> _distributedCache; + public CollectiblesManager(ISqlSugarRepository collectiblesUserStoreRepository, ISqlSugarRepository collectiblesRepository, IDistributedCache> distributedCache) { _collectiblesUserStoreRepository = collectiblesUserStoreRepository; + _collectiblesRepository = collectiblesRepository; + _distributedCache = distributedCache; } - + /// + /// 获取某个用户的价值 + /// + /// + /// public async Task GetAccountValueAsync(Guid userId) { var collectiblesList = await _collectiblesUserStoreRepository._DbQueryable @@ -30,7 +40,14 @@ public class CollectiblesManager:DomainService c.ValueNumber } ).ToListAsync(); - var groupBy = collectiblesList.GroupBy(x => x.Id); + var totalValue=ComputeValue(collectiblesList.Select(x=> (x.Id,x.ValueNumber)).ToList()); + return totalValue; + } + + //计算价值,需要每个藏品的唯一值和藏品的价值即可 + private decimal ComputeValue(List<(Guid collectiblesId,decimal valueNumber)> data) + { + var groupBy = data.GroupBy(x => x.collectiblesId); decimal totalValue = 0; //首个价值百分之百,后续每个只有百分之40,最大10个 @@ -41,7 +58,7 @@ public class CollectiblesManager:DomainService if (item.index == 0) { - totalValue += item.value.ValueNumber; + totalValue += item.value.valueNumber; } else if (item.index == 10) { @@ -50,11 +67,48 @@ public class CollectiblesManager:DomainService } else { - totalValue += item.value.ValueNumber * 0.4m; + totalValue += item.value.valueNumber * 0.4m; } } } return totalValue; } + +/// +/// 获取全量的排行榜 +/// +/// + public async Task> GetAllAccountValueByCacheAsync() + { + return await _distributedCache.GetOrAddAsync("AllAccountValue", async () => await GetAccountValueAsync(), + () => new DistributedCacheEntryOptions() + { + AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(1) + }); + } + + private async Task> GetAccountValueAsync() + { + var output = new List(); + //获取全部用户的库存 + var allStore= await _collectiblesUserStoreRepository._DbQueryable.ToListAsync(); + //获取全部藏品 + var allCollectiblesDic= (await _collectiblesRepository._DbQueryable.ToListAsync()).ToDictionary(x=>x.Id,y=>y.ValueNumber); + + //根据用户分组 + var userGroup= allStore.GroupBy(x => x.UserId); + //每个用户进行计算价值 + foreach (var item in userGroup) + { + var value= ComputeValue(item.Select(x => (x.CollectiblesId, allCollectiblesDic[x.CollectiblesId])).ToList()); + output.Add(new CollectiblesValueCacheItem + { + UserId = item.Key, + Value = value + }); + } + + return output; + } } \ No newline at end of file diff --git a/Yi.Bbs.Vue3/src/apis/analyseApi.js b/Yi.Bbs.Vue3/src/apis/analyseApi.js index 2e582156..1db012d9 100644 --- a/Yi.Bbs.Vue3/src/apis/analyseApi.js +++ b/Yi.Bbs.Vue3/src/apis/analyseApi.js @@ -27,11 +27,11 @@ export function getRecommendedFriend(data) { } /** - * 获取积分排行 + * 获取钱钱排行 * @param {*} data * @returns */ -export function getRankingPoints(data) { +export function getMoneyTop(data) { return request({ url: "/analyse/bbs-user/money-top", method: "get", @@ -39,6 +39,35 @@ export function getRankingPoints(data) { }); } + +/** + * 获取价值排行 + * @param {*} data + * @returns + */ +export function getValueTop(data) { + return request({ + url: "/analyse/dc-user/value-top", + method: "get", + params: data + }); +} + +/** + * 获取积分排行 + * @param {*} data + * @returns + */ +export function getPointsTop(data) { + return request({ + url: "/analyse/dc-user/points-top", + method: "get", + params: data + }); +} + + + /** * 获取用户分析 * @param {*} data diff --git a/Yi.Bbs.Vue3/src/views/home/Index.vue b/Yi.Bbs.Vue3/src/views/home/Index.vue index 8ec3e3c9..f94d5236 100644 --- a/Yi.Bbs.Vue3/src/views/home/Index.vue +++ b/Yi.Bbs.Vue3/src/views/home/Index.vue @@ -261,7 +261,7 @@ import {getWeek} from "@/apis/accessApi.js"; import { getRecommendedTopic, getRecommendedFriend, - getRankingPoints, + getMoneyTop, getUserAnalyse, getRegisterAnalyse } from "@/apis/analyseApi.js"; @@ -345,7 +345,7 @@ const init = async () => { weekList.value = weekData; })(), (async () => { - const {data: pointData, config: pointConfig} = await getRankingPoints(); + const {data: pointData, config: pointConfig} = await getMoneyTop(); pointList.value = pointData.items; isPointFinished.value = pointConfig.isFinish; })(), diff --git a/Yi.Bbs.Vue3/src/views/money/Index.vue b/Yi.Bbs.Vue3/src/views/money/Index.vue index 5284f2ca..c133b74f 100644 --- a/Yi.Bbs.Vue3/src/views/money/Index.vue +++ b/Yi.Bbs.Vue3/src/views/money/Index.vue @@ -3,19 +3,21 @@ import AwardPedestal from "./components/AwardPedestal.vue"; import AvatarInfo from "@/components/AvatarInfo.vue"; import { onMounted, reactive, ref, computed } from "vue"; import { - getRankingPoints, + getMoneyTop, + getValueTop, + getPointsTop } from "@/apis/analyseApi.js"; const pointList = ref([]); const total = ref(0); const moneyQuery = reactive({ skipCount: 1, maxResultCount: 30 }); - +const tabSelect=ref("money"); const isFirstPage = computed(() => { - return moneyQuery.skipCount == 1; + return moneyQuery.skipCount === 1; }) const pointListFilter=computed(() => { //如果是第一页,去掉前3个 - if(moneyQuery.skipCount == 1) + if(moneyQuery.skipCount === 1) { return pointList.value.slice(3); } @@ -29,18 +31,49 @@ onMounted(async () => { }); const initData = async () => { - const { data: pointData } = await getRankingPoints(moneyQuery); - pointList.value = pointData.items;; - total.value = pointData.totalCount + switch (tabSelect.value) + { + case "money": + const { data: pointData } = await getMoneyTop(moneyQuery); + pointList.value = pointData.items; + total.value = pointData.totalCount + break; + case "value": + const { data: pointData2 } = await getValueTop(moneyQuery); + pointData2.items.forEach(item => {item.money=item.value}) + pointList.value = pointData2.items; + total.value = pointData2.totalCount + break; + case "points": + const { data: pointData3 } = await getPointsTop(moneyQuery); + pointData3.items.forEach(item => {item.money=item.points}) + pointList.value = pointData3.items; + total.value = pointData3.totalCount + break; + } + } //分页事件 const changePage = async (currentPage) => { await initData(); } + +//切换tab +const handleClickTabs=async (pane) => { + + tabSelect.value=pane.paneName; + moneyQuery.skipCount = 1; + await initData(); +}