feat: 完成基础接口搭建
This commit is contained in:
@@ -1,8 +1,47 @@
|
|||||||
using Volo.Abp.Application.Dtos;
|
using Volo.Abp.Application.Dtos;
|
||||||
|
using Yi.Framework.DigitalCollectibles.Domain.Shared.Consts;
|
||||||
|
|
||||||
namespace Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Market;
|
namespace Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Market;
|
||||||
|
|
||||||
public class MarketGetListOutputDto:EntityDto<Guid>
|
public class MarketGetListOutputDto:EntityDto<Guid>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 藏品编号
|
||||||
|
/// </summary>
|
||||||
|
public string Code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 藏品名称
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 藏品描述
|
||||||
|
/// </summary>
|
||||||
|
public string? Describe { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 价值数
|
||||||
|
/// </summary>
|
||||||
|
public decimal ValueNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 藏品地址
|
||||||
|
/// </summary>
|
||||||
|
public string Url { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 稀有度
|
||||||
|
/// </summary>
|
||||||
|
public RarityEnum Rarity{ get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 总共出现次数
|
||||||
|
/// </summary>
|
||||||
|
public int FindTotal { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 排序
|
||||||
|
/// </summary>
|
||||||
|
public int OrderNum { get; set; }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
namespace Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.MiningPool;
|
||||||
|
|
||||||
|
public class MiningPoolGetOutput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 普通藏品剩余数量
|
||||||
|
/// </summary>
|
||||||
|
public int I0_OrdinaryNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 高级藏品剩余数量
|
||||||
|
/// </summary>
|
||||||
|
public int I1_SeniorNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 稀有藏品剩余数量
|
||||||
|
/// </summary>
|
||||||
|
public int I2_RareNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 珍品藏品剩余数量
|
||||||
|
/// </summary>
|
||||||
|
public int I3_GemNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 传说藏品剩余数量
|
||||||
|
/// </summary>
|
||||||
|
public int I4_LegendNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开始时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime StartTime{ get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 结束时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime EndTime{ get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 总共剩余藏品数量
|
||||||
|
/// </summary>
|
||||||
|
public int TotalNumber => I0_OrdinaryNumber + I1_SeniorNumber + I2_RareNumber + I3_GemNumber + I4_LegendNumber;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Collectibles;
|
||||||
|
using Yi.Framework.DigitalCollectibles.Domain.Shared.Enums;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.MiningPool;
|
||||||
|
|
||||||
|
public class MiningResultOutput
|
||||||
|
{
|
||||||
|
public MiningResultEnum Result { get; set; }
|
||||||
|
|
||||||
|
public CollectiblesUserGetOutputDto? Collectibles { get; set; }
|
||||||
|
}
|
||||||
@@ -29,7 +29,7 @@ public class CollectiblesService : ApplicationService
|
|||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
[HttpGet("user")]
|
[HttpGet("collectibles/user")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<PagedResultDto<CollectiblesUserGetOutputDto>> GetForAccountUserAsync(
|
public async Task<PagedResultDto<CollectiblesUserGetOutputDto>> GetForAccountUserAsync(
|
||||||
CollectiblesUserGetInput input)
|
CollectiblesUserGetInput input)
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using Mapster;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Volo.Abp.Application.Services;
|
||||||
|
using Volo.Abp.Users;
|
||||||
|
using Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.MiningPool;
|
||||||
|
using Yi.Framework.DigitalCollectibles.Domain.Managers;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DigitalCollectibles.Application.Services;
|
||||||
|
|
||||||
|
public class MiningPoolService : ApplicationService
|
||||||
|
{
|
||||||
|
private readonly MiningPoolManager _manager;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取矿池状态
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("mining-pool")]
|
||||||
|
public async Task<MiningPoolGetOutput> GetMiningPoolContentAsync()
|
||||||
|
{
|
||||||
|
var content = await _manager.GetMiningPoolContentAsync();
|
||||||
|
var output = content.Adapt<MiningPoolGetOutput>();
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户手动挖矿
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("mining-pool/mining")]
|
||||||
|
[Authorize]
|
||||||
|
public async Task<MiningResultOutput> MiningAsync()
|
||||||
|
{
|
||||||
|
var userId = CurrentUser.GetId();
|
||||||
|
var result = await _manager.MiningAsync(userId);
|
||||||
|
var output = result.Adapt<MiningResultOutput>();
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,6 +44,12 @@ public class MiningPoolManager : DomainService
|
|||||||
return await ComputeMiningProbabilityAsync();
|
return await ComputeMiningProbabilityAsync();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
public async Task<MiningPoolContent> GetMiningPoolContentAsync()
|
||||||
|
{
|
||||||
|
var pool = await _cache.GetAsync(CacheConst.MiningPoolContent);
|
||||||
|
return pool;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户进行一次挖矿
|
/// 用户进行一次挖矿
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -56,7 +62,7 @@ public class MiningPoolManager : DomainService
|
|||||||
//挖到了放到用户仓库即可
|
//挖到了放到用户仓库即可
|
||||||
|
|
||||||
//如果概率是挖到了矿,再从矿物中随机选择一个稀有度,再在当前稀有度中的矿物列表,随机选择一个具体的矿物
|
//如果概率是挖到了矿,再从矿物中随机选择一个稀有度,再在当前稀有度中的矿物列表,随机选择一个具体的矿物
|
||||||
var pool = await _cache.GetAsync(CacheConst.MiningPoolContent);
|
var pool =await GetMiningPoolContentAsync();
|
||||||
if (pool.TotalNumber == 0)
|
if (pool.TotalNumber == 0)
|
||||||
{
|
{
|
||||||
result.Result = MiningResultEnum.PoolIsEmpty;
|
result.Result = MiningResultEnum.PoolIsEmpty;
|
||||||
|
|||||||
Reference in New Issue
Block a user