新增班级页面

This commit is contained in:
小肥羊 2025-08-13 18:37:54 +08:00
parent 6aa945adbd
commit 3087f40316
11 changed files with 75 additions and 10 deletions

View File

@ -13,9 +13,13 @@ namespace Learn.Archives.API.Controllers
public class AdminController : BackController<Admin> public class AdminController : BackController<Admin>
{ {
readonly Repository<Admin> baseService; readonly Repository<Admin> baseService;
public AdminController(Repository<Admin> baseService) : base(baseService) readonly Repository<MenuRelation> menuRelationDB;
readonly Repository<Menu> menuDB;
public AdminController(Repository<Admin> baseService, Repository<MenuRelation> menuRelationDB, Repository<Menu> menuDB) : base(baseService)
{ {
this.baseService = baseService; this.baseService = baseService;
this.menuRelationDB = menuRelationDB;
this.menuDB = menuDB;
} }
/// <summary> /// <summary>
/// 管理员登录 /// 管理员登录
@ -40,10 +44,22 @@ namespace Learn.Archives.API.Controllers
if (admin.Password != model.Password.GetMD5()) if (admin.Password != model.Password.GetMD5())
Oh.Error("登录失败,密码错误"); Oh.Error("登录失败,密码错误");
// 获取租户信息 // 获取租户信息
var buttonRole = admin.RoleId==1
? ["*:*:*"]
: await menuRelationDB.AsQueryable()
.LeftJoin<Menu>((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 return new
{ {
//按钮权限
Permissions = buttonRole,
//用户名 //用户名
UserName = admin.Name, UserName = admin.Name,
NickName = admin.Name, NickName = admin.Name,
@ -56,6 +72,12 @@ namespace Learn.Archives.API.Controllers
}; };
} }
public override Task<bool> Edit([FromBody] Admin model)
{
//创建用户时 密码加密
if (model.Id == 0)
model.Password = model.Password.GetMD5();
return base.Edit(model);
}
} }
} }

View File

@ -2,11 +2,15 @@
using Learn.Archives.API.Expand; using Learn.Archives.API.Expand;
using Learn.Archives.Core.Common; using Learn.Archives.Core.Common;
using Learn.Archives.Core.Model; using Learn.Archives.Core.Model;
using Learn.Archives.Core.Model.Dto;
using Mapster;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics; using System.Diagnostics;
using System.Security.Claims; using System.Security.Claims;
using UserCenter.Model; using UserCenter.Model;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Learn.Archives.API.Controllers namespace Learn.Archives.API.Controllers
{ {
@ -22,5 +26,10 @@ namespace Learn.Archives.API.Controllers
this.baseService = baseService; this.baseService = baseService;
this.userInfo = userInfo; this.userInfo = userInfo;
} }
public override async Task<dynamic> PageList([FromBody] QueryRequestBase model)
{
var res = (PageResult<Classes>) await base.PageList(model);
return new PageResult<ClassDto>() { Data = res.Data.Adapt<List<ClassDto>>(), Total = res.Total };
}
} }
} }

View File

@ -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);
}
}

View File

@ -50,12 +50,14 @@ namespace Learn.Archives.API.Controllers
if (rId == 0) Oh.Error("登录了无效的用户"); if (rId == 0) Oh.Error("登录了无效的用户");
Menu[] menuArr ; Menu[] menuArr ;
if (userInfo.RoleId == 1) if (userInfo.RoleId == 1)
menuArr = await baseService.AsQueryable().ToArrayAsync(); menuArr = await baseService.AsQueryable()
.Where(m => !m.IsButton).ToArrayAsync();
else else
menuArr = await menuRelationDB.AsQueryable() menuArr = await menuRelationDB.AsQueryable()
.LeftJoin<Menu>((mr, m) => mr.MenuId == m.Id) .LeftJoin<Menu>((mr, m) => mr.MenuId == m.Id)
.Where((mr, m) => mr.RoleId == userInfo.RoleId) .Where((mr, m) => mr.RoleId == userInfo.RoleId)
.Select((mr, m) => m) .Select((mr, m) => m)
.Where(m=>!m.IsButton)
.ToArrayAsync(); .ToArrayAsync();
return GetChildren(menuArr, 0); return GetChildren(menuArr, 0);
} }

View File

@ -15,7 +15,7 @@ namespace Learn.Archives.API.Controllers
/// 通用接口 /// 通用接口
/// </summary> /// </summary>
[Authorize(AuthenticationSchemes = Authentication.Admin)] [Authorize(AuthenticationSchemes = Authentication.Admin)]
[Route("api/[controller]/[action]")] [Route("api/[controller]")]
public class PublicController : Controller public class PublicController : Controller
{ {

View File

@ -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<SchoolBusiness>
{
readonly Repository<SchoolBusiness> baseService;
public SchoolBusinessController(Repository<SchoolBusiness> baseService) : base(baseService)
{
this.baseService = baseService;
}
}
}

View File

@ -76,7 +76,7 @@ namespace Learn.Archives.API.Controllers
{ {
var db = _baseRepository; var db = _baseRepository;
int sum = 0; int sum = 0;
if (typeof(T).IsAssignableFrom(typeof(IDeletedFilter))) if (!typeof(T).IsAssignableFrom(typeof(IDeletedFilter)))
{ {
if(ids.Length==1) if(ids.Length==1)
return await db.DeleteByIdAsync(ids.First()); return await db.DeleteByIdAsync(ids.First());

View File

@ -8,7 +8,7 @@
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
}, },
"dotnetRunMessages": true, "dotnetRunMessages": true,
"applicationUrl": "http://localhost:5199" "applicationUrl": "http://localhost:5199;http://192.168.2.33:5199"
}, },
}, },
} }

View File

@ -14,7 +14,7 @@
"DB": { "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", "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", "SqlType": "MySql",
"UpdateTable": true "UpdateTable": false
}, },
"AuthKey": { "AuthKey": {
"Secret": "9FAB7AC7-F2DB-4C52-B81F-044055A34AF2", "Secret": "9FAB7AC7-F2DB-4C52-B81F-044055A34AF2",

View File

@ -26,6 +26,6 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="SqlSugar.IOC" Version="2.0.0" /> <PackageReference Include="SqlSugar.IOC" Version="2.0.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.170" /> <PackageReference Include="SqlSugarCore" Version="5.1.4.170" />
<PackageReference Include="UserCenter.Model" Version="1.3.9" /> <PackageReference Include="UserCenter.Model" Version="1.4.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -22,11 +22,11 @@ namespace Learn.Archives.Core.Model
/// <summary> /// <summary>
/// 学校名称 /// 学校名称
/// </summary> /// </summary>
public required string SchoolName { get; set; } public string SchoolName { get; set; }
/// <summary> /// <summary>
/// 年级 /// 年级
/// </summary> /// </summary>
public required string Grade { get; set; } public string Grade { get; set; }
/// <summary> /// <summary>
/// 赴校时间 /// 赴校时间
/// </summary> /// </summary>