From 1da5474826026df60a2d3da434aa910aca3a6d3b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=AF=85?= <2667210109@qq.com>
Date: Sat, 26 Oct 2024 12:18:50 +0800
Subject: [PATCH] 11
---
asg_form/Controllers/admin.cs | 28 ++++++++++++++++++++++++++++
asg_form/qqbot.cs | 26 +-------------------------
asg_form/return.cs | 14 ++++++++++++++
3 files changed, 43 insertions(+), 25 deletions(-)
create mode 100644 asg_form/return.cs
diff --git a/asg_form/Controllers/admin.cs b/asg_form/Controllers/admin.cs
index 6f5f12a..68b2d98 100644
--- a/asg_form/Controllers/admin.cs
+++ b/asg_form/Controllers/admin.cs
@@ -309,6 +309,34 @@ namespace asg_form.Controllers
}
+
+ ///
+ /// 设置管理员,需要superadmin
+ ///
+ ///
+ ///
+ [Route("api/v1/admin/removeadmin")]
+ [HttpPost]
+ [Authorize]
+ public async Task> removeadmin(string userid)
+ {
+ if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
+ {
+ var ouser = await userManager.FindByIdAsync(userid);
+
+ await userManager.RemoveFromRoleAsync(ouser, "admin");
+
+ return Ok(new { message = "用户成功设置为管理员" });
+ }
+ else
+ {
+ return BadRequest(new error_mb { code = 400, message = "无权访问" });
+
+ }
+
+ }
+
+
//管理员设置用户的职位
[Route("api/v1/admin/setop")]
[HttpPost]
diff --git a/asg_form/qqbot.cs b/asg_form/qqbot.cs
index 23f7e5c..7fc4756 100644
--- a/asg_form/qqbot.cs
+++ b/asg_form/qqbot.cs
@@ -98,31 +98,7 @@ namespace asg_form
}
- [Command]
- public string 近期赛程1()
- {
- try
- {
- TestDbContext testDb = new TestDbContext();
- int q = testDb.team_Games.Count();
- var t = (DateTime.Now);
- var a = testDb.team_Games.Where(a => string.Compare(a.opentime, t.ToString()) >= 0).Take(7);
- string msg = "";
- foreach (var b in a)
- {
- msg = $"{msg}\r\n{b.team1_name} VS {b.team2_name}\r\n时间:{b.opentime.ToString()}";
- }
- return msg;
-
-
- }
- catch
- {
- return "出现错误";
- }
-
- }
-
+
[Command]
public string 查询冠军()
diff --git a/asg_form/return.cs b/asg_form/return.cs
new file mode 100644
index 0000000..6ae4619
--- /dev/null
+++ b/asg_form/return.cs
@@ -0,0 +1,14 @@
+namespace asg_form
+{
+ public class TReturn
+ {
+ public int Code { get; set; }
+ public object Msg { get; set; }
+ }
+
+ public class TReturn_total
+ {
+ public int Total { get; set; }
+ public object Msg { get; set; }
+ }
+}