asg_backend/asg_form/Controllers/InviteReferee.cs

57 lines
1.8 KiB
C#
Raw Normal View History

2024-08-20 17:32:06 +08:00
using Masuit.Tools;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
2024-08-20 17:20:58 +08:00
using Microsoft.AspNetCore.Mvc;
2024-08-20 17:32:06 +08:00
using Microsoft.EntityFrameworkCore;
using System.Security.Claims;
2024-08-20 17:20:58 +08:00
namespace asg_form.Controllers
{
2024-08-20 17:20:58 +08:00
public class InviteReferee : ControllerBase
{
private readonly RoleManager<Role> roleManager;
private readonly UserManager<User> userManager;
public InviteReferee(
RoleManager<Role> roleManager, UserManager<User> userManager)
{
this.roleManager = roleManager;
this.userManager = userManager;
}
2024-10-10 09:59:47 +08:00
public class InviteBg
{
public int id { get; set; }
public int userId { get; set; }
public List<int> myRequest { get; set; }
}
2024-08-20 17:32:06 +08:00
[Route("api/v1/Invite")]
[HttpGet]
[Authorize]
public async Task<ActionResult<object>> GetReferee([FromBody] long Inviteeid)
{
string Invitorid = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
var user = await userManager.FindByIdAsync(Invitorid);
2024-10-10 09:59:47 +08:00
long userId = user.Id;
2024-08-20 17:32:06 +08:00
using (TestDbContext sb = new TestDbContext())
{
2024-10-10 09:59:47 +08:00
try
{
//var userInvited = await userManager.Users.FirstOrDefaultAsync(x => x.Id == Inviteeid);
//if (userInvited != null) return Ok(new { code = 404, message = "用户未找到" });
var query = await sb.T_Invitation.FindAsync(Inviteeid);
}catch (Exception ex)
{
return Ok(new { code = 500, message = "服务器错误", details = ex.Message });
}
2024-08-20 17:32:06 +08:00
return Ok();
}
}
}
}