完善大部分问题

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

Binary file not shown.

View File

@@ -10,13 +10,6 @@
</summary> </summary>
<typeparam name="T"></typeparam> <typeparam name="T"></typeparam>
</member> </member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.#ctor(Microsoft.Extensions.Logging.ILogger{`0},Yi.Framework.Repository.IRepository{`0})">
<summary>
jb
</summary>
<param name="logger"></param>
<param name="iRepository"></param>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.Get(System.Object)"> <member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.Get(System.Object)">
<summary> <summary>
主键查询 主键查询
@@ -24,13 +17,13 @@
<param name="id"></param> <param name="id"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.GetList"> <member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.GetList(Yi.Framework.Model.Query.QueryCondition)">
<summary> <summary>
列表查询 列表查询
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.Page(Yi.Framework.Model.Query.QueryCondition)"> <member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.Page(Yi.Framework.Model.Query.QueryPageCondition)">
<summary> <summary>
条件分页查询 条件分页查询
</summary> </summary>
@@ -51,7 +44,7 @@
<param name="entity"></param> <param name="entity"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.DeleteList(System.Object[])"> <member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.DeleteList(System.Collections.Generic.List{System.Guid})">
<summary> <summary>
列表删除 列表删除
</summary> </summary>

View File

@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Yi.Framework.Common.Models; using Yi.Framework.Common.Models;
using Yi.Framework.Core;
using Yi.Framework.DTOModel; using Yi.Framework.DTOModel;
using Yi.Framework.Interface; using Yi.Framework.Interface;
using Yi.Framework.Model.Models; using Yi.Framework.Model.Models;
@@ -21,9 +22,11 @@ namespace Yi.Framework.ApiMicroservice.Controllers
public class AccountController :ControllerBase public class AccountController :ControllerBase
{ {
private IUserService _iUserService; private IUserService _iUserService;
public AccountController(ILogger<UserEntity> logger, IUserService iUserService) private JwtInvoker _jwtInvoker;
public AccountController(ILogger<UserEntity> logger, IUserService iUserService, JwtInvoker jwtInvoker)
{ {
_iUserService = iUserService; _iUserService = iUserService;
_jwtInvoker = jwtInvoker;
} }
[AllowAnonymous] [AllowAnonymous]
@@ -32,8 +35,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers
{ {
UserEntity user=new(); UserEntity user=new();
if (await _iUserService.Login(loginDto.UserName, loginDto.Password,o=> user=o)) if (await _iUserService.Login(loginDto.UserName, loginDto.Password,o=> user=o))
{ {
return Result.Success("登录成功!").SetData(user); return Result.Success("登录成功!").SetData(new { user, token = _jwtInvoker.GetAccessToken(user)});
} }
return Result.SuccessError("登录失败!用户名或者密码错误!"); return Result.SuccessError("登录失败!用户名或者密码错误!");
} }

View File

@@ -1,5 +1,7 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Yi.Framework.Common.Models; using Yi.Framework.Common.Models;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
using Yi.Framework.Model.Query; using Yi.Framework.Model.Query;
using Yi.Framework.Repository; using Yi.Framework.Repository;
using Yi.Framework.WebCore.AttributeExtend; using Yi.Framework.WebCore.AttributeExtend;
@@ -12,19 +14,17 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
[ApiController] [ApiController]
[Route("api/[controller]/[action]")] [Route("api/[controller]/[action]")]
public class BaseCrudController<T> : ControllerBase where T : class,new() public class BaseCrudController<T> : ControllerBase where T : BaseModelEntity,new()
{ {
private readonly ILogger<T> _logger; public readonly ILogger<T> _logger;
public IRepository<T> _iRepository; public IBaseService<T> _baseService;
/// <summary> public IRepository<T> _repository;
/// jb
/// </summary> public BaseCrudController(ILogger<T> logger, IBaseService<T> iBaseService)
/// <param name="logger"></param>
/// <param name="iRepository"></param>
public BaseCrudController(ILogger<T> logger, IRepository<T> iRepository)
{ {
_logger = logger; _logger = logger;
_iRepository = iRepository; _baseService = iBaseService;
_repository = iBaseService._repository;
} }
/// <summary> /// <summary>
@@ -36,7 +36,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
[HttpGet] [HttpGet]
public async Task<Result> Get(object id) public async Task<Result> Get(object id)
{ {
return Result.Success().SetData(await _iRepository.GetByIdAsync(id)); return Result.Success().SetData(await _repository.GetByIdAsync(id));
} }
/// <summary> /// <summary>
@@ -44,10 +44,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[Permission($"{nameof(T)}:get:list")] [Permission($"{nameof(T)}:get:list")]
[HttpGet] [HttpPost]
public async Task<Result> GetList() public async Task<Result> GetList(QueryCondition queryCondition)
{ {
return Result.Success().SetData(await _iRepository.GetListAsync()); return Result.Success().SetData(await _repository.GetListAsync(queryCondition));
} }
/// <summary> /// <summary>
@@ -57,9 +57,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// <returns></returns> /// <returns></returns>
[Permission($"{nameof(T)}:get:page")] [Permission($"{nameof(T)}:get:page")]
[HttpPost] [HttpPost]
public async Task<Result> Page(QueryCondition queryCondition) public async Task<Result> Page(QueryPageCondition queryCondition)
{ {
return Result.Success().SetData(await _iRepository.CommonPage(queryCondition)); return Result.Success().SetData(await _repository.CommonPage(queryCondition));
} }
/// <summary> /// <summary>
@@ -71,7 +71,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
[HttpPost] [HttpPost]
public async Task<Result> Add(T entity) public async Task<Result> Add(T entity)
{ {
return Result.Success().SetData(await _iRepository.InsertReturnEntityAsync(entity)); return Result.Success().SetData(await _repository.InsertReturnEntityAsync(entity));
} }
/// <summary> /// <summary>
@@ -83,7 +83,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
[HttpPut] [HttpPut]
public async Task<Result> Update(T entity) public async Task<Result> Update(T entity)
{ {
return Result.Success().SetStatus(await _iRepository.UpdateAsync(entity)); return Result.Success().SetStatus(await _repository.UpdateAsync(entity));
} }
/// <summary> /// <summary>
@@ -93,9 +93,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// <returns></returns> /// <returns></returns>
[Permission($"{nameof(T)}:delete:list")] [Permission($"{nameof(T)}:delete:list")]
[HttpDelete] [HttpDelete]
public async Task<Result> DeleteList(object[] ids) public async Task<Result> DeleteList(List<Guid> ids)
{ {
return Result.Success().SetStatus(await _iRepository.DeleteByIdsAsync(ids)); return Result.Success().SetStatus(await _repository.DeleteByLogic(ids));
} }
} }
} }

