完善大部分问题

This commit is contained in:
橙子
2022-04-08 23:44:25 +08:00
parent 5fcd4fb5a4
commit feb73174eb
26 changed files with 160 additions and 160 deletions

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

View File

@@ -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)
{
}
}

View File

@@ -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)
{
}
}

View File

@@ -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;