2024-08-03 20:40:34 +08:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using static asg_form.blog;
|
|
|
|
|
using System.Security.Claims;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using NPOI.OpenXmlFormats.Spreadsheet;
|
|
|
|
|
using Castle.Components.DictionaryAdapter;
|
2024-10-10 16:08:18 +08:00
|
|
|
|
using Flandre.Core.Messaging;
|
2024-10-24 09:30:56 +08:00
|
|
|
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
|
2024-10-26 17:45:16 +08:00
|
|
|
|
using Flandre.Core.Common;
|
|
|
|
|
using Flandre.Core.Messaging.Segments;
|
|
|
|
|
using static asg_form.Controllers.InviteReferee;
|
|
|
|
|
using Mirai.Net.Data.Shared;
|
2024-08-03 20:40:34 +08:00
|
|
|
|
|
|
|
|
|
namespace asg_form.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class schedule:ControllerBase
|
|
|
|
|
{
|
|
|
|
|
private readonly RoleManager<Role> roleManager;
|
|
|
|
|
private readonly UserManager<User> userManager;
|
|
|
|
|
public schedule(
|
|
|
|
|
RoleManager<Role> roleManager, UserManager<User> userManager)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
this.roleManager = roleManager;
|
|
|
|
|
this.userManager = userManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Authorize]
|
|
|
|
|
[Route("api/v1/admin/game")]
|
|
|
|
|
[HttpPut]
|
2024-10-24 09:30:56 +08:00
|
|
|
|
public async Task<ActionResult<object>> gameput(long gameid,[FromBody] req_team_game req)
|
2024-08-03 20:40:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
|
|
|
|
var user = await userManager.FindByIdAsync(id);
|
|
|
|
|
|
|
|
|
|
bool a = await userManager.IsInRoleAsync(user, "admin");
|
|
|
|
|
if (a)
|
|
|
|
|
{
|
2024-10-22 22:27:56 +08:00
|
|
|
|
int wp = -1;
|
2024-10-10 16:08:18 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (TestDbContext testDb = new TestDbContext())
|
|
|
|
|
{
|
|
|
|
|
var game = await testDb.team_Games.FirstOrDefaultAsync(a => a.id == gameid);
|
|
|
|
|
game.team1_name = req.team1_name;
|
2024-11-03 00:38:59 +08:00
|
|
|
|
game.judge_Id = req.judge_Id;
|
|
|
|
|
game.referee_Id = req.referee_Id;
|
|
|
|
|
game.Remarks = req.Remarks;
|
2024-10-10 16:08:18 +08:00
|
|
|
|
game.team2_name = req.team2_name;
|
|
|
|
|
game.opentime = req.opentime;
|
|
|
|
|
game.bilibiliuri = req.bilibiliuri;
|
|
|
|
|
game.referee = req.referee;
|
|
|
|
|
game.belong = req.belong;
|
|
|
|
|
game.tag=req.tag;
|
2024-10-18 19:54:00 +08:00
|
|
|
|
game.judge = req.judge;
|
2024-10-22 22:27:56 +08:00
|
|
|
|
wp = 1;
|
2024-10-18 19:54:00 +08:00
|
|
|
|
game.commentary = req.commentary;
|
2024-10-19 13:45:13 +08:00
|
|
|
|
if(req.comLimit != null)
|
|
|
|
|
game.com_limit = req.comLimit;
|
|
|
|
|
else game.com_limit = 2;
|
2024-10-22 22:27:56 +08:00
|
|
|
|
wp = 2;
|
2024-10-18 19:54:00 +08:00
|
|
|
|
game.person_type = req.personType;
|
2024-10-22 22:27:56 +08:00
|
|
|
|
wp = 3;
|
2024-10-10 16:08:18 +08:00
|
|
|
|
await testDb.SaveChangesAsync();
|
|
|
|
|
return Ok(new { code = 200, message = "加入成功" });
|
|
|
|
|
}
|
2024-10-22 22:27:56 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
2024-10-10 16:08:18 +08:00
|
|
|
|
{
|
2024-10-22 22:27:56 +08:00
|
|
|
|
var innerException = ex.InnerException ?? ex; // 如果没有 InnerException,使用 ex 本身
|
|
|
|
|
// 记录错误信息
|
|
|
|
|
return Ok(new { code = 500, message = "服务器错误", details = innerException.Message });
|
2024-10-10 16:08:18 +08:00
|
|
|
|
}
|
2024-10-22 22:27:56 +08:00
|
|
|
|
|
2024-08-03 20:40:34 +08:00
|
|
|
|
}
|
2024-10-10 16:08:18 +08:00
|
|
|
|
return Ok(new error_mb { code = 401, message = "无权访问" });
|
2024-08-03 20:40:34 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 发布一个竞猜比赛
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[Authorize]
|
|
|
|
|
[Route("api/v1/admin/game")]
|
|
|
|
|
[HttpPost]
|
2024-10-24 09:30:56 +08:00
|
|
|
|
public async Task<ActionResult<object>> gamepost([FromBody] req_team_game req)
|
2024-08-03 20:40:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
|
|
|
|
var user = await userManager.FindByIdAsync(id);
|
|
|
|
|
|
|
|
|
|
bool a = await userManager.IsInRoleAsync(user, "admin");
|
|
|
|
|
if (a)
|
|
|
|
|
{
|
2024-10-19 13:45:13 +08:00
|
|
|
|
int wp = -1;
|
2024-10-10 16:08:18 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
2024-10-19 13:45:13 +08:00
|
|
|
|
|
2024-10-10 16:08:18 +08:00
|
|
|
|
using (TestDbContext testDb = new TestDbContext())
|
2024-10-19 13:45:13 +08:00
|
|
|
|
{ wp = 0;
|
2024-10-22 22:27:56 +08:00
|
|
|
|
var ins = new team_game
|
2024-10-10 16:08:18 +08:00
|
|
|
|
{
|
|
|
|
|
team1_name = req.team1_name,
|
|
|
|
|
team2_name = req.team2_name,
|
|
|
|
|
opentime = req.opentime,
|
|
|
|
|
team1_piaoshu = 0,
|
|
|
|
|
team2_piaoshu = 0,
|
|
|
|
|
commentary = req.commentary,
|
|
|
|
|
referee = req.referee,
|
|
|
|
|
belong = req.belong,
|
2024-10-18 19:54:00 +08:00
|
|
|
|
tag = req.tag,
|
|
|
|
|
judge = req.judge,
|
2024-11-03 00:38:59 +08:00
|
|
|
|
judge_Id= req.judge_Id,
|
|
|
|
|
referee_Id= req.referee_Id,
|
|
|
|
|
Remarks= req.Remarks,
|
2024-10-18 19:54:00 +08:00
|
|
|
|
com_limit = req.comLimit,
|
|
|
|
|
person_type = req.personType,
|
2024-10-22 22:27:56 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
wp = 1;
|
2024-10-24 09:30:56 +08:00
|
|
|
|
await testDb.team_Games.AddAsync(ins);
|
|
|
|
|
await testDb.SaveChangesAsync();
|
2024-10-10 16:08:18 +08:00
|
|
|
|
}
|
2024-10-24 09:30:56 +08:00
|
|
|
|
return Ok(new { code = 200, message = "加入成功" });
|
2024-10-10 16:08:18 +08:00
|
|
|
|
|
2024-10-22 22:27:56 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
2024-10-10 16:08:18 +08:00
|
|
|
|
{
|
2024-10-22 22:27:56 +08:00
|
|
|
|
var innerException = ex.InnerException ?? ex; // 如果没有 InnerException,使用 ex 本身
|
|
|
|
|
// 记录错误信息
|
|
|
|
|
return Ok(new { code = 500, message = "服务器错误", details = innerException.Message, wp });
|
2024-10-10 16:08:18 +08:00
|
|
|
|
}
|
2024-10-22 22:27:56 +08:00
|
|
|
|
|
|
|
|
|
|
2024-08-03 20:40:34 +08:00
|
|
|
|
}
|
2024-10-10 16:08:18 +08:00
|
|
|
|
return BadRequest(new error_mb { code = 401, message = "无权访问" });
|
2024-08-03 20:40:34 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 发布胜利者
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="teamid"></param>
|
|
|
|
|
/// <param name="winteam"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[Authorize]
|
|
|
|
|
[Route("api/v1/admin/game/win")]
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public async Task<ActionResult<string>> gamepost(long teamid,string winteam)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
|
|
|
|
var user = await userManager.FindByIdAsync(id);
|
|
|
|
|
|
|
|
|
|
bool a = await userManager.IsInRoleAsync(user, "admin");
|
|
|
|
|
if (a)
|
|
|
|
|
{
|
|
|
|
|
TestDbContext testDb = new TestDbContext();
|
|
|
|
|
team_game game=testDb.team_Games.Include(a=>a.logs).First(a=>a.id==teamid);
|
|
|
|
|
game.winteam = winteam;
|
|
|
|
|
foreach(var log in game.logs)
|
|
|
|
|
{
|
|
|
|
|
if (log.chickteam == winteam)
|
|
|
|
|
{
|
|
|
|
|
log.win = true;
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
log.win = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await testDb.SaveChangesAsync();
|
2024-10-26 17:45:16 +08:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var message1 = new MessageBuilder().Image(GetPictureData($@"{AppDomain.CurrentDomain.BaseDirectory}loge\{game.belong}\{winteam}.png")).Text($"恭喜战队{winteam}获胜!").Build();
|
|
|
|
|
await runbot.runbotr.SendMessageAsync(MessageEnvironment.Channel, "456414070", null, message1, "456414070");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
var message1 = new MessageBuilder().Text($"恭喜战队{winteam}获胜!").Build();
|
|
|
|
|
await runbot.runbotr.SendMessageAsync(MessageEnvironment.Channel, "456414070", null, message1, "456414070");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-03 20:40:34 +08:00
|
|
|
|
return "ok";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-10-18 19:54:00 +08:00
|
|
|
|
return Ok(new error_mb { code = 401, message = "无权访问" });
|
2024-08-03 20:40:34 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2024-10-26 17:45:16 +08:00
|
|
|
|
public byte[] GetPictureData(string imagePath)
|
|
|
|
|
{
|
|
|
|
|
FileStream fs = new FileStream(imagePath, FileMode.Open);
|
|
|
|
|
byte[] byteData = new byte[fs.Length];
|
|
|
|
|
fs.Read(byteData, 0, byteData.Length);
|
|
|
|
|
fs.Close();
|
|
|
|
|
return byteData;
|
|
|
|
|
}
|
2024-08-03 20:40:34 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除竞猜比赛
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="gameid"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[Authorize]
|
|
|
|
|
[Route("api/v1/admin/game")]
|
|
|
|
|
[HttpDelete]
|
|
|
|
|
public async Task<ActionResult<string>> gamepush(int gameid)
|
|
|
|
|
{
|
|
|
|
|
string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
|
|
|
|
var user = await userManager.FindByIdAsync(id);
|
|
|
|
|
|
|
|
|
|
bool a = await userManager.IsInRoleAsync(user, "admin");
|
|
|
|
|
if (a)
|
|
|
|
|
{
|
|
|
|
|
TestDbContext testDb = new TestDbContext();
|
|
|
|
|
team_game game = testDb.team_Games.Include(a => a.logs).First(a => a.id == gameid);
|
|
|
|
|
testDb.team_Games.Remove(game);
|
2024-10-19 13:45:13 +08:00
|
|
|
|
var query = testDb.T_Invitation.Where(n => n.match_id == gameid).ToList();
|
|
|
|
|
if (query.Any())
|
|
|
|
|
{
|
|
|
|
|
testDb.T_Invitation.RemoveRange(query);
|
|
|
|
|
}
|
2024-08-03 20:40:34 +08:00
|
|
|
|
await testDb.SaveChangesAsync();
|
2024-10-19 13:45:13 +08:00
|
|
|
|
return Ok(new error_mb { code = 200, message = "成功删除" });
|
2024-08-03 20:40:34 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-10-19 13:45:13 +08:00
|
|
|
|
return Ok(new error_mb { code = 401, message = "无权访问" });
|
2024-08-03 20:40:34 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 投票
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="gameid"></param>
|
|
|
|
|
/// <param name="teamid"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[Authorize]
|
|
|
|
|
[Route("api/v1/game/pushgame")]
|
|
|
|
|
[HttpPut]
|
|
|
|
|
public async Task<ActionResult<string>> gamepush(int gameid,int teamid)
|
|
|
|
|
{
|
2024-10-23 11:24:16 +08:00
|
|
|
|
int wp = -1;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
wp = 0;
|
2024-08-03 20:40:34 +08:00
|
|
|
|
string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
|
|
|
|
TestDbContext test =new TestDbContext();
|
|
|
|
|
var team = test.team_Games.Include(a=>a.logs).Single(a=>a.id==gameid);
|
|
|
|
|
bool isckick = team.logs.Any(a => a.userid == id);
|
|
|
|
|
if (isckick)
|
|
|
|
|
{
|
|
|
|
|
return BadRequest(new error_mb { code = 400, message = "不要重复投票" });
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
2024-10-23 11:24:16 +08:00
|
|
|
|
{
|
2024-08-03 20:40:34 +08:00
|
|
|
|
if (teamid == 1)
|
|
|
|
|
{
|
|
|
|
|
team.team1_piaoshu++;
|
|
|
|
|
team.logs.Add(new schedule_log { userid= id ,chickteam=team.team1_name,team=team,win= null });
|
|
|
|
|
}
|
|
|
|
|
else if(teamid == 2)
|
|
|
|
|
{
|
|
|
|
|
team.team2_piaoshu++;
|
|
|
|
|
team.logs.Add(new schedule_log { userid = id, chickteam = team.team2_name, team = team,win=null });
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return BadRequest(new error_mb { code = 400, message = "队伍id不合法" });
|
|
|
|
|
|
|
|
|
|
}
|
2024-10-23 11:24:16 +08:00
|
|
|
|
wp = 1;
|
2024-08-03 20:40:34 +08:00
|
|
|
|
await test.SaveChangesAsync();
|
2024-10-23 11:24:16 +08:00
|
|
|
|
wp = 2;
|
|
|
|
|
return Ok(new { code = 200, message = "投票成功" });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
var innerException = ex.InnerException ?? ex; // 如果没有 InnerException,使用 ex 本身
|
|
|
|
|
// 记录错误信息
|
|
|
|
|
return Ok(new { code = 500, message = "服务器错误", details = innerException.Message, wp });
|
2024-08-03 20:40:34 +08:00
|
|
|
|
}
|
2024-10-23 11:24:16 +08:00
|
|
|
|
|
2024-08-03 20:40:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获得所有比赛
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[Route("api/v1/game/")]
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public async Task<ActionResult<List<team_game>>> gameall(int page,int page_long,string belong="all")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
TestDbContext test = new TestDbContext();
|
|
|
|
|
|
|
|
|
|
int c = test.Forms.Count();
|
|
|
|
|
int b = page_long * page;
|
|
|
|
|
if (page_long * page > c)
|
|
|
|
|
{
|
|
|
|
|
b = c;
|
|
|
|
|
}
|
|
|
|
|
List<team_game> team = new List<team_game>();
|
|
|
|
|
if(belong=="all")
|
|
|
|
|
{
|
|
|
|
|
team = test.team_Games.OrderByDescending(a => a.opentime).Skip(page_long * page - page_long).Take(page_long).ToList();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
team = test.team_Games.Where(a => a.belong == belong).OrderByDescending(a => a.opentime).Skip(page_long * page - page_long).Take(page_long).ToList();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return team;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-07 14:33:50 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获得所有比赛(new)
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Route("api/v2/game/")]
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public async Task<ActionResult<object>> allGames(int page, int limit,string teamName1="null",string teamName2 = "null", string belong = "null")
|
|
|
|
|
{
|
|
|
|
|
TestDbContext db = new TestDbContext();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var query = db.team_Games.AsQueryable();
|
|
|
|
|
var total = query.Where(n => (belong == "null" || n.belong == belong) && (teamName1 == "null" || n.team1_name.Contains(teamName1)) && (teamName2 == "null" || n.team2_name.Contains(teamName2))).Count();
|
2024-11-07 16:31:07 +08:00
|
|
|
|
var rows = await query
|
2024-11-07 14:33:50 +08:00
|
|
|
|
.OrderByDescending(a => a.opentime)
|
|
|
|
|
.Where(n => (belong=="null" || n.belong==belong) && (teamName1=="null"||n.team1_name.Contains(teamName1)) && (teamName2 == "null" || n.team2_name.Contains(teamName2)))
|
|
|
|
|
.Skip((page - 1) * limit)
|
|
|
|
|
.Take(limit)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
var data = new
|
|
|
|
|
{
|
2024-11-07 16:31:07 +08:00
|
|
|
|
rows,
|
2024-11-07 14:33:50 +08:00
|
|
|
|
total,
|
|
|
|
|
};
|
|
|
|
|
return Ok(new { code = 200, message = "", data });
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return Ok(new { code = 500, message = "服务器错误", ex });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-03 20:40:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取我的竞猜
|
|
|
|
|
/// </summary>
|
2024-12-07 23:57:41 +08:00
|
|
|
|
/// <param name="page">当前页数,默认为1</param>
|
|
|
|
|
/// <param name="pageSize">每页显示的记录数,默认为5</param>
|
2024-08-03 20:40:34 +08:00
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[Authorize]
|
|
|
|
|
[Route("api/v1/game/mylog")]
|
|
|
|
|
[HttpGet]
|
2024-12-07 23:57:41 +08:00
|
|
|
|
public async Task<ActionResult<PagedResult<schedule_log>>> MyLog(int page = 1, int pageSize = 5)
|
2024-08-03 20:40:34 +08:00
|
|
|
|
{
|
|
|
|
|
string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
2024-12-07 23:57:41 +08:00
|
|
|
|
using (var _context = new TestDbContext())
|
2024-08-03 20:40:34 +08:00
|
|
|
|
{
|
2024-11-11 21:54:32 +08:00
|
|
|
|
|
2024-12-07 23:57:41 +08:00
|
|
|
|
// 查询数据并按时间倒序排列
|
|
|
|
|
var query = _context.schlogs
|
|
|
|
|
.Include(a => a.team)
|
|
|
|
|
.Where(a => a.userid == id)
|
|
|
|
|
.OrderByDescending(a => a.Id);
|
|
|
|
|
|
|
|
|
|
// 计算总记录数
|
|
|
|
|
int totalItems = await query.CountAsync();
|
|
|
|
|
|
|
|
|
|
// 分页查询数据
|
|
|
|
|
var data = await query
|
|
|
|
|
.Skip((page - 1) * pageSize)
|
|
|
|
|
.Take(pageSize)
|
|
|
|
|
.ToListAsync();
|
2024-08-03 20:40:34 +08:00
|
|
|
|
|
2024-12-07 23:57:41 +08:00
|
|
|
|
// 清除不必要的导航属性
|
|
|
|
|
foreach (var log in data)
|
|
|
|
|
{
|
|
|
|
|
log.team.logs = null;
|
|
|
|
|
}
|
2024-08-03 20:40:34 +08:00
|
|
|
|
|
2024-12-07 23:57:41 +08:00
|
|
|
|
// 返回分页结果
|
|
|
|
|
return new PagedResult<schedule_log>
|
|
|
|
|
{
|
|
|
|
|
Data = data,
|
|
|
|
|
Page = page,
|
|
|
|
|
PageSize = pageSize,
|
|
|
|
|
TotalItems = totalItems,
|
|
|
|
|
TotalPages = (int)Math.Ceiling(totalItems / (double)pageSize)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-03 20:40:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-07 23:57:41 +08:00
|
|
|
|
|
2024-10-24 09:30:56 +08:00
|
|
|
|
[Authorize]
|
|
|
|
|
[Route("api/v1/game/final")]
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public async Task<ActionResult<object>> finSc(long gameid,FinalScore msg)
|
|
|
|
|
{
|
|
|
|
|
using(var db = new TestDbContext())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var query = db.team_Games.FirstOrDefault(n => n.id == gameid);
|
|
|
|
|
if (query == null) return Ok(new { code = 404, message = "未找到比赛" });
|
|
|
|
|
query.final_score = msg.finalScore;
|
|
|
|
|
await db.SaveChangesAsync();
|
|
|
|
|
return Ok(new { code = 200, message = "结果已存入" });
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
var innerException = ex.InnerException ?? ex; // 如果没有 InnerException,使用 ex 本身
|
|
|
|
|
// 记录错误信息
|
|
|
|
|
return Ok(new { code = 500, message = "服务器错误", details = innerException.Message});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-03 20:40:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class schedule_log
|
|
|
|
|
{
|
|
|
|
|
public long Id { get; set; }
|
|
|
|
|
public string userid { get; set; }
|
|
|
|
|
public team_game team { get; set; }
|
|
|
|
|
public string chickteam { get; set; }
|
|
|
|
|
public bool? win { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class team_game
|
|
|
|
|
{
|
|
|
|
|
public long id { get; set; }
|
|
|
|
|
|
|
|
|
|
public string team1_name { get; set; }
|
|
|
|
|
public int team1_piaoshu { get; set; }
|
|
|
|
|
public string team2_name { get; set; }
|
|
|
|
|
public int team2_piaoshu { get; set; }
|
2024-10-22 22:27:56 +08:00
|
|
|
|
public string opentime { get; set; }
|
2024-08-03 20:40:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 解说的名字,用逗号隔开!!!!!!!
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string commentary { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 裁判的名字
|
|
|
|
|
/// </summary>
|
2024-11-06 22:51:29 +08:00
|
|
|
|
public string? referee { get; set; }
|
2024-11-03 00:08:34 +08:00
|
|
|
|
public int? referee_Id { get; set; }
|
2024-08-03 20:40:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// bilibili录屏路径
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Uri? bilibiliuri { get; set; }
|
|
|
|
|
public string? winteam { get; set; }
|
|
|
|
|
public string? tag { get; set; }
|
|
|
|
|
public string? belong { get; set; }
|
|
|
|
|
public List<schedule_log> logs { get; set; } = new List<schedule_log>();
|
|
|
|
|
|
2024-10-18 19:54:00 +08:00
|
|
|
|
public string? judge { get; set; }
|
2024-11-03 00:08:34 +08:00
|
|
|
|
|
|
|
|
|
public int? judge_Id { get; set; }
|
2024-10-18 19:54:00 +08:00
|
|
|
|
public int com_limit { get; set; } = 2;
|
|
|
|
|
public string? person_type { get; set; }
|
2024-10-24 09:30:56 +08:00
|
|
|
|
public string? final_score { get; set; }
|
2024-11-03 00:38:59 +08:00
|
|
|
|
public string? Remarks { get; set; }
|
2024-08-03 20:40:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class req_team_game
|
|
|
|
|
{
|
2024-11-03 00:38:59 +08:00
|
|
|
|
public int? referee_Id { get; set; }
|
|
|
|
|
|
|
|
|
|
public int? judge_Id { get; set; }
|
|
|
|
|
|
|
|
|
|
public string? Remarks { get; set; }
|
2024-08-03 20:40:34 +08:00
|
|
|
|
public string team1_name { get; set; }
|
|
|
|
|
public string team2_name { get; set; }
|
2024-10-22 22:27:56 +08:00
|
|
|
|
public string opentime { get; set; }
|
2024-08-03 20:40:34 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 解说的名字,用逗号隔开!!!!!!!
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string commentary { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 裁判的名字
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string referee { get; set; }
|
|
|
|
|
public string? belong { get; set; }
|
|
|
|
|
public Uri? bilibiliuri { get; set;}
|
|
|
|
|
public string tag { get; set; }
|
2024-10-18 19:54:00 +08:00
|
|
|
|
public string? judge { get; set; }
|
2024-10-19 13:45:13 +08:00
|
|
|
|
public int comLimit { get; set; } = 2;
|
2024-10-18 19:54:00 +08:00
|
|
|
|
public string? personType { get; set; }
|
2024-08-03 20:40:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-10-24 09:30:56 +08:00
|
|
|
|
public class FinalScore
|
|
|
|
|
{
|
|
|
|
|
public string finalScore { get; set; }
|
|
|
|
|
}
|
2024-08-03 20:40:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-24 09:30:56 +08:00
|
|
|
|
}
|
2024-08-03 20:40:34 +08:00
|
|
|
|
|