using Apimanager_backend.Config; using Apimanager_backend.Data; using Apimanager_backend.Dtos; using Apimanager_backend.Exceptions; using Apimanager_backend.Models; using AutoMapper; using Microsoft.AspNetCore.Connections.Features; using Microsoft.EntityFrameworkCore; using System.ComponentModel; namespace Apimanager_backend.Services { public class UserService : IUserService { private readonly ApiContext apiContext; private readonly IMapper mapper; public UserService(ApiContext apiContext,IMapper automapper) { this.apiContext = apiContext; this.mapper = automapper; } public Task BanUserAsync(string username) { throw new NotImplementedException(); } public Task CreateUserAsync(CreateUserDto user) { throw new NotImplementedException(); } public Task DeleteUserAsync(string username) { throw new NotImplementedException(); } public async Task GetUserAsync(int userId) { User? user = await apiContext.Users.SingleOrDefaultAsync(x => x.Id == userId); //未找到用户 if (user == null) { throw new BaseException(2004, "User not found"); } return mapper.Map(user); } public Task> GetUsersAsync(int page, int pageSize, bool desc) { throw new NotImplementedException(); } public async Task IsEmailExist(string email) { return await apiContext.Users.AnyAsync(x => x.Email == email); } public async Task IsUsernameExist(string username) { return await apiContext.Users.AnyAsync(x => x.Username == username); } public Task ResetPasswordAsync(string email, string token, string newPassword) { throw new NotImplementedException(); } public Task SendResetPasswordEmailAsync(string email) { throw new NotImplementedException(); } public Task UnbanUserAsync(string username) { throw new NotImplementedException(); } public Task UpdateUserAsync(UpdateUserDto user) { throw new NotImplementedException(); } } }