1
This commit is contained in:
parent
5dc30419e1
commit
56e210d9c0
@ -467,16 +467,13 @@ public async Task<ActionResult<all_record>> GetAdminUsersV2(string? keyword = nu
|
||||
{
|
||||
if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
||||
{
|
||||
|
||||
var ouser = await userManager.FindByIdAsync(userid);
|
||||
var ouser = await userManager.FindByIdAsync(userid);
|
||||
|
||||
ouser.officium = opname;
|
||||
|
||||
if(ouser.joinTime == null) ouser.joinTime = DateTime.Now.ToString();
|
||||
|
||||
await userManager.UpdateAsync(ouser);
|
||||
|
||||
|
||||
return Ok(new { code = 200, message = "成功" });
|
||||
return "成功!";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,15 +1,14 @@
|
||||
using Manganese.Text;
|
||||
using Masuit.Tools;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SharpCompress.Archives;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
using System.Data;
|
||||
>>>>>>> parent of 5dc3041 (排行榜)
|
||||
using System.Security.Claims;
|
||||
using static asg_form.blog;
|
||||
using static asg_form.Controllers.user_form;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace asg_form.Controllers
|
||||
{
|
||||
@ -188,52 +187,31 @@ namespace asg_form.Controllers
|
||||
|
||||
}
|
||||
|
||||
public class timeSet
|
||||
{
|
||||
public string joinTime { get; set; }
|
||||
}
|
||||
|
||||
public class userRanking
|
||||
{
|
||||
public long userId { get; set; }
|
||||
public string username { get; set; }
|
||||
public string joinTime { get; set; }
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
/// <summary>
|
||||
/// 解说排行榜
|
||||
/// 职位时间设置接口
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Route("api/v1/user/ranking")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<object>> rankingList(short page = 1, short limit = 10)
|
||||
[Authorize]
|
||||
[Route("api/v1/user/settime")]
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<object>> settime([FromBody] timeSet msg)
|
||||
{
|
||||
try
|
||||
|
||||
string userId = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
||||
var user = await userManager.FindByIdAsync(userId);
|
||||
if(user.officium != "Commentator")
|
||||
{
|
||||
DateTime currentTime = DateTime.Now;
|
||||
|
||||
var rankings = userManager.Users
|
||||
.Where(u => u.joinTime != null && u.officium == "Commentator")
|
||||
.OrderByDescending(u => (currentTime - u.joinTime.ToDateTime()).TotalSeconds)
|
||||
.Skip((page - 1) * limit)
|
||||
.Take(limit)
|
||||
.Select(u => new userRanking
|
||||
{
|
||||
userId = u.Id,
|
||||
username = u.chinaname,
|
||||
joinTime = u.joinTime,
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return Ok(new { code = 200, message = "", rankings });
|
||||
return Ok(new { code = 200, message = "你不是解说,不参与排名!" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, new { code = 500, message = "获取排行榜失败", error = ex.Message });
|
||||
}
|
||||
|
||||
user.joinTime = msg.joinTime;
|
||||
await userManager.UpdateAsync(user);
|
||||
return Ok(new { code = 200, message = "你成功修改了自己加入ASG的时间!" });
|
||||
>>>>>>> parent of 5dc3041 (排行榜)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ namespace asg_form
|
||||
//public List<string>? Roles { get; set; }
|
||||
public string? roleListName { get; set; }
|
||||
public string? roleListCode { get; set; }
|
||||
public string? joinTime { get; set; }
|
||||
}
|
||||
|
||||
public class Role : IdentityRole<long>
|
||||
|
Loading…
x
Reference in New Issue
Block a user