From 0fb57a0a2c1ce35ee9d5e5167a0d54e55ab8a0cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Fri, 9 Sep 2022 19:34:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E7=B1=BB=E5=9E=8B=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DictionaryController.cs | 7 +++++ .../IDictionaryService.cs | 19 ++++++++++++ .../Yi.Framework.Interface/IRoleService.cs | 7 +++++ .../Yi.Framework.Repository/IRepository.cs | 1 + .../Yi.Framework.Repository/Repository.cs | 2 ++ .../Yi.Framework.Service/DictionaryService.cs | 29 +++++++++++++++++++ Yi.Vue3.X.RuoYi/src/api/system/dict/type.js | 2 +- 7 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 Yi.Framework.Net6/Yi.Framework.Interface/IDictionaryService.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.Service/DictionaryService.cs diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/DictionaryController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/DictionaryController.cs index ade553f0..a615870c 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/DictionaryController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/DictionaryController.cs @@ -25,6 +25,13 @@ namespace Yi.Framework.ApiMicroservice.Controllers _iDictionaryService = iDictionaryService; } + + [HttpGet] + public async Task PageList([FromQuery] DictionaryEntity dic, [FromQuery] PageParModel page) + { + return Result.Success().SetData(await _iDictionaryService.SelctPageList(dic, page)); + } + [HttpGet] [Route("{type}")] public async Task GetListByType([FromRoute] string type) diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IDictionaryService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IDictionaryService.cs new file mode 100644 index 00000000..368bd3e6 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IDictionaryService.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; +using Yi.Framework.Model.Models; +using Yi.Framework.Repository; + +namespace Yi.Framework.Interface +{ + public partial interface IDictionaryService:IBaseService + { + /// + /// 动态条件分页查询 + /// + /// + /// + /// + Task>> SelctPageList(DictionaryEntity dic, PageParModel page); + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs index 5350f42b..a59666b3 100644 --- a/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs @@ -28,6 +28,13 @@ namespace Yi.Framework.Interface /// /// Task GiveRoleSetMenu(List roleIds, List menuIds); + + /// + /// 动态条件分页查询 + /// + /// + /// + /// Task>> SelctPageList(RoleEntity role, PageParModel page); } } diff --git a/Yi.Framework.Net6/Yi.Framework.Repository/IRepository.cs b/Yi.Framework.Net6/Yi.Framework.Repository/IRepository.cs index c08d4eee..ec1d28a6 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 : class, IBaseModelEntity, new() { + public ISugarQueryable _DbQueryable { get; set; } public ISqlSugarClient _Db { get; set; } public Task UseTranAsync(Func func); public Task InsertReturnEntityAsync(T entity); diff --git a/Yi.Framework.Net6/Yi.Framework.Repository/Repository.cs b/Yi.Framework.Net6/Yi.Framework.Repository/Repository.cs index 4ac255a6..dcd810b8 100644 --- a/Yi.Framework.Net6/Yi.Framework.Repository/Repository.cs +++ b/Yi.Framework.Net6/Yi.Framework.Repository/Repository.cs @@ -14,6 +14,8 @@ namespace Yi.Framework.Repository /// public class Repository : SimpleClient, IRepository where T : class, IBaseModelEntity, new() { + public ISugarQueryable _DbQueryable { get { return base.Context.Queryable(); } set { } } + public ISqlSugarClient _Db { get { return base.Context; } set { } } /// /// 构造函数 diff --git a/Yi.Framework.Net6/Yi.Framework.Service/DictionaryService.cs b/Yi.Framework.Net6/Yi.Framework.Service/DictionaryService.cs new file mode 100644 index 00000000..44286993 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/DictionaryService.cs @@ -0,0 +1,29 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; +using Yi.Framework.Repository; + +namespace Yi.Framework.Service +{ + public partial class DictionaryService : BaseService, IDictionaryService + { + public async Task>> SelctPageList(DictionaryEntity dic, PageParModel page) + { + RefAsync total = 0; + var data = await _repository._DbQueryable + .WhereIF(!string.IsNullOrEmpty(dic.DicName), u => u.DicName.Contains(dic.DicName)) + .WhereIF(!string.IsNullOrEmpty(dic.DictType), u => u.DictType.Contains(dic.DictType)) + .WhereIF(page.StartTime.IsNotNull() && page.EndTime.IsNotNull(), u => u.CreateTime >= page.StartTime && u.CreateTime <= page.EndTime) + .Where(u => u.IsDeleted == false) + .OrderBy(u => u.OrderNum, OrderByType.Desc) + .ToPageListAsync(page.PageNum, page.PageSize, total); + + return new PageModel>(data, total); + } + + } +} diff --git a/Yi.Vue3.X.RuoYi/src/api/system/dict/type.js b/Yi.Vue3.X.RuoYi/src/api/system/dict/type.js index a0254baa..29f87c81 100644 --- a/Yi.Vue3.X.RuoYi/src/api/system/dict/type.js +++ b/Yi.Vue3.X.RuoYi/src/api/system/dict/type.js @@ -3,7 +3,7 @@ import request from '@/utils/request' // 查询字典类型列表 export function listType(query) { return request({ - url: '/system/dict/type/list', + url: '/dictionary/pageList', method: 'get', params: query })