1
This commit is contained in:
parent
2b15e68017
commit
3bb3bf5e3a
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 绑定表单
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns></returns>
|
||||
[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; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解说排行榜
|
||||
/// </summary>
|
||||
@ -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<string, int> comCount = new Dictionary<string, int>();
|
||||
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<Item> items = JsonConvert.DeserializeObject<List<Item>>(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 });
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user