From 796bba1abec60e665c650c0caceb689fb65ee09e Mon Sep 17 00:00:00 2001 From: chenchun Date: Tue, 12 Apr 2022 18:09:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=93=E5=82=A8=E5=B1=82?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=96=87=E5=AF=B9=E8=B1=A1=E4=B8=8E=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=91=BD=E5=90=8D=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebFirst/database/sqlite.db | Bin 139264 -> 139264 bytes .../Config/SwaggerDoc.xml | 12 +++++++--- .../BaseController/BaseCrudController.cs | 6 ++--- .../Controllers/TestController.cs | 14 ++++++++++++ .../Controllers/UserController.cs | 2 ++ .../Yi.Framework.Interface/IUserService.cs | 21 ++++++++++++++++++ .../Yi.Framework.Repository/IRepository.cs | 1 + .../Yi.Framework.Repository/Repository.cs | 3 ++- .../Yi.Framework.Service/UserService.cs | 5 +++++ 9 files changed, 57 insertions(+), 7 deletions(-) diff --git a/WebFirst/database/sqlite.db b/WebFirst/database/sqlite.db index 12daf48c1b0da0953074569248f14d51c3c5886e..485a0f63d980343f0becfae4192d23443e6dc96f 100644 GIT binary patch delta 231 zcmZoTz|nAkV}i7x0|Ntt5)i{c!bBZoRtE+>oq&xg3-ejIXEAWknm93eb8dkyH)lsO zGdF`b;{@kPtqzmLi_It79u?iZzb1rfvQJ6gWQ+QFlLI@`>OY<8VDHxhtnVMM{8|s;vn{H}g-N4QLfq}P?Zx#0ko(r2D1sb`wPqbo;XS8gL zWfoxIZ}erT&l&PdHm&M3``aY-%CF3B&5iOke3F3c$| YO;0SEe#VYbVS0@XBmedY8^#rn0Y&0RH2?qr delta 250 zcmZoTz|nAkV}i7xH3I{K5)i{c+(aE?R%-@5_Z1sc7Ur|^Xfg0;O`Mp#Ik!NUd-9fg zaaBF%{M_99ynw{?RE@#{9fblQ!!s`>wF1Hn&a6t+QJB23Du}z5w>_Ado57p0PkB+3=B3kux{YyVQ1iN - 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);