插件系统初步

This commit is contained in:
biss committed 2026-10-01 08:24:32 +08:00
1 parent ae4447841a
commit 7e3f138875
17 files changed
+9921 -12

No files matched your search

+2
View File
@@ -15,6 +15,8 @@
权限采用后端强制校验的角色与数据范围模型。多角色账号按 `All > College > Class > Self` 取最高数据范围:校级角色可访问全校数据,院系管理员限定本学院,辅导员通过稳定的账号 ID 绑定所带行政班,教师和学生限定本人及当前教学关系;前端菜单和路由限制仅作为交互辅助,不替代 API 授权。
系统提供统一插件平台。`SuperAdmin` 可以从“组织与权限 → 插件中心”启用或停用内置业务插件;状态变更同时作用于菜单、前端路由和对应后端 API,停用不会删除插件已有数据。插件只控制业务能力是否开放,原接口的角色与数据范围校验仍然有效。当前版本只接纳随主程序构建、经过代码审查的内置插件,不支持上传或热加载任意程序集;生产环境升级后需先执行数据库迁移,再启动新版本服务。
人员档案与登录账号分开维护。新增或 Excel 导入学生、教师档案时不会自动创建账号,也不会在修改档案时同步账号。学生首次使用时可以在登录页进入“自助激活”,填写姓名、学号、学院、专业、年级和行政班;全部匹配在籍档案后自行设置密码,系统才创建 Identity 登录账号并关联学生角色。`AspNetUsers` 作为 ASP.NET Core Identity 的内部安全存储,负责密码哈希、登录锁定、角色和令牌。
## 本地开发:热更新模式
@@ -0,0 +1,41 @@
using System.Security.Claims;
using Jiaowu.Api.Domain.Identity;
using Jiaowu.Api.Infrastructure.Plugins;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Jiaowu.Api.Controllers;
[ApiController]
[Authorize]
[Route("api/plugins")]
public sealed class PluginsController(PluginRuntimeService runtime) : ControllerBase
{
[HttpGet("runtime")]
public async Task<ActionResult<IReadOnlyList<PluginRuntimeItem>>> GetRuntime(
CancellationToken cancellationToken) =>
Ok(await runtime.GetAllAsync(cancellationToken));
[HttpGet]
[Authorize(Roles = SystemRoles.SuperAdmin)]
public async Task<ActionResult<IReadOnlyList<PluginRuntimeItem>>> GetAll(
CancellationToken cancellationToken) =>
Ok(await runtime.GetAllAsync(cancellationToken));
[HttpPut("{pluginId}/state")]
[Authorize(Roles = SystemRoles.SuperAdmin)]
public async Task<ActionResult<PluginRuntimeItem>> SetState(
string pluginId,
UpdatePluginStateRequest request,
CancellationToken cancellationToken)
{
var result = await runtime.SetEnabledAsync(
pluginId,
request.IsEnabled,
User.FindFirstValue(ClaimTypes.NameIdentifier),
cancellationToken);
return result is null ? NotFound() : Ok(result);
}
}
public sealed record UpdatePluginStateRequest(bool IsEnabled);
@@ -0,0 +1,11 @@
using Jiaowu.Api.Domain.Common;
namespace Jiaowu.Api.Domain.System;
public sealed class PluginInstallation : EntityBase
{
public required string PluginId { get; set; }
public required string InstalledVersion { get; set; }
public bool IsEnabled { get; set; } = true;
public string? ChangedByUserId { get; set; }
}
Loaded 3 of 17 files, more files were not shown because too many files have changed in this diff. Show more