角色查询优化

This commit is contained in:
不做码农 2021-10-11 22:03:54 +08:00
parent 4f9466828f
commit 97bc55a2e2
4 changed files with 29 additions and 11 deletions

View File

@ -38,11 +38,9 @@ namespace ZR.Admin.WebApi.Controllers.System
[HttpGet("list")] [HttpGet("list")]
public IActionResult List([FromQuery] SysRole role, [FromQuery] PagerInfo pager) public IActionResult List([FromQuery] SysRole role, [FromQuery] PagerInfo pager)
{ {
var list = sysRoleService.SelectRoleList(role); var list = sysRoleService.SelectRoleList(role, pager);
VMPageResult<SysRole> vMPageResult = new(list, pager); return SUCCESS(list, TIME_FORMAT_FULL);
return SUCCESS(vMPageResult, TIME_FORMAT_FULL);
} }
/// <summary> /// <summary>

View File

@ -1,6 +1,8 @@
using Infrastructure.Attribute; using Infrastructure.Attribute;
using Infrastructure.Model;
using SqlSugar; using SqlSugar;
using System.Collections.Generic; using System.Collections.Generic;
using ZR.Model;
using ZR.Model.System; using ZR.Model.System;
namespace ZR.Repository.System namespace ZR.Repository.System
@ -14,8 +16,22 @@ namespace ZR.Repository.System
/// <summary> /// <summary>
/// 根据条件分页查询角色数据 /// 根据条件分页查询角色数据
/// </summary> /// </summary>
/// <param name="sysRole"></param>
/// <returns></returns> /// <returns></returns>
public List<SysRole> SelectRoleList(SysRole sysRole) public List<SysRole> SelectRoleList()
{
return Context.Queryable<SysRole>()
.Where(role => role.DelFlag == "0")
.OrderBy(role => role.RoleSort)
.ToList();
}
/// <summary>
/// 根据条件分页查询角色数据
/// </summary>
/// <param name="sysRole"></param>
/// <param name="pager"></param>
/// <returns></returns>
public PagedInfo<SysRole> SelectRoleList(SysRole sysRole, PagerInfo pager)
{ {
return Context.Queryable<SysRole>() return Context.Queryable<SysRole>()
.Where(role => role.DelFlag == "0") .Where(role => role.DelFlag == "0")
@ -23,7 +39,7 @@ namespace ZR.Repository.System
.WhereIF(!string.IsNullOrEmpty(sysRole.Status), role => role.Status == sysRole.Status) .WhereIF(!string.IsNullOrEmpty(sysRole.Status), role => role.Status == sysRole.Status)
.WhereIF(!string.IsNullOrEmpty(sysRole.RoleKey), role => role.RoleKey == sysRole.RoleKey) .WhereIF(!string.IsNullOrEmpty(sysRole.RoleKey), role => role.RoleKey == sysRole.RoleKey)
.OrderBy(role => role.RoleSort) .OrderBy(role => role.RoleSort)
.ToList(); .ToPage(pager);
} }
/// <summary> /// <summary>

View File

@ -1,4 +1,5 @@
using System; using Infrastructure.Model;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -12,8 +13,9 @@ namespace ZR.Service.System.IService
/// 根据条件分页查询角色数据 /// 根据条件分页查询角色数据
/// </summary> /// </summary>
/// <param name="role">角色信息</param> /// <param name="role">角色信息</param>
/// <param name="pager"></param>
/// <returns>角色数据集合信息</returns> /// <returns>角色数据集合信息</returns>
public List<SysRole> SelectRoleList(SysRole role); public PagedInfo<SysRole> SelectRoleList(SysRole role, Model.PagerInfo pager);
/// <summary> /// <summary>
/// 查询所有角色 /// 查询所有角色

View File

@ -1,10 +1,12 @@
using Infrastructure; using Infrastructure;
using Infrastructure.Attribute; using Infrastructure.Attribute;
using Infrastructure.Model;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using ZR.Model;
using ZR.Model.System; using ZR.Model.System;
using ZR.Repository.System; using ZR.Repository.System;
using ZR.Service.System.IService; using ZR.Service.System.IService;
@ -33,9 +35,9 @@ namespace ZR.Service
/// </summary> /// </summary>
/// <param name="role">角色信息</param> /// <param name="role">角色信息</param>
/// <returns>角色数据集合信息</returns> /// <returns>角色数据集合信息</returns>
public List<SysRole> SelectRoleList(SysRole role) public PagedInfo<SysRole> SelectRoleList(SysRole role, PagerInfo pager)
{ {
return SysRoleRepository.SelectRoleList(role); return SysRoleRepository.SelectRoleList(role, pager);
} }
/// <summary> /// <summary>
@ -45,7 +47,7 @@ namespace ZR.Service
/// <returns></returns> /// <returns></returns>
public List<SysRole> SelectRoleAll() public List<SysRole> SelectRoleAll()
{ {
return SysRoleRepository.SelectRoleList(new SysRole()); return SysRoleRepository.SelectRoleList();
} }
/// <summary> /// <summary>