解说加入时间

This commit is contained in:
王炜翔 2025-04-09 23:04:55 +08:00
parent c48ff0418e
commit 23df6cacca
2 changed files with 28 additions and 2 deletions

View File

@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Data;
using System.Security.Claims;
using static asg_form.blog;
@ -183,8 +184,32 @@ namespace asg_form.Controllers
}
public class timeSet
{
public string joinTime { get; set; }
}
/// <summary>
/// 职位时间设置接口
/// </summary>
/// <returns></returns>
[Authorize]
[Route("api/v1/user/settime")]
[HttpPost]
public async Task<ActionResult<object>> settime([FromBody] timeSet msg)
{
string userId = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
var user = await userManager.FindByIdAsync(userId);
if(user.officium != "Commentator")
{
return Ok(new { code = 200, message = "你不是解说,不参与排名!" });
}
user.joinTime = msg.joinTime;
await userManager.UpdateAsync(user);
return Ok(new { code = 200, message = "你成功修改了自己加入ASG的时间" });
}
}

View File

@ -29,6 +29,7 @@ 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>