From e0d60f249e1323a04a9fc0ef1835eb23974587e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=82=9C=E7=BF=94?= <2307953404@qq.com> Date: Fri, 8 Nov 2024 21:58:56 +0800 Subject: [PATCH] for teach --- asg_form/Controllers/AssignmentController.cs | 4 +-- asg_form/Controllers/BlackController.cs | 30 ++++++++++++++++++++ asg_form/Controllers/Dbset.cs | 1 + 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 asg_form/Controllers/BlackController.cs diff --git a/asg_form/Controllers/AssignmentController.cs b/asg_form/Controllers/AssignmentController.cs index 4fdf82d..7495cf4 100644 --- a/asg_form/Controllers/AssignmentController.cs +++ b/asg_form/Controllers/AssignmentController.cs @@ -297,12 +297,12 @@ namespace asg_form.Controllers .Take(limit) .ToListAsync(); - var result = new + var data = new { rows = Tasks , total = TotalRecords, }; - return Ok(result); + return Ok(new { code = 200, message = " ", data }); } } diff --git a/asg_form/Controllers/BlackController.cs b/asg_form/Controllers/BlackController.cs new file mode 100644 index 0000000..d045600 --- /dev/null +++ b/asg_form/Controllers/BlackController.cs @@ -0,0 +1,30 @@ +using AsmResolver.PE.DotNet.Cil; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Security.Claims; +using static asg_form.Controllers.AssignmentController; + +namespace asg_form.Controllers +{ + public class BlackDB + { + public int id { get; set; } + public string user_name { get; set; } + //..... + } + public class BlackController : ControllerBase + { + [Route("api/v1/blackTable")] + [HttpGet] + public async Task> blackAdd ([FromQuery] string userName) + { + if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "nbadmin")||!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) + { + return Ok(new error_mb { code = 401, message = "无权访问" }); + } + TestDbContext sub = new TestDbContext(); + + return Ok(new { code = 200, message = "" }); + } + } +} diff --git a/asg_form/Controllers/Dbset.cs b/asg_form/Controllers/Dbset.cs index d9763c0..a882f06 100644 --- a/asg_form/Controllers/Dbset.cs +++ b/asg_form/Controllers/Dbset.cs @@ -289,6 +289,7 @@ namespace asg_form.Controllers public DbSet T_Invitation { get; set; } public DbSet mainMenu { get; set; } public DbSet T_captcha_check { get; set; } + public DbSet T_blacks { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { string connStr = @"Host=localhost;Port=2345;Database=asg;Username=postgres;Password=luolan12323;";