From 3bb3bf5e3a4e70fc502f2a0ac734b3ddeb2b899a Mon Sep 17 00:00:00 2001
From: pivotqwq <2307953404@qq.com>
Date: Tue, 29 Apr 2025 22:58:16 +0800
Subject: [PATCH] 1
---
asg_form/Controllers/user_form.cs | 63 ++++++++++++++++++++++---------
1 file changed, 46 insertions(+), 17 deletions(-)
diff --git a/asg_form/Controllers/user_form.cs b/asg_form/Controllers/user_form.cs
index a446c60..a41e64b 100644
--- a/asg_form/Controllers/user_form.cs
+++ b/asg_form/Controllers/user_form.cs
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
+using Newtonsoft.Json;
using System.Buffers.Text;
using System.Data;
using System.Security.Claims;
@@ -26,12 +27,12 @@ namespace asg_form.Controllers
this.roleManager = roleManager;
this.userManager = userManager;
}
-
+
///
/// 绑定表单
///
- ///
+ ///
[Authorize]
[Route("api/v1/user/uploadvideo")]
[HttpPost]
@@ -190,9 +191,16 @@ namespace asg_form.Controllers
public string username { get; set; }
public string joinTime { get; set; }
public string base64 { get; set; }
+ public int joinCount { get; set; }
public int count { get; set; }
}
+ public class Item
+ {
+ public int id { get; set; }
+ public string chinaname { get; set; }
+ }
+
///
/// 解说排行榜
///
@@ -204,22 +212,43 @@ namespace asg_form.Controllers
try
{
DateTime currentTime = DateTime.Now;
-
- var rankings = userManager.Users
- .Where(u => u.joinTime != null && u.officium == "Commentator")
- .AsEnumerable()
- .OrderByDescending(u => (currentTime - u.joinTime.ToDateTime()).TotalSeconds)
- .Skip((page - 1) * limit)
- .Take(limit)
- .Select(u => new userRanking
+ Dictionary comCount = new Dictionary();
+ comCount.Add("默认",0);
+ TestDbContext db = new TestDbContext();
+ var gameAll = db.team_Games.Select(g => g.commentary).ToList();
+ foreach (var game in gameAll)
+ {
+ if (game == null) continue;
+ List- items = JsonConvert.DeserializeObject
>(game);
+ foreach (var item in items)
{
- userId = u.Id,
- username = u.chinaname,
- joinTime = u.joinTime,
- base64 = u.UserBase64,
- //count = (int)((currentTime - u.joinTime.ToDateTime()).TotalSeconds/ 86400),
- })
- .ToList();
+ if (comCount.ContainsKey(item.chinaname))
+ {
+ comCount.Add(item.chinaname, 1);
+ }
+ else
+ {
+ comCount[item.chinaname] += 1;
+ }
+ }
+ }
+ var rankings = userManager.Users
+ .Where(u => u.joinTime != null && u.officium == "Commentator")
+ .AsEnumerable()
+ .Select(u => new userRanking
+ {
+ userId = u.Id,
+ username = u.chinaname,
+ joinTime = u.joinTime,
+ base64 = u.UserBase64,
+ joinCount = (int)((currentTime - u.joinTime.ToDateTime()).TotalSeconds / 86400),
+ count = comCount[u.chinaname == null ? "默认" : u.chinaname]
+ })
+ .OrderByDescending(u => u.count)
+ .Skip((page - 1) * limit)
+ .Take(limit)
+ .ToList();
+
return Ok(new { code = 200, message = "", rankings });
}