diff --git a/Learn.Archives.API/Controllers/AdminController.cs b/Learn.Archives.API/Controllers/AdminController.cs index f059138..3dbdccd 100644 --- a/Learn.Archives.API/Controllers/AdminController.cs +++ b/Learn.Archives.API/Controllers/AdminController.cs @@ -13,9 +13,13 @@ namespace Learn.Archives.API.Controllers public class AdminController : BackController { readonly Repository baseService; - public AdminController(Repository baseService) : base(baseService) + readonly Repository menuRelationDB; + readonly Repository menuDB; + public AdminController(Repository baseService, Repository menuRelationDB, Repository menuDB) : base(baseService) { this.baseService = baseService; + this.menuRelationDB = menuRelationDB; + this.menuDB = menuDB; } /// /// 管理员登录 @@ -40,10 +44,22 @@ namespace Learn.Archives.API.Controllers if (admin.Password != model.Password.GetMD5()) Oh.Error("登录失败,密码错误"); // 获取租户信息 + var buttonRole = admin.RoleId==1 + ? ["*:*:*"] + : await menuRelationDB.AsQueryable() + .LeftJoin((mr, m) => mr.MenuId == m.Id) + .Where((mr, m) => mr.RoleId == admin.RoleId) + .Select((mr, m) => m) + .Where(m =>m.IsButton) + .Select(m=>m.Auths) + .ToArrayAsync(); + //获取 return new { + //按钮权限 + Permissions = buttonRole, //用户名 UserName = admin.Name, NickName = admin.Name, @@ -56,6 +72,12 @@ namespace Learn.Archives.API.Controllers }; } - + public override Task Edit([FromBody] Admin model) + { + //创建用户时 密码加密 + if (model.Id == 0) + model.Password = model.Password.GetMD5(); + return base.Edit(model); + } } } diff --git a/Learn.Archives.API/Controllers/ClassController.cs b/Learn.Archives.API/Controllers/ClassController.cs index 2abf7ed..ea43f1d 100644 --- a/Learn.Archives.API/Controllers/ClassController.cs +++ b/Learn.Archives.API/Controllers/ClassController.cs @@ -2,11 +2,15 @@ using Learn.Archives.API.Expand; using Learn.Archives.Core.Common; using Learn.Archives.Core.Model; +using Learn.Archives.Core.Model.Dto; +using Mapster; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; using System.Diagnostics; using System.Security.Claims; using UserCenter.Model; +using static System.Runtime.InteropServices.JavaScript.JSType; namespace Learn.Archives.API.Controllers { @@ -22,5 +26,10 @@ namespace Learn.Archives.API.Controllers this.baseService = baseService; this.userInfo = userInfo; } + public override async Task PageList([FromBody] QueryRequestBase model) + { + var res = (PageResult) await base.PageList(model); + return new PageResult() { Data = res.Data.Adapt>(), Total = res.Total }; + } } } diff --git a/Learn.Archives.API/Controllers/Dto/ClassDto.cs b/Learn.Archives.API/Controllers/Dto/ClassDto.cs new file mode 100644 index 0000000..d7b3f72 --- /dev/null +++ b/Learn.Archives.API/Controllers/Dto/ClassDto.cs @@ -0,0 +1,10 @@ +using UserCenter.Model; +using UserCenter.Model.Common; + +namespace Learn.Archives.API.Controllers.Dto +{ + public class ClassDto:Classes + { + public string Grade => GradeHelper.GetGrade(this.GradeLevel, GraduationYear); + } +} diff --git a/Learn.Archives.API/Controllers/MenuController.cs b/Learn.Archives.API/Controllers/MenuController.cs index ffcc366..dc4624e 100644 --- a/Learn.Archives.API/Controllers/MenuController.cs +++ b/Learn.Archives.API/Controllers/MenuController.cs @@ -50,12 +50,14 @@ namespace Learn.Archives.API.Controllers if (rId == 0) Oh.Error("登录了无效的用户"); Menu[] menuArr ; if (userInfo.RoleId == 1) - menuArr = await baseService.AsQueryable().ToArrayAsync(); + menuArr = await baseService.AsQueryable() + .Where(m => !m.IsButton).ToArrayAsync(); else menuArr = await menuRelationDB.AsQueryable() .LeftJoin((mr, m) => mr.MenuId == m.Id) .Where((mr, m) => mr.RoleId == userInfo.RoleId) .Select((mr, m) => m) + .Where(m=>!m.IsButton) .ToArrayAsync(); return GetChildren(menuArr, 0); } diff --git a/Learn.Archives.API/Controllers/PublicController.cs b/Learn.Archives.API/Controllers/PublicController.cs index 9b06ab0..f61c52e 100644 --- a/Learn.Archives.API/Controllers/PublicController.cs +++ b/Learn.Archives.API/Controllers/PublicController.cs @@ -15,7 +15,7 @@ namespace Learn.Archives.API.Controllers /// 通用接口 /// [Authorize(AuthenticationSchemes = Authentication.Admin)] - [Route("api/[controller]/[action]")] + [Route("api/[controller]")] public class PublicController : Controller { diff --git a/Learn.Archives.API/Controllers/SchoolBusinessController.cs b/Learn.Archives.API/Controllers/SchoolBusinessController.cs new file mode 100644 index 0000000..e91dee9 --- /dev/null +++ b/Learn.Archives.API/Controllers/SchoolBusinessController.cs @@ -0,0 +1,22 @@ +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 SchoolBusinessController : BackController + { + readonly Repository baseService; + public SchoolBusinessController(Repository baseService) : base(baseService) + { + this.baseService = baseService; + } + + } +} diff --git a/Learn.Archives.API/Controllers/_BaseController.cs b/Learn.Archives.API/Controllers/_BaseController.cs index 4870427..0a18f8b 100644 --- a/Learn.Archives.API/Controllers/_BaseController.cs +++ b/Learn.Archives.API/Controllers/_BaseController.cs @@ -76,7 +76,7 @@ namespace Learn.Archives.API.Controllers { var db = _baseRepository; int sum = 0; - if (typeof(T).IsAssignableFrom(typeof(IDeletedFilter))) + if (!typeof(T).IsAssignableFrom(typeof(IDeletedFilter))) { if(ids.Length==1) return await db.DeleteByIdAsync(ids.First()); diff --git a/Learn.Archives.API/Properties/launchSettings.json b/Learn.Archives.API/Properties/launchSettings.json index 5aea7d4..c5fd0ba 100644 --- a/Learn.Archives.API/Properties/launchSettings.json +++ b/Learn.Archives.API/Properties/launchSettings.json @@ -8,7 +8,7 @@ "ASPNETCORE_ENVIRONMENT": "Development" }, "dotnetRunMessages": true, - "applicationUrl": "http://localhost:5199" + "applicationUrl": "http://localhost:5199;http://192.168.2.33:5199" }, }, } \ No newline at end of file diff --git a/Learn.Archives.API/appsettings.json b/Learn.Archives.API/appsettings.json index f744304..2b7ae8b 100644 --- a/Learn.Archives.API/appsettings.json +++ b/Learn.Archives.API/appsettings.json @@ -14,7 +14,7 @@ "DB": { "ConnectionString": "AllowLoadLocalInfile=true;Server=192.168.2.9;User ID=root;Password=qwe123!@#;Port=3306;Database=learn.archives;CharSet=utf8mb4;pooling=true;SslMode=None", "SqlType": "MySql", - "UpdateTable": true + "UpdateTable": false }, "AuthKey": { "Secret": "9FAB7AC7-F2DB-4C52-B81F-044055A34AF2", diff --git a/Learn.Archives.Core/Learn.Archives.Core.csproj b/Learn.Archives.Core/Learn.Archives.Core.csproj index e36cb52..3541293 100644 --- a/Learn.Archives.Core/Learn.Archives.Core.csproj +++ b/Learn.Archives.Core/Learn.Archives.Core.csproj @@ -26,6 +26,6 @@ - + diff --git a/Learn.Archives.Core/Model/SchoolBusiness.cs b/Learn.Archives.Core/Model/SchoolBusiness.cs index 9cc1e5c..98f73c6 100644 --- a/Learn.Archives.Core/Model/SchoolBusiness.cs +++ b/Learn.Archives.Core/Model/SchoolBusiness.cs @@ -22,11 +22,11 @@ namespace Learn.Archives.Core.Model /// /// 学校名称 /// - public required string SchoolName { get; set; } + public string SchoolName { get; set; } /// /// 年级 /// - public required string Grade { get; set; } + public string Grade { get; set; } /// /// 赴校时间 ///