新增班级页面
This commit is contained in:
parent
6aa945adbd
commit
3087f40316
|
|
@ -13,9 +13,13 @@ namespace Learn.Archives.API.Controllers
|
|||
public class AdminController : BackController<Admin>
|
||||
{
|
||||
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.menuRelationDB = menuRelationDB;
|
||||
this.menuDB = menuDB;
|
||||
}
|
||||
/// <summary>
|
||||
/// 管理员登录
|
||||
|
|
@ -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<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
|
||||
{
|
||||
//按钮权限
|
||||
Permissions = buttonRole,
|
||||
//用户名
|
||||
UserName = 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<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 };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<Menu>((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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Learn.Archives.API.Controllers
|
|||
/// 通用接口
|
||||
/// </summary>
|
||||
[Authorize(AuthenticationSchemes = Authentication.Admin)]
|
||||
[Route("api/[controller]/[action]")]
|
||||
[Route("api/[controller]")]
|
||||
public class PublicController : Controller
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5199"
|
||||
"applicationUrl": "http://localhost:5199;http://192.168.2.33:5199"
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -26,6 +26,6 @@
|
|||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
<PackageReference Include="SqlSugar.IOC" Version="2.0.0" />
|
||||
<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>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ namespace Learn.Archives.Core.Model
|
|||
/// <summary>
|
||||
/// 学校名称
|
||||
/// </summary>
|
||||
public required string SchoolName { get; set; }
|
||||
public string SchoolName { get; set; }
|
||||
/// <summary>
|
||||
/// 年级
|
||||
/// </summary>
|
||||
public required string Grade { get; set; }
|
||||
public string Grade { get; set; }
|
||||
/// <summary>
|
||||
/// 赴校时间
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue