mirror of
https://github.com/nsnail/NetAdmin.git
synced 2025-12-30 09:25:49 +08:00
feat: ✨ 基础模块
注册登录 用户管理 角色管理 部门管理 消息管理 接口管理 菜单管理 字典管理 缓存管理 请求日志 系统设置 版本信息 代码生成
This commit is contained in:
@@ -8,17 +8,10 @@ using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
namespace NetAdmin.SysComponent.Application.Services.Sys;
|
||||
|
||||
/// <inheritdoc cref="IRoleService" />
|
||||
public sealed class RoleService : RepositoryService<Sys_Role, IRoleService>, IRoleService
|
||||
public sealed class RoleService(DefaultRepository<Sys_Role> rpo) //
|
||||
: RepositoryService<Sys_Role, IRoleService>(rpo), IRoleService
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RoleService" /> class.
|
||||
/// </summary>
|
||||
public RoleService(Repository<Sys_Role> rpo) //
|
||||
: base(rpo) { }
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除角色
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public async Task<int> BulkDeleteAsync(BulkReq<DelReq> req)
|
||||
{
|
||||
var sum = 0;
|
||||
@@ -29,9 +22,7 @@ public sealed class RoleService : RepositoryService<Sys_Role, IRoleService>, IRo
|
||||
return sum;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建角色
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public async Task<QueryRoleRsp> CreateAsync(CreateRoleReq req)
|
||||
{
|
||||
var entity = req.Adapt<Sys_Role>();
|
||||
@@ -45,9 +36,7 @@ public sealed class RoleService : RepositoryService<Sys_Role, IRoleService>, IRo
|
||||
return entity.Adapt<QueryRoleRsp>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除角色
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
/// <exception cref="NetAdminInvalidOperationException">Users_exist_under_this_role_and_deletion_is_not_allowed</exception>
|
||||
public async Task<int> DeleteAsync(DelReq req)
|
||||
{
|
||||
@@ -56,27 +45,20 @@ public sealed class RoleService : RepositoryService<Sys_Role, IRoleService>, IRo
|
||||
: await Rpo.DeleteAsync(a => a.Id == req.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断角色是否存在
|
||||
/// </summary>
|
||||
/// <exception cref="NotImplementedException">NotImplementedException</exception>
|
||||
/// <inheritdoc />
|
||||
public Task<bool> ExistAsync(QueryReq<QueryRoleReq> req)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return QueryInternal(req).AnyAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个角色
|
||||
/// </summary>
|
||||
/// <exception cref="NotImplementedException">NotImplementedException</exception>
|
||||
public Task<QueryRoleRsp> GetAsync(QueryRoleReq req)
|
||||
/// <inheritdoc />
|
||||
public async Task<QueryRoleRsp> GetAsync(QueryRoleReq req)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var ret = await QueryInternal(new QueryReq<QueryRoleReq> { Filter = req }).ToOneAsync();
|
||||
return ret.Adapt<QueryRoleRsp>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询角色
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public async Task<PagedQueryRsp<QueryRoleRsp>> PagedQueryAsync(PagedQueryReq<QueryRoleReq> req)
|
||||
{
|
||||
var list = await QueryInternal(req).Page(req.Page, req.PageSize).Count(out var total).ToListAsync();
|
||||
@@ -84,18 +66,14 @@ public sealed class RoleService : RepositoryService<Sys_Role, IRoleService>, IRo
|
||||
return new PagedQueryRsp<QueryRoleRsp>(req.Page, req.PageSize, total, list.Adapt<IEnumerable<QueryRoleRsp>>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询角色
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public async Task<IEnumerable<QueryRoleRsp>> QueryAsync(QueryReq<QueryRoleReq> req)
|
||||
{
|
||||
var ret = await QueryInternal(req).ToListAsync();
|
||||
return ret.Adapt<IEnumerable<QueryRoleRsp>>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新角色
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public async Task<QueryRoleRsp> UpdateAsync(UpdateRoleReq req)
|
||||
{
|
||||
var entity = req.Adapt<Sys_Role>();
|
||||
@@ -107,6 +85,12 @@ public sealed class RoleService : RepositoryService<Sys_Role, IRoleService>, IRo
|
||||
return (await QueryAsync(new QueryReq<QueryRoleReq> { Filter = new QueryRoleReq { Id = req.Id } })).First();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override Task<Sys_Role> UpdateForSqliteAsync(Sys_Role req)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private ISelect<Sys_Role> QueryInternal(QueryReq<QueryRoleReq> req)
|
||||
{
|
||||
var ret = Rpo.Select.IncludeMany(a => a.Depts.Select(b => new Sys_Dept { Id = b.Id }))
|
||||
@@ -116,8 +100,8 @@ public sealed class RoleService : RepositoryService<Sys_Role, IRoleService>, IRo
|
||||
.WhereDynamic(req.Filter)
|
||||
.WhereIf( //
|
||||
req.Keywords?.Length > 0
|
||||
, a => a.Name.Contains(req.Keywords) || a.Summary.Contains(req.Keywords) ||
|
||||
a.Id == req.Keywords.Int64Try(0))
|
||||
, a => a.Id == req.Keywords.Int64Try(0) || a.Name.Contains(req.Keywords) ||
|
||||
a.Summary.Contains(req.Keywords))
|
||||
.OrderByPropertyNameIf(req.Prop?.Length > 0, req.Prop, req.Order == Orders.Ascending);
|
||||
|
||||
if (!req.Prop?.Equals(nameof(req.Filter.Sort), StringComparison.OrdinalIgnoreCase) ?? true) {
|
||||
|
||||
Reference in New Issue
Block a user