From 6be74d6921907b8aff0cab9972ca2af35a50d3a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=82=9C=E7=BF=94?= <2307953404@qq.com> Date: Sun, 16 Feb 2025 22:23:54 +0800 Subject: [PATCH] =?UTF-8?q?2.16=E7=9A=84=E4=B8=89=E4=B8=AA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- asg_form/Controllers/InviteReferee.cs | 2 +- asg_form/Controllers/Store/Storehttp.cs | 14 +++++++++----- asg_form/Controllers/auditAndFilingController.cs | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/asg_form/Controllers/InviteReferee.cs b/asg_form/Controllers/InviteReferee.cs index f7ba24a..50af14a 100644 --- a/asg_form/Controllers/InviteReferee.cs +++ b/asg_form/Controllers/InviteReferee.cs @@ -216,7 +216,7 @@ namespace asg_form.Controllers var invitor = await userManager.Users.FirstOrDefaultAsync(u => u.Id == record.user_id); var theGame = sub.team_Games.FirstOrDefault(i => i.id == record.match_id); if (invitor == null) return Ok(new { code = 200, message = "被邀请者不存在了" }); - if (theGame.belong == null) return Ok(new { code = 200, message = "没有比赛资料" }); + if (theGame==null || theGame.belong == null) return Ok(new { code = 500, message = "没有比赛资料" }); var addData = new BeInviteForUsers { id = record.id, diff --git a/asg_form/Controllers/Store/Storehttp.cs b/asg_form/Controllers/Store/Storehttp.cs index c27ce0a..605a38e 100644 --- a/asg_form/Controllers/Store/Storehttp.cs +++ b/asg_form/Controllers/Store/Storehttp.cs @@ -42,17 +42,21 @@ namespace asg_form.Controllers.Store [Route("api/v1/admin/Store")] [HttpDelete] [Authorize] - public async Task> DelStore(long id) + public async Task> DelStore(string id) { if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) { return BadRequest(new error_mb { code = 400, message = "无权访问" }); } - using (TestDbContext sb = new TestDbContext()) - { - sb.T_Store.Remove(sb.T_Store.Find(id)); + using (TestDbContext sb = new TestDbContext()) { + var commondity = sb.T_Store.FirstOrDefault(n => n.id.ToString() == id); + if (commondity == null) + { + return Ok(new error_mb { code = 500, message = "商品不存在" }); + } + sb.T_Store.Remove(commondity); await sb.SaveChangesAsync(); - return Ok("ok"); + return Ok(new error_mb { code = 200, message = "商品已移除" }); } } [Route("api/v1/admin/Store")] diff --git a/asg_form/Controllers/auditAndFilingController.cs b/asg_form/Controllers/auditAndFilingController.cs index 123391a..3aaff4f 100644 --- a/asg_form/Controllers/auditAndFilingController.cs +++ b/asg_form/Controllers/auditAndFilingController.cs @@ -143,7 +143,7 @@ namespace asg_form.Controllers { catch { - return Ok(new error_mb { code = 200, message = "机器人错误" }); + return Ok(new error_mb { code = 500, message = "机器人错误" }); } } else @@ -198,7 +198,7 @@ namespace asg_form.Controllers { catch { - return Ok(new error_mb { code = 200, message = "机器人错误" }); + return Ok(new error_mb { code = 500, message = "机器人错误" }); } } }