This commit is contained in:
王炜翔 2024-10-19 13:45:13 +08:00
parent 0d369e426f
commit cc7ad7c7a5
2 changed files with 17 additions and 7 deletions

View File

@ -67,7 +67,7 @@ namespace asg_form.Controllers
string Invitorid = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value; string Invitorid = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
var user = await userManager.FindByIdAsync(Invitorid); var user = await userManager.FindByIdAsync(Invitorid);
long userId = user.Id; long userId = user.Id;
if (user.officium != "Commentator" || !this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "nbadmin")) return Ok(new error_mb { code = 401, message = "您不是解说无法完成邀请" }); if (user.officium != "Commentator" ) return Ok(new error_mb { code = 401, message = "您不是解说无法完成邀请" });
using (TestDbContext sb = new TestDbContext()) using (TestDbContext sb = new TestDbContext())
{ {
try try

View File

@ -42,13 +42,15 @@ namespace asg_form.Controllers
game.team1_name = req.team1_name; game.team1_name = req.team1_name;
game.team2_name = req.team2_name; game.team2_name = req.team2_name;
game.opentime = req.opentime; game.opentime = req.opentime;
game.commentary = req.commentary;
game.bilibiliuri = req.bilibiliuri; game.bilibiliuri = req.bilibiliuri;
game.referee = req.referee; game.referee = req.referee;
game.belong = req.belong; game.belong = req.belong;
game.tag=req.tag; game.tag=req.tag;
game.judge = req.judge; game.judge = req.judge;
game.commentary = req.commentary; game.commentary = req.commentary;
if(req.comLimit != null)
game.com_limit = req.comLimit;
else game.com_limit = 2;
game.person_type = req.personType; game.person_type = req.personType;
await testDb.SaveChangesAsync(); await testDb.SaveChangesAsync();
return Ok(new { code = 200, message = "加入成功" }); return Ok(new { code = 200, message = "加入成功" });
@ -85,10 +87,12 @@ namespace asg_form.Controllers
bool a = await userManager.IsInRoleAsync(user, "admin"); bool a = await userManager.IsInRoleAsync(user, "admin");
if (a) if (a)
{ {
int wp = -1;
try try
{ {
using (TestDbContext testDb = new TestDbContext()) using (TestDbContext testDb = new TestDbContext())
{ { wp = 0;
testDb.team_Games.Add(new team_game testDb.team_Games.Add(new team_game
{ {
team1_name = req.team1_name, team1_name = req.team1_name,
@ -104,13 +108,14 @@ namespace asg_form.Controllers
com_limit = req.comLimit, com_limit = req.comLimit,
person_type = req.personType, person_type = req.personType,
}); });
wp = 1;
await testDb.SaveChangesAsync(); await testDb.SaveChangesAsync();
return Ok(new { code = 200, message = "加入成功" }); return Ok(new { code = 200, message = "加入成功" });
} }
}catch (Exception ex) }catch (Exception ex)
{ {
return Ok(new { code = 500, message = "服务器错误", details = ex.Message }); return Ok(new { code = 500, message = "服务器错误", details = ex.Message,wp });
} }
} }
@ -181,12 +186,17 @@ namespace asg_form.Controllers
TestDbContext testDb = new TestDbContext(); TestDbContext testDb = new TestDbContext();
team_game game = testDb.team_Games.Include(a => a.logs).First(a => a.id == gameid); team_game game = testDb.team_Games.Include(a => a.logs).First(a => a.id == gameid);
testDb.team_Games.Remove(game); testDb.team_Games.Remove(game);
var query = testDb.T_Invitation.Where(n => n.match_id == gameid).ToList();
if (query.Any())
{
testDb.T_Invitation.RemoveRange(query);
}
await testDb.SaveChangesAsync(); await testDb.SaveChangesAsync();
return "ok"; return Ok(new error_mb { code = 200, message = "成功删除" });
} }
else else
{ {
return BadRequest(new error_mb { code = 400, message = "无权访问" }); return Ok(new error_mb { code = 401, message = "无权访问" });
} }
@ -357,7 +367,7 @@ namespace asg_form.Controllers
public Uri? bilibiliuri { get; set;} public Uri? bilibiliuri { get; set;}
public string tag { get; set; } public string tag { get; set; }
public string? judge { get; set; } public string? judge { get; set; }
public int comLimit { get; set; } public int comLimit { get; set; } = 2;
public string? personType { get; set; } public string? personType { get; set; }
} }