2.16的三个问题

This commit is contained in:
王炜翔 2025-02-16 22:23:54 +08:00
parent 5a66aa6af8
commit 6be74d6921
3 changed files with 12 additions and 8 deletions

View File

@ -216,7 +216,7 @@ namespace asg_form.Controllers
var invitor = await userManager.Users.FirstOrDefaultAsync(u => u.Id == record.user_id); var invitor = await userManager.Users.FirstOrDefaultAsync(u => u.Id == record.user_id);
var theGame = sub.team_Games.FirstOrDefault(i => i.id == record.match_id); var theGame = sub.team_Games.FirstOrDefault(i => i.id == record.match_id);
if (invitor == null) return Ok(new { code = 200, message = "被邀请者不存在了" }); 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 var addData = new BeInviteForUsers
{ {
id = record.id, id = record.id,

View File

@ -42,17 +42,21 @@ namespace asg_form.Controllers.Store
[Route("api/v1/admin/Store")] [Route("api/v1/admin/Store")]
[HttpDelete] [HttpDelete]
[Authorize] [Authorize]
public async Task<ActionResult<object>> DelStore(long id) public async Task<ActionResult<object>> DelStore(string id)
{ {
if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
{ {
return BadRequest(new error_mb { code = 400, message = "无权访问" }); return BadRequest(new error_mb { code = 400, message = "无权访问" });
} }
using (TestDbContext sb = new TestDbContext()) using (TestDbContext sb = new TestDbContext()) {
var commondity = sb.T_Store.FirstOrDefault(n => n.id.ToString() == id);
if (commondity == null)
{ {
sb.T_Store.Remove(sb.T_Store.Find(id)); return Ok(new error_mb { code = 500, message = "商品不存在" });
}
sb.T_Store.Remove(commondity);
await sb.SaveChangesAsync(); await sb.SaveChangesAsync();
return Ok("ok"); return Ok(new error_mb { code = 200, message = "商品已移除" });
} }
} }
[Route("api/v1/admin/Store")] [Route("api/v1/admin/Store")]

View File

@ -143,7 +143,7 @@ namespace asg_form.Controllers {
catch catch
{ {
return Ok(new error_mb { code = 200, message = "机器人错误" }); return Ok(new error_mb { code = 500, message = "机器人错误" });
} }
} }
else else
@ -198,7 +198,7 @@ namespace asg_form.Controllers {
catch catch
{ {
return Ok(new error_mb { code = 200, message = "机器人错误" }); return Ok(new error_mb { code = 500, message = "机器人错误" });
} }
} }
} }