From 725662693b7b47f6fae4c1917dd8d80220c7640a Mon Sep 17 00:00:00 2001 From: tk Date: Tue, 10 Dec 2024 14:49:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20=E6=A1=86=E6=9E=B6=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- package.json | 4 +- .../NetAdmin.Domain/Dto/Sys/Api/EditApiReq.cs | 2 +- .../Dto/Sys/JobRecord/EditJobRecordReq.cs | 2 +- .../Dto/Sys/LoginLog/EditLoginLogReq.cs | 2 +- .../Dto/Sys/RequestLog/EditRequestLogReq.cs | 2 +- .../EditRequestLogDetailReq.cs | 2 +- .../Dto/Sys/SiteMsgDept/EditSiteMsgDeptReq.cs | 2 +- .../Dto/Sys/SiteMsgFlag/EditSiteMsgFlagReq.cs | 2 +- .../Dto/Sys/SiteMsgRole/EditSiteMsgRoleReq.cs | 2 +- .../Dto/Sys/SiteMsgUser/EditSiteMsgUserReq.cs | 2 +- .../Dto/Sys/UserRole/CreateUserRoleReq.cs | 8 + .../Dto/Sys/UserRole/EditUserRoleReq.cs | 6 + .../Dto/Sys/UserRole/QueryUserRoleReq.cs | 8 + .../Dto/Sys/UserRole/QueryUserRoleRsp.cs | 13 + .../Dto/Sys/VerifyCode/EditVerifyCodeReq.cs | 2 +- .../Dto/Tpl/Example/EditExampleReq.cs | 2 +- .../NetAdmin.Domain/NetAdmin.Domain.csproj | 2 +- .../Enums/EnumExtensions.cs | 2 +- .../Extensions/CountryCodesExtensions.cs | 2 +- .../Modules/Sys/IRoleModule.cs | 6 + .../Modules/Sys/IUserRoleModule.cs | 12 + ...ysComponent.Application.csproj.DotSettings | 2 +- .../Sys/Dependency/IUserRoleService.cs | 6 + .../Services/Sys/RoleService.cs | 10 +- .../Services/Sys/UserRoleService.cs | 119 ++++++++ .../Sys/RoleCache.cs | 7 + .../Controllers/Sys/RoleController.cs | 9 + src/backend/UnitTests/Sys/RoleTests.cs | 11 + src/frontend/admin/package.json | 18 +- src/frontend/admin/src/api/sys/role.js | 11 + .../src/components/scContextmenu/index.vue | 10 - .../src/components/scContextmenu/item.vue | 9 - .../admin/src/components/scCron/index.vue | 9 - .../admin/src/components/scDialog/index.vue | 9 - .../src/components/scFileExport/index.vue | 9 - .../src/components/scFileImport/index.vue | 9 - .../src/components/scFileSelect/index.vue | 9 - .../src/components/scFormTable/index.vue | 9 - .../src/components/scIconSelect/index.vue | 9 - .../components/scMini/scStatusIndicator.vue | 9 - .../admin/src/components/scMini/scTrend.vue | 9 - .../src/components/scPageHeader/index.vue | 9 - .../components/scPasswordStrength/index.vue | 9 - .../admin/src/components/scSelect/index.vue | 9 - .../src/components/scSelectFilter/index.vue | 72 +++-- .../src/components/scStatistic/index.vue | 9 - .../admin/src/components/scTable/index.vue | 8 - .../src/components/scTableSelect/index.vue | 9 - .../src/components/scWaterMark/index.vue | 9 - .../src/layout/components/iframeView.vue | 9 - .../admin/src/layout/components/tasks.vue | 154 ----------- .../src/layout/components/tasks/index.vue | 261 ++++++++++++++++++ .../src/layout/components/tasks/save.vue | 44 +++ .../admin/src/layout/components/userbar.vue | 4 +- src/frontend/admin/src/locales/lang/en.js | 2 +- src/frontend/admin/src/locales/lang/zh-cn.js | 2 +- src/frontend/admin/src/style/app.scss | 2 +- src/frontend/admin/src/utils/tool.js | 7 - .../admin/src/views/sys/dept/index.vue | 11 + .../admin/src/views/sys/dept/save.vue | 3 + .../admin/src/views/sys/job/index.vue | 37 ++- .../admin/src/views/sys/job/record/index.vue | 2 +- .../admin/src/views/sys/log/login/index.vue | 4 +- .../src/views/sys/log/operation/index.vue | 5 +- .../admin/src/views/sys/role/index.vue | 11 + .../admin/src/views/sys/role/save.vue | 3 + .../admin/src/views/sys/user/index.vue | 18 ++ 68 files changed, 694 insertions(+), 399 deletions(-) create mode 100644 src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserRole/CreateUserRoleReq.cs create mode 100644 src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserRole/EditUserRoleReq.cs create mode 100644 src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserRole/QueryUserRoleReq.cs create mode 100644 src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserRole/QueryUserRoleRsp.cs create mode 100644 src/backend/NetAdmin/NetAdmin.SysComponent.Application/Modules/Sys/IUserRoleModule.cs create mode 100644 src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/Dependency/IUserRoleService.cs create mode 100644 src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserRoleService.cs delete mode 100644 src/frontend/admin/src/layout/components/tasks.vue create mode 100644 src/frontend/admin/src/layout/components/tasks/index.vue create mode 100644 src/frontend/admin/src/layout/components/tasks/save.vue diff --git a/README.md b/README.md index e141dde8..66b476f5 100644 --- a/README.md +++ b/README.md @@ -117,4 +117,4 @@ biz-infra-->infra | JavaScript | JavaScript解析器 | [Terser](https://github.com/terser/terser) | | JavaScript | 代码质量检查 | [ESLint](https://github.com/eslint/eslint) | | JavaScript | 代码格式化工具 | [Prettier](https://github.com/prettier/prettier) | -| JavaScript | 标准加密库 | [crypto-js](https://github.com/brix/crypto-js) | +| JavaScript | 标准加密库 | [crypto-js](https://github.com/brix/crypto-js) | \ No newline at end of file diff --git a/package.json b/package.json index 9755756f..735a316c 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "devDependencies": { "cz-git": "^1.11.0", "commitizen": "^4.3.1", - "prettier": "^3.4.1", + "prettier": "^3.4.2", "standard-version": "^9.5.0" }, "config": { @@ -11,4 +11,4 @@ "path": "node_modules/cz-git" } } -} +} \ No newline at end of file diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/Api/EditApiReq.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/Api/EditApiReq.cs index 35e9ce10..21fb3203 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/Api/EditApiReq.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/Api/EditApiReq.cs @@ -1,4 +1,4 @@ -using NetAdmin.Domain.DbMaps.Sys; +using NetAdmin.Domain.DbMaps.Sys; namespace NetAdmin.Domain.Dto.Sys.Api; diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/JobRecord/EditJobRecordReq.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/JobRecord/EditJobRecordReq.cs index a9137fa9..11298ead 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/JobRecord/EditJobRecordReq.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/JobRecord/EditJobRecordReq.cs @@ -1,4 +1,4 @@ -namespace NetAdmin.Domain.Dto.Sys.JobRecord; +namespace NetAdmin.Domain.Dto.Sys.JobRecord; /// /// 请求:编辑计划作业执行记录 diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/LoginLog/EditLoginLogReq.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/LoginLog/EditLoginLogReq.cs index fdef3153..8e500bad 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/LoginLog/EditLoginLogReq.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/LoginLog/EditLoginLogReq.cs @@ -1,4 +1,4 @@ -namespace NetAdmin.Domain.Dto.Sys.LoginLog; +namespace NetAdmin.Domain.Dto.Sys.LoginLog; /// /// 请求:编辑登录日志 diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/RequestLog/EditRequestLogReq.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/RequestLog/EditRequestLogReq.cs index e87f1da0..23d9b9f6 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/RequestLog/EditRequestLogReq.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/RequestLog/EditRequestLogReq.cs @@ -1,4 +1,4 @@ -namespace NetAdmin.Domain.Dto.Sys.RequestLog; +namespace NetAdmin.Domain.Dto.Sys.RequestLog; /// /// 请求:编辑请求日志 diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/RequestLogDetail/EditRequestLogDetailReq.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/RequestLogDetail/EditRequestLogDetailReq.cs index d6dccf67..e6a8389f 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/RequestLogDetail/EditRequestLogDetailReq.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/RequestLogDetail/EditRequestLogDetailReq.cs @@ -1,4 +1,4 @@ -namespace NetAdmin.Domain.Dto.Sys.RequestLogDetail; +namespace NetAdmin.Domain.Dto.Sys.RequestLogDetail; /// /// 请求:编辑请求日志明细 diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/SiteMsgDept/EditSiteMsgDeptReq.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/SiteMsgDept/EditSiteMsgDeptReq.cs index 83f4fb07..d41bb98f 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/SiteMsgDept/EditSiteMsgDeptReq.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/SiteMsgDept/EditSiteMsgDeptReq.cs @@ -1,4 +1,4 @@ -namespace NetAdmin.Domain.Dto.Sys.SiteMsgDept; +namespace NetAdmin.Domain.Dto.Sys.SiteMsgDept; /// /// 请求:编辑站内信-部门映射 diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/SiteMsgFlag/EditSiteMsgFlagReq.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/SiteMsgFlag/EditSiteMsgFlagReq.cs index cc97f2c4..e1ab4464 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/SiteMsgFlag/EditSiteMsgFlagReq.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/SiteMsgFlag/EditSiteMsgFlagReq.cs @@ -1,4 +1,4 @@ -namespace NetAdmin.Domain.Dto.Sys.SiteMsgFlag; +namespace NetAdmin.Domain.Dto.Sys.SiteMsgFlag; /// /// 请求:编辑站内信标记 diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/SiteMsgRole/EditSiteMsgRoleReq.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/SiteMsgRole/EditSiteMsgRoleReq.cs index 20e7366c..bbc9413b 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/SiteMsgRole/EditSiteMsgRoleReq.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/SiteMsgRole/EditSiteMsgRoleReq.cs @@ -1,4 +1,4 @@ -namespace NetAdmin.Domain.Dto.Sys.SiteMsgRole; +namespace NetAdmin.Domain.Dto.Sys.SiteMsgRole; /// /// 请求:编辑站内信-角色映射 diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/SiteMsgUser/EditSiteMsgUserReq.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/SiteMsgUser/EditSiteMsgUserReq.cs index b6c9d752..e807b70a 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/SiteMsgUser/EditSiteMsgUserReq.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/SiteMsgUser/EditSiteMsgUserReq.cs @@ -1,4 +1,4 @@ -namespace NetAdmin.Domain.Dto.Sys.SiteMsgUser; +namespace NetAdmin.Domain.Dto.Sys.SiteMsgUser; /// /// 请求:编辑站内信-用户映射 diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserRole/CreateUserRoleReq.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserRole/CreateUserRoleReq.cs new file mode 100644 index 00000000..bff561f5 --- /dev/null +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserRole/CreateUserRoleReq.cs @@ -0,0 +1,8 @@ +using NetAdmin.Domain.DbMaps.Sys; + +namespace NetAdmin.Domain.Dto.Sys.UserRole; + +/// +/// 请求:创建用户-角色映射 +/// +public record CreateUserRoleReq : Sys_UserRole; \ No newline at end of file diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserRole/EditUserRoleReq.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserRole/EditUserRoleReq.cs new file mode 100644 index 00000000..3462efd5 --- /dev/null +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserRole/EditUserRoleReq.cs @@ -0,0 +1,6 @@ +namespace NetAdmin.Domain.Dto.Sys.UserRole; + +/// +/// 请求:编辑用户-角色映射 +/// +public sealed record EditUserRoleReq : CreateUserRoleReq; \ No newline at end of file diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserRole/QueryUserRoleReq.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserRole/QueryUserRoleReq.cs new file mode 100644 index 00000000..91fc2316 --- /dev/null +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserRole/QueryUserRoleReq.cs @@ -0,0 +1,8 @@ +using NetAdmin.Domain.DbMaps.Sys; + +namespace NetAdmin.Domain.Dto.Sys.UserRole; + +/// +/// 请求:查询用户-角色映射 +/// +public sealed record QueryUserRoleReq : Sys_UserRole; \ No newline at end of file diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserRole/QueryUserRoleRsp.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserRole/QueryUserRoleRsp.cs new file mode 100644 index 00000000..78567871 --- /dev/null +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserRole/QueryUserRoleRsp.cs @@ -0,0 +1,13 @@ +using NetAdmin.Domain.DbMaps.Sys; + +namespace NetAdmin.Domain.Dto.Sys.UserRole; + +/// +/// 响应:查询用户-角色映射 +/// +public sealed record QueryUserRoleRsp : Sys_UserRole +{ + /// + [JsonIgnore(Condition = JsonIgnoreCondition.Never)] + public override long Id { get; init; } +} \ No newline at end of file diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/VerifyCode/EditVerifyCodeReq.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/VerifyCode/EditVerifyCodeReq.cs index 088ffe68..5f81a5f8 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/VerifyCode/EditVerifyCodeReq.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/VerifyCode/EditVerifyCodeReq.cs @@ -1,4 +1,4 @@ -namespace NetAdmin.Domain.Dto.Sys.VerifyCode; +namespace NetAdmin.Domain.Dto.Sys.VerifyCode; /// /// 请求:编辑验证码 diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Tpl/Example/EditExampleReq.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Tpl/Example/EditExampleReq.cs index 70adaee4..7712bfde 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Tpl/Example/EditExampleReq.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Tpl/Example/EditExampleReq.cs @@ -1,4 +1,4 @@ -namespace NetAdmin.Domain.Dto.Tpl.Example; +namespace NetAdmin.Domain.Dto.Tpl.Example; /// /// 请求:编辑示例 diff --git a/src/backend/NetAdmin/NetAdmin.Domain/NetAdmin.Domain.csproj b/src/backend/NetAdmin/NetAdmin.Domain/NetAdmin.Domain.csproj index 4b3fef32..92ff1b72 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/NetAdmin.Domain.csproj +++ b/src/backend/NetAdmin/NetAdmin.Domain/NetAdmin.Domain.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/backend/NetAdmin/NetAdmin.Infrastructure/Enums/EnumExtensions.cs b/src/backend/NetAdmin/NetAdmin.Infrastructure/Enums/EnumExtensions.cs index 4ccda04e..0e72262e 100644 --- a/src/backend/NetAdmin/NetAdmin.Infrastructure/Enums/EnumExtensions.cs +++ b/src/backend/NetAdmin/NetAdmin.Infrastructure/Enums/EnumExtensions.cs @@ -1,4 +1,4 @@ -namespace NetAdmin.Infrastructure.Enums; +namespace NetAdmin.Infrastructure.Enums; /// /// 枚举扩展方法 diff --git a/src/backend/NetAdmin/NetAdmin.Infrastructure/Extensions/CountryCodesExtensions.cs b/src/backend/NetAdmin/NetAdmin.Infrastructure/Extensions/CountryCodesExtensions.cs index 3140a6c1..0c0bd7eb 100644 --- a/src/backend/NetAdmin/NetAdmin.Infrastructure/Extensions/CountryCodesExtensions.cs +++ b/src/backend/NetAdmin/NetAdmin.Infrastructure/Extensions/CountryCodesExtensions.cs @@ -1,4 +1,4 @@ -namespace NetAdmin.Infrastructure.Extensions; +namespace NetAdmin.Infrastructure.Extensions; /// /// CountryCodes 扩展方法 diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Modules/Sys/IRoleModule.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Modules/Sys/IRoleModule.cs index 09a89a8e..8fe5c1ed 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Modules/Sys/IRoleModule.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Modules/Sys/IRoleModule.cs @@ -1,4 +1,5 @@ using NetAdmin.Domain.Dto.Sys.Role; +using NetAdmin.Domain.Dto.Sys.UserRole; namespace NetAdmin.SysComponent.Application.Modules.Sys; @@ -25,4 +26,9 @@ public interface IRoleModule : ICrudModule Task SetIgnorePermissionControlAsync(SetIgnorePermissionControlReq req); + + /// + /// 角色用户映射分组计数 + /// + Task, int>>> UserCountByAsync(QueryReq req); } \ No newline at end of file diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Modules/Sys/IUserRoleModule.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Modules/Sys/IUserRoleModule.cs new file mode 100644 index 00000000..1d0a01fb --- /dev/null +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Modules/Sys/IUserRoleModule.cs @@ -0,0 +1,12 @@ +using NetAdmin.Domain.Dto.Sys.UserRole; + +namespace NetAdmin.SysComponent.Application.Modules.Sys; + +/// +/// 用户-角色映射模块 +/// +public interface IUserRoleModule : ICrudModule; \ No newline at end of file diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/NetAdmin.SysComponent.Application.csproj.DotSettings b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/NetAdmin.SysComponent.Application.csproj.DotSettings index bd65a568..fa5cc3a4 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/NetAdmin.SysComponent.Application.csproj.DotSettings +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/NetAdmin.SysComponent.Application.csproj.DotSettings @@ -1,3 +1,3 @@ - + True \ No newline at end of file diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/Dependency/IUserRoleService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/Dependency/IUserRoleService.cs new file mode 100644 index 00000000..0842ec17 --- /dev/null +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/Dependency/IUserRoleService.cs @@ -0,0 +1,6 @@ +namespace NetAdmin.SysComponent.Application.Services.Sys.Dependency; + +/// +/// 用户角-色映射服务 +/// +public interface IUserRoleService : IService, IUserRoleModule; \ No newline at end of file diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RoleService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RoleService.cs index 7d8f6840..6058662e 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RoleService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RoleService.cs @@ -1,10 +1,11 @@ using NetAdmin.Domain.DbMaps.Sys; using NetAdmin.Domain.Dto.Sys.Role; +using NetAdmin.Domain.Dto.Sys.UserRole; namespace NetAdmin.SysComponent.Application.Services.Sys; /// -public sealed class RoleService(BasicRepository rpo) // +public sealed class RoleService(BasicRepository rpo, IUserRoleService userRoleService) // : RepositoryService(rpo), IRoleService { /// @@ -134,6 +135,13 @@ public sealed class RoleService(BasicRepository rpo) // return UpdateAsync(req, [nameof(req.IgnorePermissionControl)]); } + /// + public Task, int>>> UserCountByAsync(QueryReq req) + { + req.ThrowIfInvalid(); + return userRoleService.CountByAsync(req); + } + private ISelect QueryInternal(QueryReq req) { #pragma warning disable RCS1196 diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserRoleService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserRoleService.cs new file mode 100644 index 00000000..d32a2a73 --- /dev/null +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserRoleService.cs @@ -0,0 +1,119 @@ +using NetAdmin.Domain.DbMaps.Sys; +using NetAdmin.Domain.Dto.Sys.UserRole; + +namespace NetAdmin.SysComponent.Application.Services.Sys; + +/// +public sealed class UserRoleService(BasicRepository rpo) // + : RepositoryService(rpo), IUserRoleService +{ + /// + public async Task BulkDeleteAsync(BulkReq req) + { + req.ThrowIfInvalid(); + var ret = 0; + + // ReSharper disable once LoopCanBeConvertedToQuery + foreach (var item in req.Items) { + ret += await DeleteAsync(item).ConfigureAwait(false); + } + + return ret; + } + + /// + public Task CountAsync(QueryReq req) + { + req.ThrowIfInvalid(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); + } + + /// + public async Task, int>>> CountByAsync(QueryReq req) + { + req.ThrowIfInvalid(); + var ret = await QueryInternal(req with { Order = Orders.None }) + .WithNoLockNoWait() + .GroupBy(req.GetToListExp()) + .ToDictionaryAsync(a => a.Count()) + .ConfigureAwait(false); + return ret.Select(x => new KeyValuePair, int>( + req.RequiredFields.ToImmutableDictionary(y => y, y => typeof(Sys_UserRole).GetProperty(y)!.GetValue(x.Key)!.ToString()) + , x.Value)) + .OrderByDescending(x => x.Value); + } + + /// + public async Task CreateAsync(CreateUserRoleReq req) + { + req.ThrowIfInvalid(); + var ret = await Rpo.InsertAsync(req).ConfigureAwait(false); + return ret.Adapt(); + } + + /// + public Task DeleteAsync(DelReq req) + { + req.ThrowIfInvalid(); + return Rpo.DeleteAsync(a => a.Id == req.Id); + } + + /// + public Task EditAsync(EditUserRoleReq req) + { + req.ThrowIfInvalid(); + throw new NotImplementedException(); + } + + /// + public Task ExportAsync(QueryReq req) + { + req.ThrowIfInvalid(); + throw new NotImplementedException(); + } + + /// + public async Task GetAsync(QueryUserRoleReq req) + { + req.ThrowIfInvalid(); + var ret = await QueryInternal(new QueryReq { Filter = req, Order = Orders.None }).ToOneAsync().ConfigureAwait(false); + return ret.Adapt(); + } + + /// + public async Task> PagedQueryAsync(PagedQueryReq req) + { + req.ThrowIfInvalid(); + var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + + return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); + } + + /// + public async Task> QueryAsync(QueryReq req) + { + req.ThrowIfInvalid(); + var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + return ret.Adapt>(); + } + + private ISelect QueryInternal(QueryReq req) + { + var ret = Rpo.Select.WhereDynamicFilter(req.DynamicFilter).WhereDynamic(req.Filter); + + // ReSharper disable once SwitchStatementMissingSomeEnumCasesNoDefault + switch (req.Order) { + case Orders.None: + return ret; + case Orders.Random: + return ret.OrderByRandom(); + } + + ret = ret.OrderByPropertyNameIf(req.Prop?.Length > 0, req.Prop, req.Order == Orders.Ascending); + if (!req.Prop?.Equals(nameof(req.Filter.Id), StringComparison.OrdinalIgnoreCase) ?? true) { + ret = ret.OrderByDescending(a => a.Id); + } + + return ret; + } +} \ No newline at end of file diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Cache/Sys/RoleCache.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Cache/Sys/RoleCache.cs index 1c3ef106..bbf7a5b1 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Cache/Sys/RoleCache.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Cache/Sys/RoleCache.cs @@ -1,4 +1,5 @@ using NetAdmin.Domain.Dto.Sys.Role; +using NetAdmin.Domain.Dto.Sys.UserRole; namespace NetAdmin.SysComponent.Cache.Sys; @@ -83,4 +84,10 @@ public sealed class RoleCache(IDistributedCache cache, IRoleService service) // { return Service.SetIgnorePermissionControlAsync(req); } + + /// + public Task, int>>> UserCountByAsync(QueryReq req) + { + return Service.UserCountByAsync(req); + } } \ No newline at end of file diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Host/Controllers/Sys/RoleController.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Host/Controllers/Sys/RoleController.cs index 7cb7657e..e1b67c46 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Host/Controllers/Sys/RoleController.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Host/Controllers/Sys/RoleController.cs @@ -1,4 +1,5 @@ using NetAdmin.Domain.Dto.Sys.Role; +using NetAdmin.Domain.Dto.Sys.UserRole; namespace NetAdmin.SysComponent.Host.Controllers.Sys; @@ -116,4 +117,12 @@ public sealed class RoleController(IRoleCache cache) : ControllerBase + /// 角色用户映射分组计数 + /// + public Task, int>>> UserCountByAsync(QueryReq req) + { + return Cache.UserCountByAsync(req); + } } \ No newline at end of file diff --git a/src/backend/UnitTests/Sys/RoleTests.cs b/src/backend/UnitTests/Sys/RoleTests.cs index 85ad7f51..96ce69cc 100644 --- a/src/backend/UnitTests/Sys/RoleTests.cs +++ b/src/backend/UnitTests/Sys/RoleTests.cs @@ -1,4 +1,5 @@ using NetAdmin.Domain.Dto.Sys.Role; +using NetAdmin.Domain.Dto.Sys.UserRole; namespace UnitTests.Sys; @@ -139,4 +140,14 @@ public class RoleTests(WebTestApplicationFactory factory, ITestOutputHe Assert.True(rsp.IsSuccessStatusCode); return default; } + + /// + [InlineData(default)] + [Theory] + public async Task, int>>> UserCountByAsync(QueryReq req) + { + var rsp = await PostJsonAsync(typeof(RoleController), req); + Assert.True(rsp.IsSuccessStatusCode); + return default; + } } \ No newline at end of file diff --git a/src/frontend/admin/package.json b/src/frontend/admin/package.json index 8b6d79ac..6fd1ba59 100644 --- a/src/frontend/admin/package.json +++ b/src/frontend/admin/package.json @@ -11,19 +11,19 @@ "dependencies": { "@element-plus/icons-vue": "2.3.1", "ace-builds": "1.36.5", - "aieditor": "1.2.7", - "axios": "1.7.8", + "aieditor": "1.2.8", + "axios": "1.7.9", "crypto-js": "4.2.0", "echarts": "5.5.1", - "element-plus": "2.8.8", + "element-plus": "2.9.0", "json-bigint": "1.0.0", "markdown-it": "14.1.0", "markdown-it-emoji": "3.0.0", "nprogress": "0.2.0", - "sortablejs": "1.15.4", + "sortablejs": "1.15.6", "vkbeautify": "0.99.3", "vue": "3.5.13", - "vue-i18n": "10.0.4", + "vue-i18n": "10.0.5", "vue-router": "4.5.0", "vue3-ace-editor": "2.2.4", "vue3-json-viewer": "2.2.2", @@ -32,11 +32,11 @@ }, "devDependencies": { "@vitejs/plugin-vue": "5.2.1", - "prettier": "3.4.1", + "prettier": "3.4.2", "prettier-plugin-organize-attributes": "1.0.0", - "sass": "1.81.0", - "terser": "5.36.0", - "vite": "6.0.1" + "sass": "1.82.0", + "terser": "5.37.0", + "vite": "6.0.3" }, "browserslist": [ "> 1%", diff --git a/src/frontend/admin/src/api/sys/role.js b/src/frontend/admin/src/api/sys/role.js index de189cb1..21cde53e 100644 --- a/src/frontend/admin/src/api/sys/role.js +++ b/src/frontend/admin/src/api/sys/role.js @@ -147,4 +147,15 @@ export default { return await http.post(this.url, data, config) }, }, + + /** + * 角色用户映射分组计数 + */ + userCountBy: { + url: `${config.API_URL}/api/sys/role/user.count.by`, + name: `角色用户映射分组计数`, + post: async function (data = {}, config = {}) { + return await http.post(this.url, data, config) + }, + }, } \ No newline at end of file diff --git a/src/frontend/admin/src/components/scContextmenu/index.vue b/src/frontend/admin/src/components/scContextmenu/index.vue index e19948ea..06db715f 100644 --- a/src/frontend/admin/src/components/scContextmenu/index.vue +++ b/src/frontend/admin/src/components/scContextmenu/index.vue @@ -1,13 +1,3 @@ - -