From 1f2dbfd74f71fe21407ee86ed56ae6e847328f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=82=9C=E7=BF=94?= <2307953404@qq.com> Date: Tue, 22 Oct 2024 22:27:56 +0800 Subject: [PATCH] e --- asg_form/Controllers/admin.cs | 4 ++-- asg_form/Controllers/schedule.cs | 39 +++++++++++++++++++++----------- asg_form/qqbot.cs | 13 ++++++----- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/asg_form/Controllers/admin.cs b/asg_form/Controllers/admin.cs index 72997ab..a66eccc 100644 --- a/asg_form/Controllers/admin.cs +++ b/asg_form/Controllers/admin.cs @@ -254,7 +254,7 @@ namespace asg_form.Controllers if (keyword == null) { a.cout = userManager.Users.Count(); - a.msg = await userManager.Users.Paginate(pageindex, pagesize).Select(a => new { a.Id, a.Email, a.chinaname, a.UserName, a.Integral, a.officium}).ToListAsync(); + a.msg = await userManager.Users.Paginate(pageindex, pagesize).Select(a => new { a.Id, a.Email, a.chinaname, a.UserName, a.Integral, a.officium,a.qqnumber}).ToListAsync(); } else @@ -581,7 +581,7 @@ namespace asg_form.Controllers { team1_name = teamname1, team2_name = teamname2, - opentime = DateTime.Now, + opentime = DateTime.Now.ToString(), team1_piaoshu = 0, team2_piaoshu = 0, commentary = "待公布", diff --git a/asg_form/Controllers/schedule.cs b/asg_form/Controllers/schedule.cs index 26d33e9..a8c2141 100644 --- a/asg_form/Controllers/schedule.cs +++ b/asg_form/Controllers/schedule.cs @@ -34,6 +34,7 @@ namespace asg_form.Controllers bool a = await userManager.IsInRoleAsync(user, "admin"); if (a) { + int wp = -1; try { using (TestDbContext testDb = new TestDbContext()) @@ -47,19 +48,25 @@ namespace asg_form.Controllers game.belong = req.belong; game.tag=req.tag; game.judge = req.judge; + wp = 1; game.commentary = req.commentary; if(req.comLimit != null) game.com_limit = req.comLimit; else game.com_limit = 2; + wp = 2; game.person_type = req.personType; + wp = 3; await testDb.SaveChangesAsync(); return Ok(new { code = 200, message = "加入成功" }); } - }catch (Exception ex) - { - return Ok(new { code = 500, message = "服务器错误", details = ex.Message }); } - + catch (Exception ex) + { + var innerException = ex.InnerException ?? ex; // 如果没有 InnerException,使用 ex 本身 + // 记录错误信息 + return Ok(new { code = 500, message = "服务器错误", details = innerException.Message }); + } + } return Ok(new error_mb { code = 401, message = "无权访问" }); @@ -93,7 +100,7 @@ namespace asg_form.Controllers using (TestDbContext testDb = new TestDbContext()) { wp = 0; - testDb.team_Games.Add(new team_game + var ins = new team_game { team1_name = req.team1_name, team2_name = req.team2_name, @@ -107,17 +114,23 @@ namespace asg_form.Controllers judge = req.judge, com_limit = req.comLimit, person_type = req.personType, - }); - wp = 1; + }; + + wp = 1; + testDb.team_Games.Add(ins); await testDb.SaveChangesAsync(); return Ok(new { code = 200, message = "加入成功" }); } - }catch (Exception ex) - { - return Ok(new { code = 500, message = "服务器错误", details = ex.Message,wp }); } - + catch (Exception ex) + { + var innerException = ex.InnerException ?? ex; // 如果没有 InnerException,使用 ex 本身 + // 记录错误信息 + return Ok(new { code = 500, message = "服务器错误", details = innerException.Message, wp }); + } + + } return BadRequest(new error_mb { code = 401, message = "无权访问" }); @@ -323,7 +336,7 @@ namespace asg_form.Controllers public int team1_piaoshu { get; set; } public string team2_name { get; set; } public int team2_piaoshu { get; set; } - public DateTime opentime { get; set; } + public string opentime { get; set; } /// /// 解说的名字,用逗号隔开!!!!!!! /// @@ -353,7 +366,7 @@ namespace asg_form.Controllers { public string team1_name { get; set; } public string team2_name { get; set; } - public DateTime opentime { get; set; } + public string opentime { get; set; } /// /// 解说的名字,用逗号隔开!!!!!!! diff --git a/asg_form/qqbot.cs b/asg_form/qqbot.cs index 515d34d..71d3dda 100644 --- a/asg_form/qqbot.cs +++ b/asg_form/qqbot.cs @@ -79,12 +79,13 @@ namespace asg_form { TestDbContext testDb = new TestDbContext(); int q = testDb.team_Games.Count(); - var a = testDb.team_Games.Where(a => a.opentime >= DateTime.Now).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("f")}"; - } + 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;