成功写入Uesrs数据库表
This commit is contained in:
14
WorkStation.Server/Services/IBaseSerivice.cs
Normal file
14
WorkStation.Server/Services/IBaseSerivice.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using WorkStation.Share;
|
||||
|
||||
namespace WorkStation.Server.Services
|
||||
{
|
||||
public interface IBaseSerivice<T>
|
||||
{
|
||||
Task<ApiResponse> AddAsync(T item);
|
||||
Task<ApiResponse> DelateAsync(int id);
|
||||
Task<ApiResponse> UpdateAsync(T item);
|
||||
Task<ApiResponse> GetByIdAsync(int id);
|
||||
Task<ApiResponse> GetAllAsync();
|
||||
|
||||
}
|
||||
}
|
9
WorkStation.Server/Services/IUserService.cs
Normal file
9
WorkStation.Server/Services/IUserService.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using WorkStation.Server.Context.Entity;
|
||||
|
||||
namespace WorkStation.Server.Services
|
||||
{
|
||||
public interface IUserService : IBaseSerivice<User>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
38
WorkStation.Server/Services/UserService.cs
Normal file
38
WorkStation.Server/Services/UserService.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using Arch.EntityFrameworkCore.UnitOfWork;
|
||||
using WorkStation.Server.Context.Entity;
|
||||
using WorkStation.Share;
|
||||
|
||||
namespace WorkStation.Server.Services
|
||||
{
|
||||
public class UserService(IUnitOfWork unitOfWork) : IUserService
|
||||
{
|
||||
private IUnitOfWork _unitOfWork = unitOfWork;
|
||||
public async Task<ApiResponse> AddAsync(User item)
|
||||
{
|
||||
var repository = _unitOfWork.GetRepository<User>();
|
||||
await repository.InsertAsync(item);
|
||||
var count = await _unitOfWork.SaveChangesAsync();
|
||||
return new ApiResponse(true, "添加数据", count);
|
||||
}
|
||||
|
||||
public Task<ApiResponse> DelateAsync(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<ApiResponse> GetAllAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<ApiResponse> GetByIdAsync(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<ApiResponse> UpdateAsync(User item)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user