View File

@@ -127,7 +127,7 @@ ServiceLocator.Instance = app.Services;
#region #region
//<2F><><EFBFBD><EFBFBD>ץȡ<D7A5><C8A1><EFBFBD><EFBFBD>ע<EFBFBD><D7A2> //<2F><><EFBFBD><EFBFBD>ץȡ<D7A5><C8A1><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
#endregion #endregion
app.UseErrorHandlingService(); //app.UseErrorHandlingService();
#region #region
//<2F><>̬<EFBFBD>ļ<EFBFBD>ע<EFBFBD><D7A2> //<2F><>̬<EFBFBD>ļ<EFBFBD>ע<EFBFBD><D7A2>
#endregion #endregion

View File

@@ -38,10 +38,14 @@
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]" "server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]"
] ]
}, },
"JWTTokenOptions": { "JwtAuthorize": {
"Audience": "http://localhost:7000", "Issuer": "cc",
"Issuer": "http://localhost:7000", "Audience": "cc",
"SecurityKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB" "PolicyName": "permission",
"DefaultScheme": "Bearer",
"IsHttps": false,
"Expiration": 30,
"ReExpiration": 3000
}, },
"RedisConnOptions": { "RedisConnOptions": {
"Host": "[xxxx]", "Host": "[xxxx]",

View File

@@ -11,8 +11,6 @@ namespace Yi.Framework.Common.IOCOptions
public string Issuer { get; set; } public string Issuer { get; set; }
public string SecurityKey { get; set; }
public string DefaultScheme { get; set; } public string DefaultScheme { get; set; }
public int Expiration { get; set; } public int Expiration { get; set; }

View File

@@ -23,22 +23,4 @@
<ProjectReference Include="..\Yi.Framework.Task\Yi.Framework.Job.csproj" /> <ProjectReference Include="..\Yi.Framework.Task\Yi.Framework.Job.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Bcl.AsyncInterfaces">
<HintPath>Library\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Common">
<HintPath>Library\ServiceStack.Common.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Interfaces">
<HintPath>Library\ServiceStack.Interfaces.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Redis">
<HintPath>Library\ServiceStack.Redis.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Text">
<HintPath>Library\ServiceStack.Text.dll</HintPath>
</Reference>
</ItemGroup>
</Project> </Project>

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
namespace Yi.Framework.Interface
{
public interface IBaseService<T> where T:BaseModelEntity,new()
{
public IRepository<T> _repository { get; set; }
}
}

View File

@@ -3,7 +3,7 @@ using Yi.Framework.Repository;
namespace Yi.Framework.Interface namespace Yi.Framework.Interface
{ {
public partial interface ITenantService: IRepository<TenantEntity> public partial interface ITenantService:IBaseService<TenantEntity>
{ {
} }
} }

View File

@@ -3,7 +3,7 @@ using Yi.Framework.Repository;
namespace Yi.Framework.Interface namespace Yi.Framework.Interface
{ {
public partial interface IUserService: IRepository<UserEntity> public partial interface IUserService:IBaseService<UserEntity>
{ {
} }
} }

View File

@@ -41,16 +41,6 @@ namespace Yi.Framework.Model.Models
[SugarColumn(ColumnName = "ModifyTime")] [SugarColumn(ColumnName = "ModifyTime")]
public DateTime? ModifyTime { get; set; } public DateTime? ModifyTime { get; set; }
/// <summary> /// <summary>
/// 删除者
///</summary>
[SugarColumn(ColumnName = "DeleteUser")]
public Guid? DeleteUser { get; set; }
/// <summary>
/// 删除时间
///</summary>
[SugarColumn(ColumnName = "DeleteTime")]
public DateTime? DeleteTime { get; set; }
/// <summary>
/// 是否删除 /// 是否删除
///</summary> ///</summary>
[SugarColumn(ColumnName = "IsDeleted")] [SugarColumn(ColumnName = "IsDeleted")]

View File

@@ -8,38 +8,12 @@ namespace Yi.Framework.Model.Models
/// 租户表 /// 租户表
///</summary> ///</summary>
[SugarTable("Tenant")] [SugarTable("Tenant")]
public partial class TenantEntity public partial class TenantEntity:BaseModelEntity
{ {
public TenantEntity()
{
this.Id=Guid.NewGuid();
this.IsDeleted=false;
this.CreateTime = DateTime.Now;
}
/// <summary> /// <summary>
/// 1 /// 租户名
///</summary> ///</summary>
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )] [SugarColumn(ColumnName="TenantName" )]
public Guid Id { get; set; } public string TenantName { get; set; }
/// <summary>
/// 创建者
///</summary>
[SugarColumn(ColumnName="CreateUser" )]
public Guid? CreateUser { get; set; }
/// <summary>
/// 创建时间
///</summary>
[SugarColumn(ColumnName="CreateTime" )]
public DateTime? CreateTime { get; set; }
/// <summary>
/// 修改时间
///</summary>
[SugarColumn(ColumnName="ModifyTime" )]
public DateTime? ModifyTime { get; set; }
/// <summary>
/// 是否删除
///</summary>
[SugarColumn(ColumnName="IsDeleted" )]
public bool? IsDeleted { get; set; }
} }
} }

