成功写入Uesrs数据库表

This commit is contained in:
2025-07-07 18:41:36 +08:00
parent a3996dad99
commit 547142730e
17 changed files with 170 additions and 59 deletions

View 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();
}
}

View File

@ -0,0 +1,9 @@
using WorkStation.Server.Context.Entity;
namespace WorkStation.Server.Services
{
public interface IUserService : IBaseSerivice<User>
{
}
}

View 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();
}
}
}