From 6aa945adbdc3beb112fd6f49481cb03ed2b7bd77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=82=A5=E7=BE=8A?= <1048382248@qq.com> Date: Mon, 11 Aug 2025 18:25:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AddressController.cs | 55 ++++++++ .../Controllers/AdminController.cs | 15 ++- .../Controllers/AdminRoleController.cs | 26 ++++ .../Controllers/ClassController.cs | 26 ++++ Learn.Archives.API/Controllers/Dto/MeunDto.cs | 41 +++++- .../Controllers/GradeController.cs | 26 ++++ .../Controllers/MenuController.cs | 51 +++++--- .../Controllers/PublicController.cs | 55 ++++++++ .../Controllers/_BaseController.cs | 12 +- Learn.Archives.Core/Common/AppCommon.cs | 11 +- Learn.Archives.Core/Common/ClaimEnum.cs | 2 +- .../Common/Expand/SqlSugarExpand.cs | 119 ++++++++++-------- Learn.Archives.Core/Common/Repository.cs | 4 +- Learn.Archives.Core/Model/Grade.cs | 2 +- Learn.Archives.Core/Model/Menu.cs | 25 ++-- 15 files changed, 376 insertions(+), 94 deletions(-) create mode 100644 Learn.Archives.API/Controllers/AddressController.cs create mode 100644 Learn.Archives.API/Controllers/AdminRoleController.cs create mode 100644 Learn.Archives.API/Controllers/ClassController.cs create mode 100644 Learn.Archives.API/Controllers/GradeController.cs create mode 100644 Learn.Archives.API/Controllers/PublicController.cs diff --git a/Learn.Archives.API/Controllers/AddressController.cs b/Learn.Archives.API/Controllers/AddressController.cs new file mode 100644 index 0000000..d473017 --- /dev/null +++ b/Learn.Archives.API/Controllers/AddressController.cs @@ -0,0 +1,55 @@ +using Learn.Archives.API.Controllers.Dto; +using Learn.Archives.API.Expand; +using Learn.Archives.Core.Common; +using Learn.Archives.Core.Model; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Diagnostics; +using System.Security.Claims; +using UserCenter.Model; + +namespace Learn.Archives.API.Controllers +{ + [ApiExplorerSettings(GroupName = "公共接口")] + [Route("api/address")] + public class AddressController : Controller + { + private readonly Repository _provinceService; + private readonly Repository _cityService; + private readonly Repository _regionService; + + public AddressController(Repository provinceService, Repository regionService, Repository cityService) + { + _provinceService = provinceService; + _regionService = regionService; + _cityService = cityService; + } + /// + /// 获取所有省份 + /// + /// + [HttpGet, Route("province"), AllowAnonymous] + public async Task> GetProvince() + { + return await _provinceService.GetListAsync(); + } + /// + /// 获取省份下的市区 + /// + /// + [HttpGet, Route("{pid}/city"), AllowAnonymous] + public async Task> GetProvince(int pid) + { + return await _cityService.GetListAsync(s => s.Pid == pid); + } + /// + /// 获取市区下的区县 + /// + /// + [HttpGet, Route("{cid}/region"), AllowAnonymous] + public async Task> GetRegion(int cid) + { + return await _regionService.GetListAsync(s => s.Cid == cid); + } + } +} diff --git a/Learn.Archives.API/Controllers/AdminController.cs b/Learn.Archives.API/Controllers/AdminController.cs index 6372ffc..f059138 100644 --- a/Learn.Archives.API/Controllers/AdminController.cs +++ b/Learn.Archives.API/Controllers/AdminController.cs @@ -1,4 +1,5 @@ -using Learn.Archives.API.Controllers.Dto; +using Azure.Core; +using Learn.Archives.API.Controllers.Dto; using Learn.Archives.API.Expand; using Learn.Archives.Core.Common; using Learn.Archives.Core.Model; @@ -23,7 +24,7 @@ namespace Learn.Archives.API.Controllers /// [HttpPost, AllowAnonymous] [HttpLogEnable] - public async Task Login([FromBody] AdminLoginReq model) + public async Task Login([FromBody] AdminLoginReq model) { if (string.IsNullOrWhiteSpace(model.Account)) Oh.Error("登录失败,用户名不能为空"); @@ -41,12 +42,18 @@ namespace Learn.Archives.API.Controllers // 获取租户信息 //获取 - return JwtHelper.GetToken(AppCommon.Config.AuthKey, + return new + { + //用户名 + UserName = admin.Name, + NickName = admin.Name, + AccessToken = JwtHelper.GetToken(AppCommon.Config.AuthKey, [ new Claim(ClaimEnum.Role,admin.RoleId.ToString()), new Claim(ClaimEnum.Id, admin.Id.ToString()), new Claim(ClaimEnum.Name, admin.Name), - ]); + ]) + }; } diff --git a/Learn.Archives.API/Controllers/AdminRoleController.cs b/Learn.Archives.API/Controllers/AdminRoleController.cs new file mode 100644 index 0000000..e3f6e49 --- /dev/null +++ b/Learn.Archives.API/Controllers/AdminRoleController.cs @@ -0,0 +1,26 @@ +using Learn.Archives.API.Controllers.Dto; +using Learn.Archives.API.Expand; +using Learn.Archives.Core.Common; +using Learn.Archives.Core.Model; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Diagnostics; +using System.Security.Claims; +using UserCenter.Model; + +namespace Learn.Archives.API.Controllers +{ + /// + /// 管理员角色控制器 + /// + public class AdminRoleController : BackController + { + readonly Repository baseService; + readonly LiveUserInfo userInfo; + public AdminRoleController(Repository baseService, LiveUserInfo userInfo) : base(baseService) + { + this.baseService = baseService; + this.userInfo = userInfo; + } + } +} diff --git a/Learn.Archives.API/Controllers/ClassController.cs b/Learn.Archives.API/Controllers/ClassController.cs new file mode 100644 index 0000000..2abf7ed --- /dev/null +++ b/Learn.Archives.API/Controllers/ClassController.cs @@ -0,0 +1,26 @@ +using Learn.Archives.API.Controllers.Dto; +using Learn.Archives.API.Expand; +using Learn.Archives.Core.Common; +using Learn.Archives.Core.Model; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Diagnostics; +using System.Security.Claims; +using UserCenter.Model; + +namespace Learn.Archives.API.Controllers +{ + /// + /// 班级控制器 + /// + public class ClassController : BackController + { + readonly Repository baseService; + readonly LiveUserInfo userInfo; + public ClassController(Repository baseService, LiveUserInfo userInfo) : base(baseService) + { + this.baseService = baseService; + this.userInfo = userInfo; + } + } +} diff --git a/Learn.Archives.API/Controllers/Dto/MeunDto.cs b/Learn.Archives.API/Controllers/Dto/MeunDto.cs index a5f74af..f0fcf7e 100644 --- a/Learn.Archives.API/Controllers/Dto/MeunDto.cs +++ b/Learn.Archives.API/Controllers/Dto/MeunDto.cs @@ -1,4 +1,6 @@ using Learn.Archives.Core.Model; +using SqlSugar; +using System.Text.Json.Serialization; namespace Learn.Archives.API.Controllers.Dto { @@ -7,9 +9,46 @@ namespace Learn.Archives.API.Controllers.Dto /// public class MenuTree : Menu { + + [JsonIgnore] + public override string Title { get; set; } + [JsonIgnore] + public override string? Icon { get; set; } + [JsonIgnore] + public override int Rank { get; set; } + [JsonIgnore] + public override bool ShowLink { get; set; } + [JsonIgnore] + public override long ParentId { get; set; } + [JsonIgnore] + public override bool IsButton { get; set; } + /// /// 子菜单列表 /// - public MenuTree[] Children { get; set; } = Array.Empty(); + public MenuTree[]? Children { get; set; } + public MenuMeta Meta { get; set; } + } + /// + /// 菜单树媒体 + /// + public class MenuMeta + { + /// + /// 菜单名称 + /// + public string Title { get; set; } + /// + /// 图标 + /// + public string? Icon { get; set; } + /// + /// 排名 + /// + public int Rank { get; set; } + /// + /// 显示菜单? + /// + public bool ShowLink { get; set; } } } diff --git a/Learn.Archives.API/Controllers/GradeController.cs b/Learn.Archives.API/Controllers/GradeController.cs new file mode 100644 index 0000000..7387534 --- /dev/null +++ b/Learn.Archives.API/Controllers/GradeController.cs @@ -0,0 +1,26 @@ +using Learn.Archives.API.Controllers.Dto; +using Learn.Archives.API.Expand; +using Learn.Archives.Core.Common; +using Learn.Archives.Core.Model; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Diagnostics; +using System.Security.Claims; +using UserCenter.Model; + +namespace Learn.Archives.API.Controllers +{ + /// + /// 年级控制器 + /// + public class GradeController : BackController + { + readonly Repository baseService; + readonly LiveUserInfo userInfo; + public GradeController(Repository baseService, LiveUserInfo userInfo) : base(baseService) + { + this.baseService = baseService; + this.userInfo = userInfo; + } + } +} diff --git a/Learn.Archives.API/Controllers/MenuController.cs b/Learn.Archives.API/Controllers/MenuController.cs index 49535ac..ffcc366 100644 --- a/Learn.Archives.API/Controllers/MenuController.cs +++ b/Learn.Archives.API/Controllers/MenuController.cs @@ -2,6 +2,7 @@ using Learn.Archives.API.Expand; using Learn.Archives.Core.Common; using Learn.Archives.Core.Model; +using Learn.Archives.Core.Model.Dto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Diagnostics; @@ -16,13 +17,26 @@ namespace Learn.Archives.API.Controllers public class MenuController : BackController { readonly Repository baseService; + readonly Repository roleService; readonly Repository menuRelationDB; readonly LiveUserInfo userInfo; - public MenuController(Repository baseService, LiveUserInfo userInfo, Repository menuRelationDB) : base(baseService) + public MenuController(Repository baseService, LiveUserInfo userInfo, Repository menuRelationDB, Repository roleService) : base(baseService) { this.baseService = baseService; this.userInfo = userInfo; this.menuRelationDB = menuRelationDB; + this.roleService = roleService; + } + /// + /// 管理员菜单 + /// + /// + [HttpGet] + public async Task> All() + { + var rId = userInfo.RoleId; + if (rId != 1) Oh.Error("登录了无效的用户"); + return await baseService.GetListAsync(); } /// @@ -34,37 +48,44 @@ namespace Learn.Archives.API.Controllers { var rId = userInfo.RoleId; if (rId == 0) Oh.Error("登录了无效的用户"); - var menuArr = await menuRelationDB.AsQueryable() - .LeftJoin((mr, m) => mr.MenuId == m.Id) - .Where((mr,m)=> mr.RoleId == userInfo.RoleId) - .Select((mr, m) => m) - .ToArrayAsync(); - return GetChildren(menuArr, menuArr.First().Id); + Menu[] menuArr ; + if (userInfo.RoleId == 1) + menuArr = await baseService.AsQueryable().ToArrayAsync(); + else + menuArr = await menuRelationDB.AsQueryable() + .LeftJoin((mr, m) => mr.MenuId == m.Id) + .Where((mr, m) => mr.RoleId == userInfo.RoleId) + .Select((mr, m) => m) + .ToArrayAsync(); + return GetChildren(menuArr, 0); } /// /// 递归获取子菜单 /// [NonAction] - private static MenuTree[] GetChildren(IEnumerable menus, long parentId) + private static MenuTree[]? GetChildren(IEnumerable menus, long parentId) { - return menus + var res = menus .Where(m => m.ParentId == parentId) .OrderBy(m => m.Rank) .Select(m => new MenuTree { Id = m.Id, Name = m.Name, - Title = m.Title, Path = m.Path, - IsButton = m.IsButton, - Icon = m.Icon, - Auths = m.Auths, - Rank = m.Rank, - ShowLink = m.ShowLink, + Meta = new MenuMeta() + { + Title = m.Title, + Icon = m.Icon, + Rank = m.Rank, + ShowLink = m.ShowLink, + //Auths = m.Auths, + }, ParentId = m.ParentId, Children = GetChildren(menus, m.Id) }) .ToArray(); + return res.Length==0?null: res; } } diff --git a/Learn.Archives.API/Controllers/PublicController.cs b/Learn.Archives.API/Controllers/PublicController.cs new file mode 100644 index 0000000..9b06ab0 --- /dev/null +++ b/Learn.Archives.API/Controllers/PublicController.cs @@ -0,0 +1,55 @@ +using Learn.Archives.API.Controllers.Dto; +using Learn.Archives.API.Expand; +using Learn.Archives.Core.Common; +using Learn.Archives.Core.Model; +using Learn.Archives.Core.Model.Dto; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Diagnostics; +using System.Security.Claims; +using UserCenter.Model; + +namespace Learn.Archives.API.Controllers +{ + /// + /// 通用接口 + /// + [Authorize(AuthenticationSchemes = Authentication.Admin)] + [Route("api/[controller]/[action]")] + public class PublicController : Controller + { + + public PublicController(Repository baseService) + { + } + + /// + /// App.EntityDto.Enum 枚举转下拉列表 + /// + /// 枚举名称 例子type='ExamStatusEnum' + /// + [HttpGet, Route("enum/{type}")] + [ResponseCache(Duration = 5)] + public List GetExamStatusData(string type) + { + if (!AppCommon.EnumType.ContainsKey(type)) + Oh.Error("无效类型"); + return Enum.GetValues(AppCommon.EnumType[type]).Cast() + .Select(enumValue => new ComboModel() { Text = enumValue.ToString(), Value = (int)enumValue }).ToList(); + } + /// + /// App.EntityDto.Enum 枚举转下拉列表 + /// + /// 枚举名称 例子type='ExamStatusEnum' + /// + [HttpGet, Route("enum/{type}/Dic")] + [ResponseCache(Duration = 5)] + public Dictionary GetExamStatusDictionary(string type) + { + if (!AppCommon.EnumType.ContainsKey(type)) + Oh.Error("无效类型"); + return Enum.GetValues(AppCommon.EnumType[type]).Cast() + .ToDictionary(s => (int)s, s => s.ToString()); + } + } +} diff --git a/Learn.Archives.API/Controllers/_BaseController.cs b/Learn.Archives.API/Controllers/_BaseController.cs index 0e517db..4870427 100644 --- a/Learn.Archives.API/Controllers/_BaseController.cs +++ b/Learn.Archives.API/Controllers/_BaseController.cs @@ -45,7 +45,7 @@ namespace Learn.Archives.API.Controllers /// /// /// - [HttpGet, Route("{id}")] + [HttpGet] public virtual async Task Info(long id) { return await _baseRepository.GetByIdAsync(id); @@ -56,7 +56,7 @@ namespace Learn.Archives.API.Controllers /// /// /// - [HttpPost, Route("edit")] + [HttpPost] [HttpLogEnable] public virtual async Task Edit([FromBody] T model) { @@ -70,7 +70,7 @@ namespace Learn.Archives.API.Controllers /// /// /// - [HttpPost, Route("delete")] + [HttpPost] [HttpLogEnable] public virtual async Task Del([FromBody] params long[] ids) { @@ -122,8 +122,8 @@ namespace Learn.Archives.API.Controllers /// /// /// - [HttpPost, Route("pagelist")] - public virtual async Task GetPageList([FromBody] QueryRequestBase model) + [HttpPost] + public virtual async Task PageList([FromBody] QueryRequestBase model) { var sqlquery = BaseQuery(model); RefAsync total = 0; @@ -136,7 +136,7 @@ namespace Learn.Archives.API.Controllers /// /// /// - [HttpPost, Route("querycombo")] + [HttpPost] public virtual async Task> QueryCombo([FromBody] QueryCombo model) { if (string.IsNullOrEmpty(model.ValueName) || string.IsNullOrEmpty(model.TextName)) diff --git a/Learn.Archives.Core/Common/AppCommon.cs b/Learn.Archives.Core/Common/AppCommon.cs index 2d35d2c..1b5dcff 100644 --- a/Learn.Archives.Core/Common/AppCommon.cs +++ b/Learn.Archives.Core/Common/AppCommon.cs @@ -35,6 +35,7 @@ namespace Learn.Archives.Core.Common /// public static readonly IEnumerable DbMatserType; public static readonly IEnumerable UserCenterType; + public static readonly Dictionary EnumType; static AppCommon() { try @@ -47,7 +48,15 @@ namespace Learn.Archives.Core.Common DbMatserType = assembliesType .Where(u => u.GetInterfaces().Contains(typeof(IDB))); UserCenterType = assembliesType - .Where(u => u.FullName.Contains("UserCenter")); + .Where(u => u.FullName.Contains("UserCenter")); + + + + EnumType = Assemblies + .Where(s => s.FullName.Contains("Model")) + .SelectMany(s => s.GetTypes().Where(x => x.IsEnum)) + .ToDictionary(s => s.Name, s => s); + } catch { diff --git a/Learn.Archives.Core/Common/ClaimEnum.cs b/Learn.Archives.Core/Common/ClaimEnum.cs index e456ae0..51339de 100644 --- a/Learn.Archives.Core/Common/ClaimEnum.cs +++ b/Learn.Archives.Core/Common/ClaimEnum.cs @@ -6,7 +6,7 @@ public static string PositionId => "position"; public static string UserId => "user"; public static string Id => "id"; - public static string Role => "role"; + public static string Role => "roleid"; public static string Scope => "scope"; public static string Name => "name"; } diff --git a/Learn.Archives.Core/Common/Expand/SqlSugarExpand.cs b/Learn.Archives.Core/Common/Expand/SqlSugarExpand.cs index 9c8ae59..c0ca350 100644 --- a/Learn.Archives.Core/Common/Expand/SqlSugarExpand.cs +++ b/Learn.Archives.Core/Common/Expand/SqlSugarExpand.cs @@ -48,61 +48,74 @@ namespace Learn.Archives.Core.Common.Expand //注入SqlSugar 主库 services.AddSqlSugar(dbList); - - services.ConfigurationSugar(db => - { - var config = db.CurrentConnectionConfig; - // 设置超时时间 - db.Ado.CommandTimeOut = 61; -#if DEBUG - // 打印SQL语句 - db.Aop.OnLogExecuting = (sql, pars) => - { - if (!ShowSQL) return; - //var originColor = Console.ForegroundColor; - //if (sql.StartsWith("SELECT", StringComparison.OrdinalIgnoreCase)) - // Console.ForegroundColor = ConsoleColor.Green; - //if (sql.StartsWith("UPDATE", StringComparison.OrdinalIgnoreCase) || sql.StartsWith("INSERT", StringComparison.OrdinalIgnoreCase)) - // Console.ForegroundColor = ConsoleColor.Yellow; - //if (sql.StartsWith("DELETE", StringComparison.OrdinalIgnoreCase)) - // Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine($"【{DateTime.Now}——执行SQL - [{config.ConfigId}]】\r\n" + UtilMethods.GetSqlString(config.DbType, sql, pars) + "\r\n"); - //Console.ForegroundColor = originColor; - }; -#endif - db.Aop.OnError = (ex) => - { - if (ex.Parametres == null) return; - //var originColor = Console.ForegroundColor; - //Console.ForegroundColor = ConsoleColor.DarkRed; - Console.WriteLine($"【{DateTime.Now}——错误SQL - [{config.ConfigId}]】\r\n" + ex.Message + "\r\n" + UtilMethods.GetSqlString(config.DbType, ex.Sql, (SugarParameter[])ex.Parametres) + "\r\n"); - Console.WriteLine(); - //Console.ForegroundColor = originColor; - }; - db.Aop.DataExecuting = (oldValue, entityInfo) => - { - if (entityInfo.OperationType == DataFilterType.InsertByObject) - { - // 主键(long类型)且没有值的---赋值雪花Id - if (entityInfo.EntityColumnInfo.IsPrimarykey && !entityInfo.EntityColumnInfo.IsIdentity && entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(long)) - { - var id = entityInfo.EntityColumnInfo.PropertyInfo.GetValue(entityInfo.EntityValue); - if (id == null || (long)id == 0) - entityInfo.SetValue(YitIdHelper.NextId()); - } - if (entityInfo.PropertyName == "CreateTime" && entityInfo.EntityValue is null) - entityInfo.SetValue(DateTime.Now); - } - if (entityInfo.OperationType == DataFilterType.UpdateByObject) - { - - } - }; - - }); - #endregion + + services.ConfigurationSugar(SetDbAop); + } + + + + /// + /// 配置Aop + /// + /// + /// 配置 学校数据 sql过滤 默认true + public static void SetDbAop(ISqlSugarClient db) + { + if (db.Ado.CommandTimeOut == 61) + { + return; + } + var config = db.CurrentConnectionConfig; + // 设置超时时间 + db.Ado.CommandTimeOut = 61; +#if DEBUG + // 打印SQL语句 + db.Aop.OnLogExecuting = (sql, pars) => + { + if (!ShowSQL) return; + Console.WriteLine($"【{DateTime.Now}——执行SQL - [{config.ConfigId}]】\r\n" + UtilMethods.GetSqlString(config.DbType, sql, pars) + "\r\n"); + }; +#endif + db.Aop.OnError = (ex) => + { + if (ex.Parametres == null) return; + Console.WriteLine($"【{DateTime.Now}——错误SQL - [{config.ConfigId}]】\r\n" + ex.Message + "\r\n" + UtilMethods.GetSqlString(config.DbType, ex.Sql, (SugarParameter[])ex.Parametres) + "\r\n"); + Console.WriteLine(); + }; + db.Aop.DataExecuting = (oldValue, entityInfo) => + { + if (entityInfo.OperationType == DataFilterType.InsertByObject) + { + // 主键(long类型)且没有值的---赋值雪花Id + if (entityInfo.EntityColumnInfo.IsPrimarykey && !entityInfo.EntityColumnInfo.IsIdentity && entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(long)) + { + var id = entityInfo.EntityColumnInfo.PropertyInfo.GetValue(entityInfo.EntityValue); + if (id == null || (long)id == 0) + entityInfo.SetValue(YitIdHelper.NextId()); + } + if (entityInfo.PropertyName == "CreateTime" && entityInfo.EntityValue is null) + entityInfo.SetValue(DateTime.Now); + } + if (entityInfo.OperationType == DataFilterType.UpdateByObject) + { + + } + }; + + // 超管时排除各种过滤器 + //if (App.User?.FindFirst(ClaimEnum.Role)?.Value == "1") + //return; + // 配置用户机构(数据范围)过滤器 + //SetOrgEntityFilter(db); + } + + + + + + public static void UseSqlSugarExpand(this IApplicationBuilder app) { ShowSQL = false; diff --git a/Learn.Archives.Core/Common/Repository.cs b/Learn.Archives.Core/Common/Repository.cs index a908e12..cc0f719 100644 --- a/Learn.Archives.Core/Common/Repository.cs +++ b/Learn.Archives.Core/Common/Repository.cs @@ -1,4 +1,5 @@ -using SqlSugar; +using Learn.Archives.Core.Common.Expand; +using SqlSugar; using SqlSugar.IOC; using System; using System.Collections.Generic; @@ -23,6 +24,7 @@ namespace Learn.Archives.Core.Common base.Context = DbScoped.Sugar; else if (AppCommon.UserCenterType.Contains(t)) base.Context = DbScoped.Sugar.GetConnectionScope(1001); + SqlSugarExpand.SetDbAop(base.Context); } } } diff --git a/Learn.Archives.Core/Model/Grade.cs b/Learn.Archives.Core/Model/Grade.cs index 4b4055b..fdd5e1c 100644 --- a/Learn.Archives.Core/Model/Grade.cs +++ b/Learn.Archives.Core/Model/Grade.cs @@ -29,7 +29,7 @@ namespace Learn.Archives.Core.Model /// 学校名称 /// [SugarColumn(Length = 12)] - public required string SchoolName { get; set; } + public string SchoolName { get; set; } = string.Empty; /// /// 学校Id /// diff --git a/Learn.Archives.Core/Model/Menu.cs b/Learn.Archives.Core/Model/Menu.cs index 460f591..ced48bf 100644 --- a/Learn.Archives.Core/Model/Menu.cs +++ b/Learn.Archives.Core/Model/Menu.cs @@ -21,11 +21,6 @@ namespace Learn.Archives.Core.Model [SugarColumn(Length = 50)] public string Name { get; set; } /// - /// 标题 - /// - [SugarColumn(Length = 20)] - public string Title { get; set; } - /// /// 路径 /// [SugarColumn(IsNullable = true)] @@ -33,33 +28,41 @@ namespace Learn.Archives.Core.Model /// /// 是按钮权限 /// - public bool IsButton { get; set; } + public virtual bool IsButton { get; set; } + + /// + /// 标题 + /// + [SugarColumn(Length = 20)] + public virtual string Title { get; set; } + /// /// 图标 /// [SugarColumn(IsNullable = true)] - public string? Icon { get; set; } + public virtual string? Icon { get; set; } + /// /// 需要的授权码 /// [SugarColumn(IsNullable = true)] - public string? Auths { get; set; } + public virtual string? Auths { get; set; } /// /// 排名 /// - public int Rank { get; set; } + public virtual int Rank { get; set; } /// /// 显示菜单? /// - public bool ShowLink { get; set; } + public virtual bool ShowLink { get; set; } /// /// 父级菜单ID /// 属于 /// [SugarColumn(IsNullable = true)] - public long ParentId { get; set; } + public virtual long ParentId { get; set; } } }