View File

@@ -11,11 +11,6 @@ namespace Yi.Framework.Model.Models
public partial class UserEntity:BaseModelEntity public partial class UserEntity:BaseModelEntity
{ {
/// <summary> /// <summary>
/// 1
///</summary>
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
public Guid Id { get; set; }
/// <summary>
/// 姓名 /// 姓名
///</summary> ///</summary>
[SugarColumn(ColumnName="Name" )] [SugarColumn(ColumnName="Name" )]
@@ -26,31 +21,6 @@ namespace Yi.Framework.Model.Models
[SugarColumn(ColumnName="Age" )] [SugarColumn(ColumnName="Age" )]
public int? Age { get; set; } public int? Age { get; set; }
/// <summary> /// <summary>
/// 创建者
///</summary>
[SugarColumn(ColumnName="CreateUser" )]
public Guid? CreateUser { get; set; }
/// <summary>
/// 创建时间
///</summary>
[SugarColumn(ColumnName="CreateTime" )]
public DateTime? CreateTime { get; set; }
/// <summary>
/// 修改者
///</summary>
[SugarColumn(ColumnName="ModifyUser" )]
public Guid? ModifyUser { get; set; }
/// <summary>
/// 修改时间
///</summary>
[SugarColumn(ColumnName="ModifyTime" )]
public DateTime? ModifyTime { get; set; }
/// <summary>
/// 是否删除
///</summary>
[SugarColumn(ColumnName="IsDeleted" )]
public bool? IsDeleted { get; set; }
/// <summary>
/// 租户Id /// 租户Id
///</summary> ///</summary>
[SugarColumn(ColumnName="TenantId" )] [SugarColumn(ColumnName="TenantId" )]

View File

@@ -6,11 +6,18 @@ using System.Threading.Tasks;
namespace Yi.Framework.Model.Query namespace Yi.Framework.Model.Query
{ {
public class QueryCondition public class QueryPageCondition
{ {
public int Index { get; set; } public int Index { get; set; }
public int Size { get; set; } public int Size { get; set; }
public int Count { get; set; }
public List<QueryParameter> Parameters { get; set; } = new List<QueryParameter>();
public List<string> OrderBys { get; set; } = new List<string>();
}
public class QueryCondition
{
public List<QueryParameter> Parameters { get; set; } = new List<QueryParameter>(); public List<QueryParameter> Parameters { get; set; } = new List<QueryParameter>();
public List<string> OrderBys { get; set; } = new List<string>(); public List<string> OrderBys { get; set; } = new List<string>();

View File

@@ -1,16 +1,19 @@
using SqlSugar; using Newtonsoft.Json.Converters;
using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Yi.Framework.Model.Query namespace Yi.Framework.Model.Query
{ {
public class QueryParameter public class QueryParameter
{ {
public string FieldName { get; set; } public string Key { get; set; }
public string FieldValue { get; set; } public string Value { get; set; }
public ConditionalType ConditionalType { get; set; } = ConditionalType.Like; [JsonConverter(typeof(StringEnumConverter))]
public ConditionalType Type { get; set; } = ConditionalType.Like;
} }
} }

View File

@@ -15,6 +15,8 @@ namespace Yi.Framework.Repository
{ {
public Task<T> InsertReturnEntityAsync(T entity); public Task<T> InsertReturnEntityAsync(T entity);
public Task<List<S>> StoreAsync<S>(string storeName, object para); public Task<List<S>> StoreAsync<S>(string storeName, object para);
public Task<PageModel<List<T>>> CommonPage(QueryCondition pars); public Task<PageModel<List<T>>> CommonPage(QueryPageCondition pars);
public Task<List<T>> GetListAsync(QueryCondition pars);
public Task<bool> DeleteByLogic(List<Guid> ids);
} }
} }

View File

@@ -34,6 +34,18 @@ namespace Yi.Framework.Repository
return await Db.Insertable(entity).ExecuteReturnEntityAsync(); return await Db.Insertable(entity).ExecuteReturnEntityAsync();
} }
/// <summary>
/// 逻辑多删除
/// </summary>
/// <returns></returns>
public async Task<bool> DeleteByLogic(List<Guid> ids)
{
var entitys = await Db.Queryable<T>().Where(u => ids.Contains(u.Id)).ToListAsync();
entitys.ForEach(u=>u.IsDeleted=true);
return await Db.Updateable(entitys).ExecuteCommandAsync()>0;
}
/// <summary> /// <summary>
/// 调用存储过程 /// 调用存储过程
/// </summary> /// </summary>
@@ -46,18 +58,41 @@ namespace Yi.Framework.Repository
return await Db.Ado.UseStoredProcedure().SqlQueryAsync<S>(storeName, para); return await Db.Ado.UseStoredProcedure().SqlQueryAsync<S>(storeName, para);
} }
/// <summary>
/// 多条件查询
/// </summary>
/// <param name="pars"></param>
/// <returns></returns>
public async Task<List<T>> GetListAsync(QueryCondition pars)
{
return await QueryConditionHandler(pars).ToListAsync();
}
/// <summary> /// <summary>
/// 仓储扩展方法:单表查询通用分页 /// 仓储扩展方法:单表查询通用分页
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<PageModel<List<T>>> CommonPage(QueryCondition pars) public async Task<PageModel<List<T>>> CommonPage(QueryPageCondition pars)
{ {
RefAsync<int> tolCount = 0; RefAsync<int> tolCount = 0;
var result = await QueryConditionHandler(new QueryCondition() {OrderBys=pars.OrderBys,Parameters=pars.Parameters } ).ToPageListAsync(pars.Index, pars.Size, tolCount);
return new PageModel<List<T>>
{
Total = tolCount.Value,
Data = result
};
}
private ISugarQueryable<T> QueryConditionHandler(QueryCondition pars)
{
var sugarParamters = pars.Parameters.Select(it => (IConditionalModel)new ConditionalModel() var sugarParamters = pars.Parameters.Select(it => (IConditionalModel)new ConditionalModel()
{ {
ConditionalType = it.ConditionalType, ConditionalType = it.Type,
FieldName = it.FieldName, FieldName = it.Key,
FieldValue = it.FieldValue FieldValue = it.Value
}).ToList(); }).ToList();
var query = Db.Queryable<T>(); var query = Db.Queryable<T>();
if (pars.OrderBys != null) if (pars.OrderBys != null)
@@ -67,14 +102,9 @@ namespace Yi.Framework.Repository
query.OrderBy(item.ToSqlFilter()); query.OrderBy(item.ToSqlFilter());
} }
} }
var result =await query.Where(sugarParamters).ToPageListAsync(pars.Index, pars.Size, tolCount); return query.Where(sugarParamters);
return new PageModel<List<T>>
{
Total = tolCount.Value,
Data = result
};
} }
} }

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 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 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) 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); userAction.Invoke(user);
if (user == null) if (user == null)
{ {
@@ -22,7 +22,7 @@ namespace Yi.Framework.Service
} }
public async Task<bool> Exist(string userName, Action<UserEntity> userAction = null) 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) if (userAction != null)
{ {
userAction.Invoke(user); userAction.Invoke(user);
@@ -55,7 +55,7 @@ namespace Yi.Framework.Service
user.UserName= userEntity.UserName; user.UserName= userEntity.UserName;
user.Salt = Common.Helper.MD5Helper.GenerateSalt(); user.Salt = Common.Helper.MD5Helper.GenerateSalt();
user.Password = Common.Helper.MD5Helper.SHA2Encode(userEntity.Password,user.Salt); user.Password = Common.Helper.MD5Helper.SHA2Encode(userEntity.Password,user.Salt);
userAction.Invoke(await InsertReturnEntityAsync(user)); userAction.Invoke(await _repository.InsertReturnEntityAsync(user));
return true; return true;
} }
return false; return false;

