121212133

This commit is contained in:
Putoo
2026-07-10 19:37:38 +08:00
parent 2c1bec379d
commit dec8c2e076
6 changed files with 32 additions and 23 deletions

View File

@@ -5,6 +5,7 @@ public interface IRankService
Task<string> GetRankUpdateTime();
Task<List<GameRankModel>> GetGameRank(int type, int area, int page, int limit, RefAsync<int> total);
Task<List<GameRankModel>> GetGameCopperRank(int area, int page, int limit, RefAsync<int> total);
Task<List<GameRankModel>> GetGameLevRank(int area, int page, int limit, RefAsync<int> total);
Task<List<GameRankModel>> GetGameTeachAndRenownRank(int type, int area, int page, int limit, RefAsync<int> total);
Task HandleRank();
}

View File

@@ -24,7 +24,6 @@ public class RankService(ISqlSugarClient DbClient, IRedisCache redis) : IRankSer
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_temp>();
var data = await db.Queryable<unit_user_temp>()
.WhereIF(area != 0, it => it.areaId == area)
.WhereIF(type == 0, it => it.lev > 30)
.WhereIF(type == 1, it => it.atk > 100)
.WhereIF(type == 2, it => it.defense > 100)
.WhereIF(type == 3, it => it.agility > 100)
@@ -32,8 +31,6 @@ public class RankService(ISqlSugarClient DbClient, IRedisCache redis) : IRankSer
.WhereIF(type == 5, it => it.upMorale > 0)
.WhereIF(type == 6, it => it.luck > 0)
.WhereIF(type == 7, it => it.score > 1000)
.OrderByIF(type == 0, it => it.lev, OrderByType.Desc)
.OrderByIF(type == 0, it => it.upTime, OrderByType.Desc)
.OrderByIF(type == 1, it => it.atk, OrderByType.Desc)
.OrderByIF(type == 2, it => it.defense, OrderByType.Desc)
.OrderByIF(type == 3, it => it.agility, OrderByType.Desc)
@@ -64,9 +61,6 @@ public class RankService(ISqlSugarClient DbClient, IRedisCache redis) : IRankSer
string result = "0";
switch (type)
{
case 0:
result = $"{Convert.ToString(data.lev)}级";
break;
case 1:
result = Convert.ToString(data.atk);
break;
@@ -118,6 +112,32 @@ public class RankService(ISqlSugarClient DbClient, IRedisCache redis) : IRankSer
return result;
}
public async Task<List<GameRankModel>> GetGameLevRank(int area, int page, int limit, RefAsync<int> total)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_attr>();
var data = await db.Queryable<unit_user_attr>().LeftJoin<unit_user>((uc, u) => uc.userId == u.userId)
.WhereIF(area != 0, (uc, u) => u.areaId == area)
.Where((uc, u) => uc.lev > 29)
.Select<unit_user_attr>()
.OrderByDescending(uc => uc.lev)
.OrderByDescending(uc=>uc.levUpdate)
.Take(100)
.ToListAsync();
total = data.Count;
data = PageExtend.GetPageList(data, page, limit);
List<GameRankModel> result = new List<GameRankModel>();
foreach (var item in data)
{
GameRankModel temp = new GameRankModel();
temp.userId = item.userId;
temp.user = await UserModelTool.GetUserView(item.userId);
temp.sign = item.lev.ToString();
temp.par = "";
result.Add(temp);
}
return result;
}
public async Task<List<GameRankModel>> GetGameTeachAndRenownRank(int type, int area, int page, int limit, RefAsync<int> total)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_data>();
@@ -170,8 +190,6 @@ public class RankService(ISqlSugarClient DbClient, IRedisCache redis) : IRankSer
{
userId = attrInfo.id,
areaId = attrInfo.area,
lev = attrInfo.lev,
upTime = attrInfo.upTime,
luck = attrInfo.luck,
score = attrInfo.score,
atk = attrInfo.maxAtk,

View File

@@ -18,7 +18,6 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
result.code = nameof(UserEnum.AttrCode.Person);
var unitAttr = await GetUserAttr(userId);
result.lev = (int)unitAttr.lev;
result.upTime = (long)unitAttr.levUpdate;
result.minAtk = (int)unitAttr.minAtk;
result.maxAtk = (int)unitAttr.maxAtk;
result.defense = (int)unitAttr.defense;