feat: 完成查询动态条件筛选,做一个快乐的crud boy

This commit is contained in:
橙子
2023-02-19 17:18:52 +08:00
parent 0566606bfb
commit 1f33204697
9 changed files with 76 additions and 41 deletions

View File

@@ -10,21 +10,9 @@ namespace Yi.RBAC.Application.Contracts.Identity.Dtos
{
public class MenuGetListInputVo : PagedAndSortedResultRequestDto
{
public long Id { get; set; }
public DateTime CreationTime { get; set; } = DateTime.Now;
public long? CreatorId { get; set; }
public bool State { get; set; }
public string MenuName { get; set; } = string.Empty;
public MenuTypeEnum MenuType { get; set; } = MenuTypeEnum.Menu;
public string? PermissionCode { get; set; }
public long ParentId { get; set; }
public string? MenuIcon { get; set; }
public string? Router { get; set; }
public bool IsLink { get; set; }
public bool IsCache { get; set; }
public bool IsShow { get; set; } = true;
public string? Remark { get; set; }
public string? Component { get; set; }
public string? Query { get; set; }
public bool? State { get; set; }
public string? MenuName { get; set; }
}
}

View File

@@ -9,12 +9,8 @@ namespace Yi.RBAC.Application.Contracts.Identity.Dtos
{
public class PostGetListInputVo : PagedAndSortedResultRequestDto
{
public long Id { get; set; }
public DateTime CreationTime { get; set; } = DateTime.Now;
public long? CreatorId { get; set; }
public bool State { get; set; }
public string PostCode { get; set; }=string.Empty;
public string PostName { get; set; } = string.Empty;
public string? Remark { get; set; }
public bool? State { get; set; }
//public string? PostCode { get; set; }=string.Empty;
public string? PostName { get; set; } = string.Empty;
}
}

View File

@@ -8,15 +8,11 @@ using Yi.RBAC.Domain.Shared.Identity.EnumClasses;
namespace Yi.RBAC.Application.Contracts.Identity.Dtos
{
public class RoleGetListInputVo : PagedAndSortedResultRequestDto
public class RoleGetListInputVo : PagedAllResultRequestDto
{
public long Id { get; set; }
public DateTime CreationTime { get; set; } = DateTime.Now;
public long? CreatorId { get; set; }
public string? RoleName { get; set; }
public string? RoleCode { get; set; }
public string? Remark { get; set; }
public DataScopeEnum DataScope { get; set; } = DataScopeEnum.ALL;
public bool State { get; set; }
public bool? State { get; set; }
}
}

View File

@@ -7,15 +7,10 @@ using Yi.Framework.Ddd.Dtos;
namespace Yi.RBAC.Application.Contracts.Setting.Dtos
{
public class ConfigGetListInputVo : PagedAndSortedResultRequestDto
public class ConfigGetListInputVo : PagedAllResultRequestDto
{
public long Id { get; set; }
public string ConfigName { get; set; } = string.Empty;
public string ConfigKey { get; set; } = string.Empty;
public string ConfigValue { get; set; } = string.Empty;
public string? ConfigType { get; set; }
public int OrderNum { get; set; }
public string? Remark { get; set; }
public string? ConfigName { get; set; }
public string? ConfigKey { get; set; }
public DateTime CreationTime { get; set; }
}
}

View File

