diff --git a/WebFirst/database/sqlite.db b/WebFirst/database/sqlite.db
index ee5ce8b1..6d4d8bbf 100644
Binary files a/WebFirst/database/sqlite.db and b/WebFirst/database/sqlite.db differ
diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml
index 47b9deab..dce031be 100644
--- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml
+++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml
@@ -10,13 +10,6 @@
-
-
- jb
-
-
-
-
主键查询
@@ -24,13 +17,13 @@
-
+
列表查询
-
+
条件分页查询
@@ -51,7 +44,7 @@
-
+
列表删除
diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs
index e05677f1..365c5339 100644
--- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs
+++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs
@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
+using Yi.Framework.Core;
using Yi.Framework.DTOModel;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
@@ -21,9 +22,11 @@ namespace Yi.Framework.ApiMicroservice.Controllers
public class AccountController :ControllerBase
{
private IUserService _iUserService;
- public AccountController(ILogger logger, IUserService iUserService)
+ private JwtInvoker _jwtInvoker;
+ public AccountController(ILogger logger, IUserService iUserService, JwtInvoker jwtInvoker)
{
_iUserService = iUserService;
+ _jwtInvoker = jwtInvoker;
}
[AllowAnonymous]
@@ -32,8 +35,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers
{
UserEntity user=new();
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("登录失败!用户名或者密码错误!");
}
diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BaseController/BaseCrudController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BaseController/BaseCrudController.cs
index 1fcfb87c..d48ebbdf 100644
--- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BaseController/BaseCrudController.cs
+++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BaseController/BaseCrudController.cs
@@ -1,5 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using Yi.Framework.Common.Models;
+using Yi.Framework.Interface;
+using Yi.Framework.Model.Models;
using Yi.Framework.Model.Query;
using Yi.Framework.Repository;
using Yi.Framework.WebCore.AttributeExtend;
@@ -12,19 +14,17 @@ namespace Yi.Framework.ApiMicroservice.Controllers
///
[ApiController]
[Route("api/[controller]/[action]")]
- public class BaseCrudController : ControllerBase where T : class,new()
+ public class BaseCrudController : ControllerBase where T : BaseModelEntity,new()
{
- private readonly ILogger _logger;
- public IRepository _iRepository;
- ///
- /// jb
- ///
- ///
- ///
- public BaseCrudController(ILogger logger, IRepository iRepository)
+ public readonly ILogger _logger;
+ public IBaseService _baseService;
+ public IRepository _repository;
+
+ public BaseCrudController(ILogger logger, IBaseService iBaseService)
{
_logger = logger;
- _iRepository = iRepository;
+ _baseService = iBaseService;
+ _repository = iBaseService._repository;
}
///
@@ -36,7 +36,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
[HttpGet]
public async Task Get(object id)
{
- return Result.Success().SetData(await _iRepository.GetByIdAsync(id));
+ return Result.Success().SetData(await _repository.GetByIdAsync(id));
}
///
@@ -44,10 +44,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
///
///
[Permission($"{nameof(T)}:get:list")]
- [HttpGet]
- public async Task GetList()
+ [HttpPost]
+ public async Task GetList(QueryCondition queryCondition)
{
- return Result.Success().SetData(await _iRepository.GetListAsync());
+ return Result.Success().SetData(await _repository.GetListAsync(queryCondition));
}
///
@@ -57,9 +57,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers
///
[Permission($"{nameof(T)}:get:page")]
[HttpPost]
- public async Task Page(QueryCondition queryCondition)
+ public async Task Page(QueryPageCondition queryCondition)
{
- return Result.Success().SetData(await _iRepository.CommonPage(queryCondition));
+ return Result.Success().SetData(await _repository.CommonPage(queryCondition));
}
///
@@ -71,7 +71,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
[HttpPost]
public async Task Add(T entity)
{
- return Result.Success().SetData(await _iRepository.InsertReturnEntityAsync(entity));
+ return Result.Success().SetData(await _repository.InsertReturnEntityAsync(entity));
}
///
@@ -83,7 +83,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
[HttpPut]
public async Task Update(T entity)
{
- return Result.Success().SetStatus(await _iRepository.UpdateAsync(entity));
+ return Result.Success().SetStatus(await _repository.UpdateAsync(entity));
}
///
@@ -93,9 +93,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers
///
[Permission($"{nameof(T)}:delete:list")]
[HttpDelete]
- public async Task DeleteList(object[] ids)
+ public async Task DeleteList(List ids)
{
- return Result.Success().SetStatus(await _iRepository.DeleteByIdsAsync(ids));
+ return Result.Success().SetStatus(await _repository.DeleteByLogic(ids));
}
}
}
diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs
index e84864cb..3a2c3c7f 100644
--- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs
+++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs
@@ -127,7 +127,7 @@ ServiceLocator.Instance = app.Services;
#region
//ץȡע
#endregion
-app.UseErrorHandlingService();
+//app.UseErrorHandlingService();
#region
//̬ļע
#endregion
diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.json b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.json
index c7ae2d34..24a90649 100644
--- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.json
+++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.json
@@ -38,10 +38,14 @@
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]"
]
},
- "JWTTokenOptions": {
- "Audience": "http://localhost:7000",
- "Issuer": "http://localhost:7000",
- "SecurityKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB"
+ "JwtAuthorize": {
+ "Issuer": "cc",
+ "Audience": "cc",
+ "PolicyName": "permission",
+ "DefaultScheme": "Bearer",
+ "IsHttps": false,
+ "Expiration": 30,
+ "ReExpiration": 3000
},
"RedisConnOptions": {
"Host": "[xxxx]",
diff --git a/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/JWTTokenOptions.cs b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/JWTTokenOptions.cs
index 8c4601c4..5f4388b8 100644
--- a/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/JWTTokenOptions.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/JWTTokenOptions.cs
@@ -11,8 +11,6 @@ namespace Yi.Framework.Common.IOCOptions
public string Issuer { get; set; }
- public string SecurityKey { get; set; }
-
public string DefaultScheme { get; set; }
public int Expiration { get; set; }
diff --git a/Yi.Framework.Net6/Yi.Framework.Core/Yi.Framework.Core.csproj b/Yi.Framework.Net6/Yi.Framework.Core/Yi.Framework.Core.csproj
index c8f401f9..fc9dce43 100644
--- a/Yi.Framework.Net6/Yi.Framework.Core/Yi.Framework.Core.csproj
+++ b/Yi.Framework.Net6/Yi.Framework.Core/Yi.Framework.Core.csproj
@@ -23,22 +23,4 @@
-
-
- Library\Microsoft.Bcl.AsyncInterfaces.dll
-
-
- Library\ServiceStack.Common.dll
-
-
- Library\ServiceStack.Interfaces.dll
-
-
- Library\ServiceStack.Redis.dll
-
-
- Library\ServiceStack.Text.dll
-
-
-
diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IBaseService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IBaseService.cs
new file mode 100644
index 00000000..3f26d296
--- /dev/null
+++ b/Yi.Framework.Net6/Yi.Framework.Interface/IBaseService.cs
@@ -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 where T:BaseModelEntity,new()
+ {
+ public IRepository _repository { get; set; }
+ }
+}
diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/ITenantService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/ITenantService.cs
index d0e94463..31f8a4a9 100644
--- a/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/ITenantService.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/ITenantService.cs
@@ -3,7 +3,7 @@ using Yi.Framework.Repository;
namespace Yi.Framework.Interface
{
- public partial interface ITenantService: IRepository
+ public partial interface ITenantService:IBaseService
{
}
}
diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/IUserService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/IUserService.cs
index 2d1b9210..9d12e09a 100644
--- a/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/IUserService.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/IUserService.cs
@@ -3,7 +3,7 @@ using Yi.Framework.Repository;
namespace Yi.Framework.Interface
{
- public partial interface IUserService: IRepository
+ public partial interface IUserService:IBaseService
{
}
}
diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Models/BaseModel/BaseModelEntity.cs b/Yi.Framework.Net6/Yi.Framework.Model/Models/BaseModel/BaseModelEntity.cs
index f2eb7432..eb7b55db 100644
--- a/Yi.Framework.Net6/Yi.Framework.Model/Models/BaseModel/BaseModelEntity.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Model/Models/BaseModel/BaseModelEntity.cs
@@ -41,16 +41,6 @@ namespace Yi.Framework.Model.Models
[SugarColumn(ColumnName = "ModifyTime")]
public DateTime? ModifyTime { get; set; }
///
- /// 删除者
- ///
- [SugarColumn(ColumnName = "DeleteUser")]
- public Guid? DeleteUser { get; set; }
- ///
- /// 删除时间
- ///
- [SugarColumn(ColumnName = "DeleteTime")]
- public DateTime? DeleteTime { get; set; }
- ///
/// 是否删除
///
[SugarColumn(ColumnName = "IsDeleted")]
diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Models/TenantEntity.cs b/Yi.Framework.Net6/Yi.Framework.Model/Models/TenantEntity.cs
index 820d901d..8da9ff39 100644
--- a/Yi.Framework.Net6/Yi.Framework.Model/Models/TenantEntity.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Model/Models/TenantEntity.cs
@@ -8,38 +8,12 @@ namespace Yi.Framework.Model.Models
/// 租户表
///
[SugarTable("Tenant")]
- public partial class TenantEntity
+ public partial class TenantEntity:BaseModelEntity
{
- public TenantEntity()
- {
- this.Id=Guid.NewGuid();
- this.IsDeleted=false;
- this.CreateTime = DateTime.Now;
- }
///
- /// 1
+ /// 租户名
///
- [SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
- public Guid Id { get; set; }
- ///
- /// 创建者
- ///
- [SugarColumn(ColumnName="CreateUser" )]
- public Guid? CreateUser { get; set; }
- ///
- /// 创建时间
- ///
- [SugarColumn(ColumnName="CreateTime" )]
- public DateTime? CreateTime { get; set; }
- ///
- /// 修改时间
- ///
- [SugarColumn(ColumnName="ModifyTime" )]
- public DateTime? ModifyTime { get; set; }
- ///
- /// 是否删除
- ///
- [SugarColumn(ColumnName="IsDeleted" )]
- public bool? IsDeleted { get; set; }
+ [SugarColumn(ColumnName="TenantName" )]
+ public string TenantName { get; set; }
}
}
diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Models/UserEntity.cs b/Yi.Framework.Net6/Yi.Framework.Model/Models/UserEntity.cs
index 80b3bd81..f79d8aea 100644
--- a/Yi.Framework.Net6/Yi.Framework.Model/Models/UserEntity.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Model/Models/UserEntity.cs
@@ -11,11 +11,6 @@ namespace Yi.Framework.Model.Models
public partial class UserEntity:BaseModelEntity
{
///
- /// 1
- ///
- [SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
- public Guid Id { get; set; }
- ///
/// 姓名
///
[SugarColumn(ColumnName="Name" )]
@@ -26,31 +21,6 @@ namespace Yi.Framework.Model.Models
[SugarColumn(ColumnName="Age" )]
public int? Age { get; set; }
///
- /// 创建者
- ///
- [SugarColumn(ColumnName="CreateUser" )]
- public Guid? CreateUser { get; set; }
- ///
- /// 创建时间
- ///
- [SugarColumn(ColumnName="CreateTime" )]
- public DateTime? CreateTime { get; set; }
- ///
- /// 修改者
- ///
- [SugarColumn(ColumnName="ModifyUser" )]
- public Guid? ModifyUser { get; set; }
- ///
- /// 修改时间
- ///
- [SugarColumn(ColumnName="ModifyTime" )]
- public DateTime? ModifyTime { get; set; }
- ///
- /// 是否删除
- ///
- [SugarColumn(ColumnName="IsDeleted" )]
- public bool? IsDeleted { get; set; }
- ///
/// 租户Id
///
[SugarColumn(ColumnName="TenantId" )]
diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Query/QueryCondition.cs b/Yi.Framework.Net6/Yi.Framework.Model/Query/QueryCondition.cs
index e3875eac..08c6a33d 100644
--- a/Yi.Framework.Net6/Yi.Framework.Model/Query/QueryCondition.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Model/Query/QueryCondition.cs
@@ -6,11 +6,18 @@ using System.Threading.Tasks;
namespace Yi.Framework.Model.Query
{
- public class QueryCondition
+ public class QueryPageCondition
{
public int Index { get; set; }
public int Size { get; set; }
- public int Count { get; set; }
+
+ public List Parameters { get; set; } = new List();
+ public List OrderBys { get; set; } = new List();
+
+ }
+
+ public class QueryCondition
+ {
public List Parameters { get; set; } = new List();
public List OrderBys { get; set; } = new List();
diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Query/QueryParameter.cs b/Yi.Framework.Net6/Yi.Framework.Model/Query/QueryParameter.cs
index e46520c1..330902c4 100644
--- a/Yi.Framework.Net6/Yi.Framework.Model/Query/QueryParameter.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Model/Query/QueryParameter.cs
@@ -1,16 +1,19 @@
-using SqlSugar;
+using Newtonsoft.Json.Converters;
+using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Yi.Framework.Model.Query
{
public class QueryParameter
{
- public string FieldName { get; set; }
- public string FieldValue { get; set; }
- public ConditionalType ConditionalType { get; set; } = ConditionalType.Like;
+ public string Key { get; set; }
+ public string Value { get; set; }
+ [JsonConverter(typeof(StringEnumConverter))]
+ public ConditionalType Type { get; set; } = ConditionalType.Like;
}
}
diff --git a/Yi.Framework.Net6/Yi.Framework.Repository/IRepository.cs b/Yi.Framework.Net6/Yi.Framework.Repository/IRepository.cs
index c7eeabac..273954e9 100644
--- a/Yi.Framework.Net6/Yi.Framework.Repository/IRepository.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Repository/IRepository.cs
@@ -15,6 +15,8 @@ namespace Yi.Framework.Repository
{
public Task InsertReturnEntityAsync(T entity);
public Task> StoreAsync(string storeName, object para);
- public Task>> CommonPage(QueryCondition pars);
+ public Task>> CommonPage(QueryPageCondition pars);
+ public Task> GetListAsync(QueryCondition pars);
+ public Task DeleteByLogic(List ids);
}
}
diff --git a/Yi.Framework.Net6/Yi.Framework.Repository/Repository.cs b/Yi.Framework.Net6/Yi.Framework.Repository/Repository.cs
index 93c4da66..b9846506 100644
--- a/Yi.Framework.Net6/Yi.Framework.Repository/Repository.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Repository/Repository.cs
@@ -34,6 +34,18 @@ namespace Yi.Framework.Repository
return await Db.Insertable(entity).ExecuteReturnEntityAsync();
}
+ ///
+ /// 逻辑多删除
+ ///
+ ///
+ public async Task DeleteByLogic(List ids)
+ {
+ var entitys = await Db.Queryable().Where(u => ids.Contains(u.Id)).ToListAsync();
+ entitys.ForEach(u=>u.IsDeleted=true);
+ return await Db.Updateable(entitys).ExecuteCommandAsync()>0;
+ }
+
+
///
/// 调用存储过程
///
@@ -46,18 +58,41 @@ namespace Yi.Framework.Repository
return await Db.Ado.UseStoredProcedure().SqlQueryAsync(storeName, para);
}
+
+ ///
+ /// 多条件查询
+ ///
+ ///
+ ///
+ public async Task> GetListAsync(QueryCondition pars)
+ {
+ return await QueryConditionHandler(pars).ToListAsync();
+ }
+
///
/// 仓储扩展方法:单表查询通用分页
///
///
- public async Task>> CommonPage(QueryCondition pars)
+ public async Task>> CommonPage(QueryPageCondition pars)
{
RefAsync tolCount = 0;
+ var result = await QueryConditionHandler(new QueryCondition() {OrderBys=pars.OrderBys,Parameters=pars.Parameters } ).ToPageListAsync(pars.Index, pars.Size, tolCount);
+ return new PageModel>
+ {
+ Total = tolCount.Value,
+ Data = result
+ };
+ }
+
+
+
+ private ISugarQueryable QueryConditionHandler(QueryCondition pars)
+ {
var sugarParamters = pars.Parameters.Select(it => (IConditionalModel)new ConditionalModel()
{
- ConditionalType = it.ConditionalType,
- FieldName = it.FieldName,
- FieldValue = it.FieldValue
+ ConditionalType = it.Type,
+ FieldName = it.Key,
+ FieldValue = it.Value
}).ToList();
var query = Db.Queryable();
if (pars.OrderBys != null)
@@ -67,14 +102,9 @@ namespace Yi.Framework.Repository
query.OrderBy(item.ToSqlFilter());
}
}
- var result =await query.Where(sugarParamters).ToPageListAsync(pars.Index, pars.Size, tolCount);
-
- return new PageModel>
- {
- Total = tolCount.Value,
- Data = result
- };
+ return query.Where(sugarParamters);
}
+
}
diff --git a/Yi.Framework.Net6/Yi.Framework.Service/BaseService.cs b/Yi.Framework.Net6/Yi.Framework.Service/BaseService.cs
new file mode 100644
index 00000000..43fff21c
--- /dev/null
+++ b/Yi.Framework.Net6/Yi.Framework.Service/BaseService.cs
@@ -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:IBaseService where T:BaseModelEntity,new()
+ {
+ public IRepository _repository { get; set; }
+ public BaseService(IRepository iRepository)
+ {
+ _repository = iRepository;
+ }
+ }
+}
diff --git a/Yi.Framework.Net6/Yi.Framework.Service/ServiceTemplate/TenantService.cs b/Yi.Framework.Net6/Yi.Framework.Service/ServiceTemplate/TenantService.cs
index b401891e..6093f532 100644
--- a/Yi.Framework.Net6/Yi.Framework.Service/ServiceTemplate/TenantService.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Service/ServiceTemplate/TenantService.cs
@@ -5,9 +5,9 @@ using Yi.Framework.Repository;
namespace Yi.Framework.Service
{
- public partial class TenantService : Repository, ITenantService
+ public partial class TenantService : BaseService, ITenantService
{
- public TenantService(ISqlSugarClient context) : base(context)
+ public TenantService(IRepository repository) : base(repository)
{
}
}
diff --git a/Yi.Framework.Net6/Yi.Framework.Service/ServiceTemplate/UserService.cs b/Yi.Framework.Net6/Yi.Framework.Service/ServiceTemplate/UserService.cs
index a44353d3..964a76dd 100644
--- a/Yi.Framework.Net6/Yi.Framework.Service/ServiceTemplate/UserService.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Service/ServiceTemplate/UserService.cs
@@ -5,9 +5,9 @@ using Yi.Framework.Repository;
namespace Yi.Framework.Service
{
- public partial class UserService : Repository, IUserService
+ public partial class UserService : BaseService, IUserService
{
- public UserService(ISqlSugarClient context) : base(context)
+ public UserService(IRepository repository) : base(repository)
{
}
}
diff --git a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs
index 54bd1352..35a22f68 100644
--- a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs
@@ -12,7 +12,7 @@ namespace Yi.Framework.Service
{
public async Task Exist(Guid id, Action 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 Exist(string userName, Action 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;
diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ConsulRegiterExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ConsulRegiterExtend.cs
index 7c8ab310..9eeca35e 100644
--- a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ConsulRegiterExtend.cs
+++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ConsulRegiterExtend.cs
@@ -37,6 +37,8 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
c.Datacenter = consulClientOption.Datacenter;
}))
{
+
+ client.Agent.ServiceDeregister($"{consulRegisterOption.IP}-{consulRegisterOption.Port}-{Guid.NewGuid()}");
client.Agent.ServiceRegister(new AgentServiceRegistration()
{
ID = $"{consulRegisterOption.IP}-{consulRegisterOption.Port}-{Guid.NewGuid()}",//唯一Id
diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/JwtExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/JwtExtension.cs
index 08e2fb92..a09163d1 100644
--- a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/JwtExtension.cs
+++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/JwtExtension.cs
@@ -8,6 +8,7 @@ using System.Text;
using Yi.Framework.Common.Const;
using Yi.Framework.Common.Helper;
using Yi.Framework.Common.IOCOptions;
+using Yi.Framework.Core;
namespace Yi.Framework.WebCore.MiddlewareExtend
{
@@ -19,7 +20,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
public static IServiceCollection AddJwtService(this IServiceCollection services)
{
services.Configure(Appsettings.appConfiguration("JwtAuthorize"));
-
+ services.AddTransient();
var jwtOptions = Appsettings.app("JwtAuthorize");
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/Utility/CustomAutofacModule.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/Utility/CustomAutofacModule.cs
index 26777668..e83a0a99 100644
--- a/Yi.Framework.Net6/Yi.Framework.WebCore/Utility/CustomAutofacModule.cs
+++ b/Yi.Framework.Net6/Yi.Framework.WebCore/Utility/CustomAutofacModule.cs
@@ -11,7 +11,10 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
+using Yi.Framework.Interface;
using Yi.Framework.Job;
+using Yi.Framework.Repository;
+using Yi.Framework.Service;
using Yi.Framework.WebCore.Utility;
using Module = Autofac.Module;
@@ -38,16 +41,16 @@ namespace Yi.Framework.WebCore.Utility
containerBuilder.RegisterType< HttpContextAccessor>().As().SingleInstance();
-
-
+ containerBuilder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>)).InstancePerLifetimeScope();
+ containerBuilder.RegisterGeneric(typeof(BaseService<>)).As(typeof(IBaseService<>)).InstancePerLifetimeScope();
///反射注入服务层及接口层
var assemblysServices = GetDll( "Yi.Framework.Service.dll");
containerBuilder.RegisterAssemblyTypes(assemblysServices)
.AsImplementedInterfaces()
- .InstancePerDependency()
+ .InstancePerLifetimeScope()
.EnableInterfaceInterceptors();
-///反射注册任务调度层
+ ///反射注册任务调度层
var assemblysJob = GetDll("Yi.Framework.Job.dll");
containerBuilder.RegisterAssemblyTypes(assemblysJob)
.InstancePerDependency();
diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj b/Yi.Framework.Net6/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj
index bc373a9f..27308c25 100644
--- a/Yi.Framework.Net6/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj
+++ b/Yi.Framework.Net6/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj
@@ -35,7 +35,10 @@
+
+
+