diff --git a/WebFirst/database/sqlite.db b/WebFirst/database/sqlite.db index 12daf48c..485a0f63 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 1eb4c3c8..ba2472e8 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml @@ -6,11 +6,11 @@ - 6666 + Json To Sql 类比模式,通用模型 - + 主键查询 @@ -23,7 +23,7 @@ - + 条件分页查询 @@ -51,6 +51,12 @@ + + + 仓储上下文对象测试 + + + 国际化测试 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 ccfa601f..69bf1deb 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BaseController/BaseCrudController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BaseController/BaseCrudController.cs @@ -11,7 +11,7 @@ using Yi.Framework.WebCore.AttributeExtend; namespace Yi.Framework.ApiMicroservice.Controllers { /// - /// 6666 + /// Json To Sql 类比模式,通用模型 /// /// [ApiController] @@ -35,7 +35,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// [Permission($"{nameof(T)}:get:one")] [HttpGet] - public async Task Get(long id) + public async Task GetById(long id) { return Result.Success().SetData(await _repository.GetByIdAsync(id)); } @@ -58,7 +58,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// [Permission($"{nameof(T)}:get:page")] [HttpPost] - public async Task Page(QueryPageCondition queryCondition) + public async Task PageList(QueryPageCondition queryCondition) { return Result.Success().SetData(await _repository.CommonPageAsync(queryCondition)); } diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs index 1443b95c..a1fb5093 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs @@ -22,10 +22,24 @@ namespace Yi.Framework.ApiMicroservice.Controllers public class TestController : ControllerBase { private IStringLocalizer _local; + private IUserService _iUserService; public TestController(ILogger logger, IUserService iUserService, IStringLocalizer local) { _local = local; + _iUserService = iUserService; } + + /// + /// 仓储上下文对象测试 + /// + /// + [HttpGet] + /// 特点:仓储代理上下文对象,用起来就是爽 + public async Task DbTest() + { + return Result.Success().SetData(await _iUserService.DbTest()); + } + /// /// 国际化测试 /// diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs index 930ed80e..4b8631f4 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs @@ -19,8 +19,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers [Route("api/[controller]/[action]")] public class UserController : BaseCrudController { + private IUserService _iUserService; public UserController(ILogger logger, IUserService iUserService) : base(logger, iUserService) { + _iUserService = iUserService; } } } diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs index 65fa2a3e..6504f5be 100644 --- a/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using Yi.Framework.Model.Models; using Yi.Framework.Repository; @@ -7,7 +8,27 @@ namespace Yi.Framework.Interface { public partial interface IUserService { + /// + /// 测试仓储的上下文对象 + /// + /// + public Task> DbTest(); + + /// + /// 登录方法 + /// + /// + /// + /// + /// public Task Login(string userName, string password, Action userAction = null); + + /// + /// 注册方法 + /// + /// + /// + /// public Task Register(UserEntity userEntity, Action userAction = null); } } diff --git a/Yi.Framework.Net6/Yi.Framework.Repository/IRepository.cs b/Yi.Framework.Net6/Yi.Framework.Repository/IRepository.cs index a83d7b45..1bca4848 100644 --- a/Yi.Framework.Net6/Yi.Framework.Repository/IRepository.cs +++ b/Yi.Framework.Net6/Yi.Framework.Repository/IRepository.cs @@ -13,6 +13,7 @@ namespace Yi.Framework.Repository { public interface IRepository : ISimpleClient where T : BaseModelEntity,new() { + public ISqlSugarClient _Db { get; set; } public Task InsertReturnEntityAsync(T entity); public Task> StoreAsync(string storeName, object para); public Task>> CommonPageAsync(QueryPageCondition pars); diff --git a/Yi.Framework.Net6/Yi.Framework.Repository/Repository.cs b/Yi.Framework.Net6/Yi.Framework.Repository/Repository.cs index ce23c8b7..46efea88 100644 --- a/Yi.Framework.Net6/Yi.Framework.Repository/Repository.cs +++ b/Yi.Framework.Net6/Yi.Framework.Repository/Repository.cs @@ -14,13 +14,14 @@ namespace Yi.Framework.Repository /// public class Repository : DataContext, IRepository where T : BaseModelEntity,new() { - + public ISqlSugarClient _Db { get; set; } /// /// 构造函数 /// /// public Repository(ISqlSugarClient context) : base(context)//注意这里要有默认值等于null { + _Db = context; } diff --git a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs index 63ddc22e..8124274a 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs @@ -1,5 +1,6 @@ using SqlSugar; using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Yi.Framework.Interface; @@ -10,6 +11,10 @@ namespace Yi.Framework.Service { public partial class UserService { + public async Task> DbTest() + { + return await _repository._Db.Queryable().ToListAsync(); + } public async Task Exist(Guid id, Action userAction = null) { var user = await _repository.GetByIdAsync(id);