View File

@@ -37,6 +37,8 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
c.Datacenter = consulClientOption.Datacenter; c.Datacenter = consulClientOption.Datacenter;
})) }))
{ {
client.Agent.ServiceDeregister($"{consulRegisterOption.IP}-{consulRegisterOption.Port}-{Guid.NewGuid()}");
client.Agent.ServiceRegister(new AgentServiceRegistration() client.Agent.ServiceRegister(new AgentServiceRegistration()
{ {
ID = $"{consulRegisterOption.IP}-{consulRegisterOption.Port}-{Guid.NewGuid()}",//唯一Id ID = $"{consulRegisterOption.IP}-{consulRegisterOption.Port}-{Guid.NewGuid()}",//唯一Id

View File

@@ -8,6 +8,7 @@ using System.Text;
using Yi.Framework.Common.Const; using Yi.Framework.Common.Const;
using Yi.Framework.Common.Helper; using Yi.Framework.Common.Helper;
using Yi.Framework.Common.IOCOptions; using Yi.Framework.Common.IOCOptions;
using Yi.Framework.Core;
namespace Yi.Framework.WebCore.MiddlewareExtend namespace Yi.Framework.WebCore.MiddlewareExtend
{ {
@@ -19,7 +20,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
public static IServiceCollection AddJwtService(this IServiceCollection services) public static IServiceCollection AddJwtService(this IServiceCollection services)
{ {
services.Configure<JWTTokenOptions>(Appsettings.appConfiguration("JwtAuthorize")); services.Configure<JWTTokenOptions>(Appsettings.appConfiguration("JwtAuthorize"));
services.AddTransient<JwtInvoker>();
var jwtOptions = Appsettings.app<JWTTokenOptions>("JwtAuthorize"); var jwtOptions = Appsettings.app<JWTTokenOptions>("JwtAuthorize");
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options => .AddJwtBearer(options =>

View File

@@ -11,7 +11,10 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using Yi.Framework.Interface;
using Yi.Framework.Job; using Yi.Framework.Job;
using Yi.Framework.Repository;
using Yi.Framework.Service;
using Yi.Framework.WebCore.Utility; using Yi.Framework.WebCore.Utility;
using Module = Autofac.Module; using Module = Autofac.Module;
@@ -38,16 +41,16 @@ namespace Yi.Framework.WebCore.Utility
containerBuilder.RegisterType< HttpContextAccessor>().As<IHttpContextAccessor>().SingleInstance(); containerBuilder.RegisterType< HttpContextAccessor>().As<IHttpContextAccessor>().SingleInstance();
containerBuilder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>)).InstancePerLifetimeScope();
containerBuilder.RegisterGeneric(typeof(BaseService<>)).As(typeof(IBaseService<>)).InstancePerLifetimeScope();
///反射注入服务层及接口层 ///反射注入服务层及接口层
var assemblysServices = GetDll( "Yi.Framework.Service.dll"); var assemblysServices = GetDll( "Yi.Framework.Service.dll");
containerBuilder.RegisterAssemblyTypes(assemblysServices) containerBuilder.RegisterAssemblyTypes(assemblysServices)
.AsImplementedInterfaces() .AsImplementedInterfaces()
.InstancePerDependency() .InstancePerLifetimeScope()
.EnableInterfaceInterceptors(); .EnableInterfaceInterceptors();
///反射注册任务调度层 ///反射注册任务调度层
var assemblysJob = GetDll("Yi.Framework.Job.dll"); var assemblysJob = GetDll("Yi.Framework.Job.dll");
containerBuilder.RegisterAssemblyTypes(assemblysJob) containerBuilder.RegisterAssemblyTypes(assemblysJob)
.InstancePerDependency(); .InstancePerDependency();

View File

@@ -35,7 +35,10 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Yi.Framework.Core\Yi.Framework.Core.csproj" /> <ProjectReference Include="..\Yi.Framework.Core\Yi.Framework.Core.csproj" />
<ProjectReference Include="..\Yi.Framework.DTOModel\Yi.Framework.DTOModel.csproj" /> <ProjectReference Include="..\Yi.Framework.DTOModel\Yi.Framework.DTOModel.csproj" />
<ProjectReference Include="..\Yi.Framework.Interface\Yi.Framework.Interface.csproj" />
<ProjectReference Include="..\Yi.Framework.Model\Yi.Framework.Model.csproj" /> <ProjectReference Include="..\Yi.Framework.Model\Yi.Framework.Model.csproj" />
<ProjectReference Include="..\Yi.Framework.Repository\Yi.Framework.Repository.csproj" />
<ProjectReference Include="..\Yi.Framework.Service\Yi.Framework.Service.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>