完善大部分问题
This commit is contained in:
20
Yi.Framework.Net6/Yi.Framework.Service/BaseService.cs
Normal file
20
Yi.Framework.Net6/Yi.Framework.Service/BaseService.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Repository;
|
||||
|
||||
namespace Yi.Framework.Service
|
||||
{
|
||||
public class BaseService<T>:IBaseService<T> where T:BaseModelEntity,new()
|
||||
{
|
||||
public IRepository<T> _repository { get; set; }
|
||||
public BaseService(IRepository<T> iRepository)
|
||||
{
|
||||
_repository = iRepository;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@ using Yi.Framework.Repository;
|
||||
|
||||
namespace Yi.Framework.Service
|
||||
{
|
||||
public partial class TenantService : Repository<TenantEntity>, ITenantService
|
||||
public partial class TenantService : BaseService<TenantEntity>, ITenantService
|
||||
{
|
||||
public TenantService(ISqlSugarClient context) : base(context)
|
||||
public TenantService(IRepository<TenantEntity> repository) : base(repository)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ using Yi.Framework.Repository;
|
||||
|
||||
namespace Yi.Framework.Service
|
||||
{
|
||||
public partial class UserService : Repository<UserEntity>, IUserService
|
||||
public partial class UserService : BaseService<UserEntity>, IUserService
|
||||
{
|
||||
public UserService(ISqlSugarClient context) : base(context)
|
||||
public UserService(IRepository<UserEntity> repository) : base(repository)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Yi.Framework.Service
|
||||
{
|
||||
public async Task<bool> Exist(Guid id, Action<UserEntity> userAction = null)
|
||||
{
|
||||
var user = await GetByIdAsync(id);
|
||||
var user = await _repository.GetByIdAsync(id);
|
||||
userAction.Invoke(user);
|
||||
if (user == null)
|
||||
{
|
||||
@@ -22,7 +22,7 @@ namespace Yi.Framework.Service
|
||||
}
|
||||
public async Task<bool> Exist(string userName, Action<UserEntity> userAction = null)
|
||||
{
|
||||
var user = await GetFirstAsync(u=>u.UserName== userName);
|
||||
var user = await _repository.GetFirstAsync(u=>u.UserName== userName);
|
||||
if (userAction != null)
|
||||
{
|
||||
userAction.Invoke(user);
|
||||
@@ -55,7 +55,7 @@ namespace Yi.Framework.Service
|
||||
user.UserName= userEntity.UserName;
|
||||
user.Salt = Common.Helper.MD5Helper.GenerateSalt();
|
||||
user.Password = Common.Helper.MD5Helper.SHA2Encode(userEntity.Password,user.Salt);
|
||||
userAction.Invoke(await InsertReturnEntityAsync(user));
|
||||
userAction.Invoke(await _repository.InsertReturnEntityAsync(user));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user