@@ -4,6 +4,7 @@ using Yi.RBAC.Application.Contracts.Identity.Dtos;
using Yi.RBAC.Domain.Identity.Entities;
using Yi.Framework.Ddd.Services;
using SqlSugar;
using Yi.Framework.Ddd.Dtos;
namespace Yi.RBAC.Application.Identity
{
@@ -14,6 +15,19 @@ namespace Yi.RBAC.Application.Identity
public class MenuService : CrudAppService<MenuEntity, MenuGetOutputDto, MenuGetListOutputDto, long, MenuGetListInputVo, MenuCreateInputVo, MenuUpdateInputVo>,
IMenuService, IAutoApiService
{
public override async Task<PagedResultDto<MenuGetListOutputDto>> GetListAsync(MenuGetListInputVo input)
{
var entity = await MapToEntityAsync(input);
RefAsync<int> total = 0;
var entities = await _DbQueryable.WhereIF(!string.IsNullOrEmpty(input.MenuName), x => x.MenuName.Contains(input.MenuName!))
.WhereIF(input.State is not null, x => x.State == input.State)
.ToPageListAsync(input.PageNum, input.PageSize, total);
return new PagedResultDto<MenuGetListOutputDto>(total, await MapToGetListOutputDtosAsync(entities));
}
/// <summary>
/// 查询当前角色的菜单
/// </summary>
@@ -21,7 +35,7 @@ namespace Yi.RBAC.Application.Identity
/// <returns></returns>
public async Task<List<MenuGetListOutputDto>> GetListRoleIdAsync(long roleId)
{
var entities= await _DbQueryable.Where(m => SqlFunc.Subqueryable<RoleMenuEntity>().Where(rm => rm.RoleId == roleId && rm.MenuId == m.Id).Any()).ToListAsync();
var entities = await _DbQueryable.Where(m => SqlFunc.Subqueryable<RoleMenuEntity>().Where(rm => rm.RoleId == roleId && rm.MenuId == m.Id).Any()).ToListAsync();
return await MapToGetListOutputDtosAsync(entities);
}

View File

@@ -3,6 +3,9 @@ using NET.AutoWebApi.Setting;
using Yi.RBAC.Application.Contracts.Identity.Dtos;
using Yi.RBAC.Domain.Identity.Entities;
using Yi.Framework.Ddd.Services;
using Yi.Framework.Ddd.Dtos;
using SqlSugar;
using Yi.RBAC.Application.Contracts.Setting.Dtos;
namespace Yi.RBAC.Application.Identity
{
@@ -13,5 +16,16 @@ namespace Yi.RBAC.Application.Identity
public class PostService : CrudAppService<PostEntity, PostGetOutputDto, PostGetListOutputDto, long, PostGetListInputVo, PostCreateInputVo, PostUpdateInputVo>,
IPostService, IAutoApiService
{
public override async Task<PagedResultDto<PostGetListOutputDto>> GetListAsync(PostGetListInputVo input)
{
var entity = await MapToEntityAsync(input);
RefAsync<int> total = 0;
var entities = await _DbQueryable.WhereIF(!string.IsNullOrEmpty(input.PostName), x => x.PostName.Contains(input.PostName!))
.WhereIF(input.State is not null, x => x.State == input.State)
.ToPageListAsync(input.PageNum, input.PageSize, total);
return new PagedResultDto<PostGetListOutputDto>(total, await MapToGetListOutputDtosAsync(entities));
}
}
}

View File

@@ -6,6 +6,8 @@ using Yi.Framework.Ddd.Services;
using Yi.RBAC.Domain.Identity;
using Microsoft.AspNetCore.Identity;
using Yi.Framework.Uow;
using Yi.Framework.Ddd.Dtos;
using SqlSugar;
namespace Yi.RBAC.Application.Identity
{
@@ -22,6 +24,20 @@ namespace Yi.RBAC.Application.Identity
[Autowired]
private IUnitOfWorkManager _unitOfWorkManager { get; set; }
public override async Task<PagedResultDto<RoleGetListOutputDto>> GetListAsync(RoleGetListInputVo input)
{
var entity = await MapToEntityAsync(input);
RefAsync<int> total = 0;
var entities = await _DbQueryable.WhereIF(!string.IsNullOrEmpty(input.RoleCode), x => x.RoleCode.Contains(input.RoleCode!))
.WhereIF(!string.IsNullOrEmpty(input.RoleName), x => x.RoleName.Contains(input.RoleName!))
.WhereIF(input.State is not null, x => x.State == input.State)
.ToPageListAsync(input.PageNum, input.PageSize, total);
return new PagedResultDto<RoleGetListOutputDto>(total, await MapToGetListOutputDtosAsync(entities));
}
/// <summary>
/// 添加角色
/// </summary>

View File

@@ -3,6 +3,10 @@ using NET.AutoWebApi.Setting;
using Yi.RBAC.Application.Contracts.Setting.Dtos;
using Yi.RBAC.Domain.Setting.Entities;
using Yi.Framework.Ddd.Services;
using Yi.Framework.Ddd.Dtos;
using SqlSugar;
using Yi.RBAC.Application.Contracts.Identity.Dtos;
using Yi.RBAC.Domain.Identity.Entities;
namespace Yi.RBAC.Application.Setting
{
@@ -13,5 +17,17 @@ namespace Yi.RBAC.Application.Setting
public class ConfigService : CrudAppService<ConfigEntity, ConfigGetOutputDto, ConfigGetListOutputDto, long, ConfigGetListInputVo, ConfigCreateInputVo, ConfigUpdateInputVo>,
IConfigService, IAutoApiService
{
public override async Task<PagedResultDto<ConfigGetListOutputDto>> GetListAsync(ConfigGetListInputVo input)
{
var entity = await MapToEntityAsync(input);
RefAsync<int> total = 0;
var entities = await _DbQueryable.WhereIF(!string.IsNullOrEmpty(input.ConfigKey), x => x.ConfigKey.Contains(input.ConfigKey!))
.WhereIF(!string.IsNullOrEmpty(input.ConfigName), x => x.ConfigName!.Contains(input.ConfigName!))
.WhereIF(input.StartTime is not null && input.EndTime is not null, x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
.ToPageListAsync(input.PageNum, input.PageSize, total);
return new PagedResultDto<ConfigGetListOutputDto>(total, await MapToGetListOutputDtosAsync(entities));
}
}
}

View File

@@ -5,8 +5,8 @@
<el-input v-model="queryParams.roleName" placeholder="请输入角色名称" clearable style="width: 240px"
@keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="权限字符" prop="roleCode">
<el-input v-model="queryParams.roleCode" placeholder="请输入权限字符" clearable style="width: 240px"
<el-form-item label="角色编号" prop="roleCode">
<el-input v-model="queryParams.roleCode" placeholder="请输入角色编号" clearable style="width: 240px"
@keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="状态" prop="state">