LMS.service/LMS.DAO/UserDAO/UserBasicDAO.cs

30 lines
791 B
C#
Raw Normal View History

2024-10-13 17:04:47 +08:00
using LMS.Repository.Models.DB;
using Microsoft.AspNetCore.Identity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LMS.DAO.UserDAO
{
public class UserBasicDao(UserManager<User> userManager)
{
private readonly UserManager<User> _userManager = userManager;
/// <summary>
/// 检查用户是否存在,通过用户ID
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public async Task<bool> CheckUserExistsByID(long? userId)
{
if (userId == null)
{
return false;
}
return await _userManager.FindByIdAsync(userId.ToString()) != null;
}
}
}