55 lines
1.3 KiB
C#
55 lines
1.3 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System.Security.Claims;
|
|
|
|
namespace asg_form.Controllers
|
|
{
|
|
|
|
|
|
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
public class qqbotr : ControllerBase
|
|
{
|
|
private readonly RoleManager<Role> roleManager;
|
|
private readonly UserManager<User> userManager;
|
|
public qqbotr(
|
|
RoleManager<Role> roleManager, UserManager<User> userManager)
|
|
{
|
|
|
|
this.roleManager = roleManager;
|
|
this.userManager = userManager;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置qq号
|
|
/// </summary>
|
|
/// <param name="qqnumber"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Authorize]
|
|
public async Task<ActionResult<int>> qqnumber(string qqnumber)
|
|
{
|
|
|
|
|
|
string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
|
var user = await userManager.FindByIdAsync(id);
|
|
user.qqnumber= qqnumber;
|
|
var r = await userManager.UpdateAsync(user);
|
|
return Ok("修改成功");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|