恢复老报名
This commit is contained in:
parent
2202dae4c6
commit
59bc8fe511
@ -2,7 +2,6 @@
|
||||
//using asg_form.Controllers.Budget;
|
||||
using asg_form.Controllers.Budget;
|
||||
using asg_form.Controllers.Store;
|
||||
using asg_form.Controllers.Team;
|
||||
using asg_form.Controllers.Teamregistration;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@ -72,6 +71,9 @@ namespace asg_form.Controllers
|
||||
}
|
||||
|
||||
|
||||
/* /// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class TeamConfig : IEntityTypeConfiguration<T_Team>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<T_Team> builder)
|
||||
@ -85,8 +87,8 @@ namespace asg_form.Controllers
|
||||
builder.HasMany<T_events>(a => a.Events).WithMany(a => a.Teams).UsingEntity(j => j.ToTable("T_Teams_Player"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}*/
|
||||
/*
|
||||
class PlayerConfig : IEntityTypeConfiguration<T_Player>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<T_Player> builder)
|
||||
@ -96,7 +98,7 @@ namespace asg_form.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class RoleConfig : IEntityTypeConfiguration<role>
|
||||
{
|
||||
@ -265,8 +267,8 @@ namespace asg_form.Controllers
|
||||
|
||||
class TestDbContext : DbContext
|
||||
{
|
||||
public DbSet<T_Team> Teams { get; set; }
|
||||
public DbSet<T_Player> Players { get; set; }
|
||||
/* public DbSet<T_Team> Teams { get; set; }
|
||||
public DbSet<T_Player> Players { get; set; }*/
|
||||
|
||||
public DbSet<form> Forms { get; set; }
|
||||
public DbSet<role> Roles { get; set; }
|
||||
|
@ -1,5 +1,4 @@
|
||||
using asg_form.Controllers.Team;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
@ -212,7 +211,7 @@ namespace asg_form.Controllers
|
||||
public string? name { get; set; }
|
||||
public bool? is_over { get; set; }
|
||||
public DateTime? opentime { get; set; }
|
||||
public List<T_Team> Teams { get; set; }=new List<T_Team>();
|
||||
|
||||
public List<form>? forms { get; set; }
|
||||
public Uri? events_rule_uri { get; set; }
|
||||
public string? promChart { get; set; }
|
||||
@ -225,7 +224,7 @@ namespace asg_form.Controllers
|
||||
public string? name { get; set; }
|
||||
public bool? is_over { get; set; }
|
||||
public DateTime? opentime { get; set; }
|
||||
public List<T_Team> Teams { get; set; } = new List<T_Team>();
|
||||
|
||||
public List<form>? forms { get; set; }
|
||||
public Uri? events_rule_uri { get; set; }
|
||||
public string? promChart { get; set; }
|
||||
|
@ -1,35 +0,0 @@
|
||||
namespace asg_form.Controllers.Team
|
||||
{
|
||||
public class T_Team
|
||||
{
|
||||
|
||||
public List<T_events> Events { get; set; }=new List<T_events>();
|
||||
public long Id { get; set; }
|
||||
public bool is_check { get; set; }
|
||||
public int piaoshu { get; set; }
|
||||
public long time { get; set; }
|
||||
public string team_name { get; set; }
|
||||
public string team_password { get; set; }
|
||||
public string team_tel { get; set; }
|
||||
public string logo_uri { get; set; }
|
||||
|
||||
// public string? belong { get; set; }
|
||||
public List<T_Player> role { get; set; } = new List<T_Player>();
|
||||
}
|
||||
public class T_Player
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
public T_Team Team { get; set; }//属于哪个队伍
|
||||
|
||||
public string role_id { get; set; } = "无";
|
||||
public string role_name { get; set; } = "无";//阵容
|
||||
public string? Game_Name { get; set; } = "未知";
|
||||
public string role_lin { get; set; }
|
||||
public string? Id_Card { get; set; } = "未知";
|
||||
public string? Common_Roles { get; set; } = "未知";
|
||||
public string? Phone_Number { get; set; } = "未知";
|
||||
public string? Id_Card_Name { get; set; } = "未知";
|
||||
public int? Historical_Ranks { get; set; } = 0;
|
||||
}
|
||||
}
|
@ -1,392 +0,0 @@
|
||||
using asg_form.Controllers.Hubs;
|
||||
using Manganese.Text;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NPOI.OpenXmlFormats.Dml;
|
||||
using System.Security.Claims;
|
||||
using static allteam1;
|
||||
using static asg_form.Controllers.menuAssignController;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
|
||||
|
||||
namespace asg_form.Controllers.Team
|
||||
{
|
||||
public class Team_http:ControllerBase
|
||||
{
|
||||
|
||||
private readonly RoleManager<Role> roleManager;
|
||||
private readonly UserManager<User> userManager;
|
||||
|
||||
private readonly IHubContext<room> hubContext;
|
||||
public Team_http(IHubContext<room> hubContext, RoleManager<Role> roleManager, UserManager<User> userManager)
|
||||
{
|
||||
this.hubContext = hubContext;
|
||||
this.roleManager = roleManager;
|
||||
this.userManager = userManager;
|
||||
}
|
||||
|
||||
[Route("api/v1/form/my")]
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<string>> Posthameform(string eventname)
|
||||
{
|
||||
long id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value.ToInt64();
|
||||
var user = await userManager.Users.FirstAsync(a=>a.Id==id);
|
||||
var team= user.myteam;
|
||||
using(TestDbContext db=new TestDbContext())
|
||||
{
|
||||
var events= await db.events.FirstAsync(a=>a.name==eventname);
|
||||
events.Teams.Add(team);
|
||||
await db.SaveChangesAsync();
|
||||
}
|
||||
return Ok("成功");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取我的表单
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Authorize]
|
||||
[Route("api/v2/user/form")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<form>> getmyform()
|
||||
{
|
||||
|
||||
string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
||||
var ouser = userManager.Users.Include(a => a.myteam.role).FirstOrDefault(a => a.Id == id.ToInt64());
|
||||
if (ouser.haveform == null)
|
||||
{
|
||||
return BadRequest(new error_mb { code = 400, message = "你没有绑定表单" });
|
||||
|
||||
}
|
||||
ouser.haveform.events.forms = null;
|
||||
foreach (var role in ouser.haveform.role)
|
||||
{
|
||||
role.form = null;
|
||||
}
|
||||
return ouser.haveform;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 提交表单 eventname留空代表创建战队
|
||||
/// </summary>
|
||||
/// <param name="imageFile"></param>
|
||||
/// <param name="for1">表单信息</param>
|
||||
/// <param name="captoken">谷歌人机验证验证码</param>
|
||||
/// <returns></returns>
|
||||
[Route("api/v3/form/")]
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<string>> PostAsync(IFormFile imageFile, [FromForm] form_get_new for1)
|
||||
{
|
||||
|
||||
using (TestDbContext ctx = new TestDbContext()) {
|
||||
string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
||||
var user = await userManager.FindByIdAsync(id);
|
||||
|
||||
|
||||
if (ctx.Teams.Include(a => a.Events).Any(e => e.team_name == for1.team_name))
|
||||
{
|
||||
return BadRequest(new error_mb { code = 400, message = "有重名队伍" });
|
||||
}
|
||||
else
|
||||
{
|
||||
if (imageFile == null || imageFile.Length == 0)
|
||||
return BadRequest("Invalid image file.");
|
||||
// 将文件保存到磁盘
|
||||
var filePath = Path.Combine(Directory.GetCurrentDirectory(), $"loge/", $"{for1.team_name}.png");
|
||||
using (var stream = new FileStream(filePath, FileMode.Create))
|
||||
{
|
||||
await imageFile.CopyToAsync(stream);
|
||||
} // 返回成功响应
|
||||
// base64toimg(for1.logo_base64, $@"{AppDomain.CurrentDomain.BaseDirectory}loge\{for1.events_name}\{for1.team_name}.png");
|
||||
|
||||
|
||||
|
||||
|
||||
T_Team form1 = new T_Team();
|
||||
form1.logo_uri = $"/loge/{for1.team_name}.png";
|
||||
form1.team_name = for1.team_name;
|
||||
form1.team_password = for1.team_password;
|
||||
form1.team_tel = for1.team_tel;
|
||||
if (for1.events_name == null)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var events = await ctx.events.FirstAsync(ctx => ctx.name == for1.events_name);
|
||||
|
||||
form1.Events.Add(events);
|
||||
}
|
||||
|
||||
List<T_Player> role = new List<T_Player>();
|
||||
foreach (role_get a in for1.role_get)
|
||||
{
|
||||
role.Add(new T_Player { role_id = a.role_id, role_lin = a.role_lin, role_name = a.role_name, Common_Roles = a.Common_Roles, Historical_Ranks = a.Historical_Ranks, Id_Card = a.Id_Card, Game_Name = a.Game_Name, Phone_Number = a.Phone_Number, Id_Card_Name = a.Id_Card_Name });
|
||||
}
|
||||
form1.role = role;
|
||||
|
||||
await ctx.Teams.AddAsync(form1);
|
||||
await ctx.SaveChangesAsync();
|
||||
user.myteam = form1;
|
||||
await userManager.UpdateAsync(user);
|
||||
// int nownumber = ctx.Forms.Count();
|
||||
//ChatRoomHub chat = new ChatRoomHub();
|
||||
// await chat.formok(nownumber, for1.team_name);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return "ok!";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获得所有表单信息
|
||||
/// </summary>
|
||||
/// <param name="page">页数</param>
|
||||
/// <param name="page_long">每页长度</param>
|
||||
/// <returns></returns>
|
||||
|
||||
[Route("api/v2/form/all")]
|
||||
[HttpGet]
|
||||
public List<team> Getform(short page, short page_long, string sort, string eventsname)
|
||||
{
|
||||
using (TestDbContext ctx = new TestDbContext())
|
||||
{
|
||||
|
||||
|
||||
int c = ctx.Teams.Count();
|
||||
int b = page_long * page;
|
||||
if (page_long * page > c)
|
||||
{
|
||||
b = c;
|
||||
}
|
||||
var events = ctx.events.First(ctx => ctx.name == eventsname);
|
||||
List<T_Team> forms;
|
||||
if (sort == "vote")
|
||||
{
|
||||
var team1 = ctx.events.Include(a => a.Teams).Select(a => new {a.name,a.Teams}).First(a=>a.name==eventsname);
|
||||
forms= team1.Teams.Where(a=>a.is_check==true).OrderByDescending(a => a.piaoshu).ToList();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//改为按照id倒序排序
|
||||
//forms = ctx.Forms.Include(a => a.role).Skip(page_long * page - page_long).Take(page_long).ToList();
|
||||
var team1 = ctx.events.Include(a => a.Teams).Select(a => new { a.name, a.Teams }).First(a => a.name == eventsname);
|
||||
forms = team1.Teams.Where(a => a.is_check == true).OrderByDescending(a => a.Id).ToList();
|
||||
|
||||
}
|
||||
List<team> teams = new List<team>();
|
||||
|
||||
|
||||
foreach (T_Team for1 in forms)
|
||||
{
|
||||
var team = new team { id = for1.Id, name = for1.team_name, timer = for1.time, piaoshu = for1.piaoshu, logo_uri = for1.logo_uri };
|
||||
|
||||
teams.Add(team);
|
||||
// a++;
|
||||
}
|
||||
return teams;
|
||||
}
|
||||
}
|
||||
|
||||
public class tmpRole
|
||||
{
|
||||
public string? roleName { get; set; }
|
||||
public int? roleRank { get; set; }
|
||||
public string? commonRoles { get; set; }
|
||||
public string? roleLin { get; set; }
|
||||
public string? roleId { get; set; }
|
||||
public string? gameName { get; set; }
|
||||
public string? idCard { get; set; }
|
||||
public string? phoneNumber { get; set; }
|
||||
public string? idCardName { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class TeamFind
|
||||
{
|
||||
|
||||
public long formId { get; set; }
|
||||
public string teamName { get; set; }
|
||||
public int voteOfLikes { get; set; }
|
||||
public List<tmpRole> roles { get; set; } = new List<tmpRole>();
|
||||
|
||||
}
|
||||
public class AdminTeamFind
|
||||
{
|
||||
public form? form { get; set; }
|
||||
public List<tmpRole>? roles { get; set; }= new List<tmpRole>();
|
||||
}
|
||||
private static List<tmpRole> findRolesByFormId(long formId,int y)
|
||||
{
|
||||
var roles = new List<tmpRole>();
|
||||
var db = new TestDbContext();
|
||||
try
|
||||
{
|
||||
var query = db.Roles.Where(x => x.form.Id == formId);
|
||||
if (y == 1)
|
||||
{
|
||||
roles = query
|
||||
.Select(f => new tmpRole
|
||||
{
|
||||
roleName = f.role_name,
|
||||
roleRank = f.Historical_Ranks,
|
||||
commonRoles = f.Common_Roles,
|
||||
roleLin = f.role_lin
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
roles = query
|
||||
.Select(f => new tmpRole
|
||||
{
|
||||
roleName = f.role_name,
|
||||
roleRank = f.Historical_Ranks,
|
||||
commonRoles = f.Common_Roles,
|
||||
roleLin = f.role_lin,
|
||||
roleId = f.role_id,
|
||||
gameName =f.Game_Name,
|
||||
idCard = f.Id_Card,
|
||||
phoneNumber = f.Phone_Number,
|
||||
idCardName = f.Id_Card_Name
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Error in BuildTree: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
[Route("api/v3/form/all")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<object>> GetFormById(short page, short limit, int sort, int eventId)
|
||||
{
|
||||
using (var db = new TestDbContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
var query = db.Forms.Where(f => f.events.Id == eventId);
|
||||
query = sort switch
|
||||
{
|
||||
0 => query.OrderByDescending(m => m.piaoshu).ThenByDescending(m => m.time),
|
||||
1 => query.OrderBy(m => m.piaoshu),
|
||||
2 => query.OrderByDescending(m => m.piaoshu),
|
||||
3 => query.OrderBy(m => m.time),
|
||||
4 => query.OrderByDescending(m => m.time),
|
||||
_ => query
|
||||
};
|
||||
if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "nbadmin")|| this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
||||
{
|
||||
try
|
||||
{
|
||||
var results = await query
|
||||
.Skip((page - 1) * limit)
|
||||
.Take(limit)
|
||||
.Select(f => new AdminTeamFind
|
||||
{
|
||||
form = f,
|
||||
roles = findRolesByFormId(f.Id,0)
|
||||
})
|
||||
.ToListAsync();
|
||||
int total = await query.CountAsync();
|
||||
|
||||
return Ok(new { code = 200, message = "成功", data = results, total });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Ok(new { code = 500, message = "服务器错误", error = ex.Message });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var results = await query
|
||||
.Skip((page - 1) * limit)
|
||||
.Take(limit)
|
||||
.Select(f => new AdminTeamFind
|
||||
{
|
||||
form = new form
|
||||
{
|
||||
Id = f.Id,
|
||||
team_name = f.team_name,
|
||||
piaoshu = f.piaoshu,
|
||||
},
|
||||
roles = findRolesByFormId(f.Id,1)
|
||||
})
|
||||
.ToListAsync();
|
||||
int total = await query.CountAsync();
|
||||
return Ok(new { code = 200, message = "成功", data = results, total });
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Ok(new { code = 500, message = "服务器错误", ex = ex.Message });
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 新的删除战队口
|
||||
/// </summary>
|
||||
[Route("api/v2/form/delete")]
|
||||
[HttpDelete]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<object>> DeleteFormById(long formId)
|
||||
{
|
||||
if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "nbadmin")|| !this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
||||
{
|
||||
return BadRequest(new error_mb { code = 400, message = "无权访问" });
|
||||
}
|
||||
using (var db = new TestDbContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var rolesToDelete = db.Roles.Where(r => r.form.Id == formId).ToList();
|
||||
if (rolesToDelete.Any())
|
||||
{
|
||||
db.Roles.RemoveRange(rolesToDelete);
|
||||
}
|
||||
|
||||
var formToDelete = await db.Forms.FindAsync(formId);
|
||||
if (formToDelete == null)
|
||||
{
|
||||
return NotFound(new { code = 404, message = "表单未找到" });
|
||||
}
|
||||
db.Forms.Remove(formToDelete);
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
return Ok(new { code = 200, message = "删除成功" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, new { code = 500, message = "服务器错误", error = ex.Message });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -742,8 +742,8 @@ namespace asg_form.Controllers
|
||||
if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
||||
{
|
||||
TestDbContext ctx = new TestDbContext();
|
||||
var form = await ctx.Teams.Include(a => a.role).FirstOrDefaultAsync(a => a.Id == formid);
|
||||
var users = await userManager.Users.Include(a => a.myteam).Where(a => a.myteam == form).ToListAsync();
|
||||
var form = await ctx.Forms.Include(a => a.role).FirstOrDefaultAsync(a => a.Id == formid);
|
||||
var users = await userManager.Users.Include(a => a.haveform).Where(a => a.haveform == form).ToListAsync();
|
||||
try
|
||||
{
|
||||
foreach (var user in users)
|
||||
@ -756,7 +756,7 @@ namespace asg_form.Controllers
|
||||
{
|
||||
}
|
||||
|
||||
ctx.Teams.Remove(form); ;
|
||||
ctx.Forms.Remove(form); ;
|
||||
await ctx.SaveChangesAsync();
|
||||
logger.Warn($"管理员删除了表单{formid},参赛选手:{string.Join(',', form.role.Select(a => a.role_name))}");
|
||||
return Ok("删除成功!");
|
||||
|
@ -1,4 +1,3 @@
|
||||
using asg_form.Controllers.Team;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -36,7 +35,7 @@ namespace asg_form.Controllers
|
||||
|
||||
|
||||
|
||||
public static void ExportToExcel_noadmin(List<T_Team> data, string fileName)
|
||||
public static void ExportToExcel_noadmin(List<form> data, string fileName)
|
||||
{
|
||||
using (var package = new ExcelPackage())
|
||||
{
|
||||
@ -108,7 +107,7 @@ namespace asg_form.Controllers
|
||||
|
||||
|
||||
|
||||
public static void ExportToExcel(List<T_Team> data, string fileName)
|
||||
public static void ExportToExcel(List<form> data, string fileName)
|
||||
{
|
||||
using (var package = new ExcelPackage())
|
||||
{
|
||||
@ -342,7 +341,7 @@ namespace asg_form.Controllers
|
||||
{
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
TestDbContext testDb = new TestDbContext();
|
||||
List<T_Team> result = testDb.Teams.ToList();
|
||||
List<form> result = testDb.Forms.ToList();
|
||||
if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "nbadmin"))
|
||||
{
|
||||
|
||||
|
@ -21,7 +21,10 @@ using System.Net.Mail;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using static asg_form.Controllers.excel;
|
||||
using static 所有队伍;
|
||||
using Manganese.Array;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Flurl.Http;
|
||||
|
||||
namespace asg_form.Controllers
|
||||
{
|
||||
@ -49,7 +52,7 @@ namespace asg_form.Controllers
|
||||
}
|
||||
|
||||
// [Route("api/updateform/")]
|
||||
public class updateform1 : ControllerBase
|
||||
public class 提交表单 : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
@ -146,7 +149,10 @@ namespace asg_form.Controllers
|
||||
}
|
||||
private readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly IHubContext<room> hubContext;
|
||||
|
||||
public 提交表单(IHubContext<room> hubContext)
|
||||
{
|
||||
this.hubContext= hubContext;
|
||||
}
|
||||
|
||||
|
||||
[Route("api/v1/websocket/")]
|
||||
@ -251,11 +257,20 @@ namespace asg_form.Controllers
|
||||
/// <returns></returns>
|
||||
[Route("api/v2/form/")]
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<string>> PostAsync(IFormFile imageFile,[FromForm] form_get_new for1)
|
||||
public async Task<ActionResult<string>> PostAsync(IFormFile imageFile,[FromForm] form_get_new for1, string server, string token, string ip)
|
||||
{
|
||||
|
||||
TestDbContext ctx = new TestDbContext();
|
||||
object data = new { id = "67134feddc0ff12924d9aaf4", secretkey = "c3e08b07b8034e6b961f010abed5586a", scene = 3, token = token, ip = ip };
|
||||
var a1 = await server.PostJsonAsync(data);
|
||||
var ok = await a1.GetJsonAsync();
|
||||
Console.WriteLine(ok);
|
||||
|
||||
if (ok.success == 1)
|
||||
{
|
||||
|
||||
|
||||
using (var ctx = new TestDbContext())
|
||||
{
|
||||
|
||||
if (ctx.Forms.Include(a => a.events).Where(a => a.events.name == for1.events_name).Any(e => e.team_name == for1.team_name))
|
||||
{
|
||||
@ -276,7 +291,7 @@ namespace asg_form.Controllers
|
||||
|
||||
|
||||
form form1 = new form();
|
||||
form1.logo_uri = $"https://124.223.35.239/loge/{for1.events_name}/{for1.team_name}.png";
|
||||
form1.logo_uri = $"/loge/{for1.events_name}/{for1.team_name}.png";
|
||||
form1.team_name = for1.team_name;
|
||||
form1.team_password = for1.team_password;
|
||||
form1.team_tel = for1.team_tel;
|
||||
@ -310,8 +325,17 @@ namespace asg_form.Controllers
|
||||
|
||||
return "ok!";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(new error_mb { code = 400, message = $"未通过人机验证{await a1.GetStringAsync()}" });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -363,6 +387,57 @@ namespace asg_form.Controllers
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获得所有表单信息
|
||||
/// </summary>
|
||||
/// <param name="page">页数</param>
|
||||
/// <param name="page_long">每页长度</param>
|
||||
/// <returns></returns>
|
||||
|
||||
[Route("api/v1/form/all")]
|
||||
[HttpGet]
|
||||
[Authorize]
|
||||
public List<team> Getform(short page,short page_long,string sort,string eventsname)
|
||||
{
|
||||
TestDbContext ctx = new TestDbContext();
|
||||
|
||||
|
||||
int c = ctx.Forms.Count();
|
||||
int b = page_long * page;
|
||||
if (page_long * page > c)
|
||||
{
|
||||
b = c;
|
||||
}
|
||||
var events= ctx.events.First(ctx => ctx.name == eventsname);
|
||||
List<form> forms;
|
||||
if(sort=="vote")
|
||||
{
|
||||
forms = ctx.Forms.Include(a => a.role).Include(a=>a.events).OrderByDescending(a => a.piaoshu).Where(a=>a.events==events).Skip(page_long * page - page_long).Take(page_long).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
//改为按照id倒序排序
|
||||
//forms = ctx.Forms.Include(a => a.role).Skip(page_long * page - page_long).Take(page_long).ToList();
|
||||
forms = ctx.Forms.Include(a => a.role).Include(a => a.events).OrderByDescending(a => a.Id).Where(a => a.events == events).Skip(page_long * page - page_long).Take(page_long).ToList();
|
||||
|
||||
}
|
||||
List<team> teams = new List<team>();
|
||||
|
||||
|
||||
foreach (form for1 in forms)
|
||||
{
|
||||
var team = new team { id=for1.Id,name = for1.team_name, timer = for1.time, piaoshu = for1.piaoshu ,logo_uri=for1.logo_uri};
|
||||
foreach (var role in for1.role)
|
||||
{
|
||||
team.rolename.Add(new roletwo { name = role.role_name, lin = role.role_lin });
|
||||
}
|
||||
teams.Add(team);
|
||||
// a++;
|
||||
}
|
||||
return teams;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -487,10 +562,11 @@ namespace asg_form.Controllers
|
||||
|
||||
public DateTime time { get; set; } = DateTime.Now;
|
||||
public string team_name { get; set; }
|
||||
|
||||
public string team_password { get; set; }
|
||||
public string team_tel { get; set; }
|
||||
// public string logo_base64 { get; set; }
|
||||
public string? events_name { get; set; }
|
||||
public string events_name { get; set; }
|
||||
// public string? belong { get; set; }
|
||||
public List<role_get> role_get { get; set; }
|
||||
}
|
||||
@ -525,7 +601,7 @@ namespace asg_form.Controllers
|
||||
|
||||
|
||||
|
||||
public class allteam1 : ControllerBase
|
||||
public class 所有队伍 : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
@ -540,11 +616,17 @@ public class allteam1 : ControllerBase
|
||||
{
|
||||
public long id { get; set; }
|
||||
public string name { get; set; }
|
||||
public long timer { get; set; }
|
||||
public DateTime timer { get; set; }
|
||||
public int piaoshu { get; set; }
|
||||
public string logo_uri { get; set; }
|
||||
public List<roletwo> rolename { get; set; }=new List<roletwo>();
|
||||
}
|
||||
|
||||
public class roletwo
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string lin { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -12,7 +12,6 @@ using Flandre.Core.Common;
|
||||
using Flandre.Core.Messaging.Segments;
|
||||
using static asg_form.Controllers.InviteReferee;
|
||||
using Mirai.Net.Data.Shared;
|
||||
using static asg_form.Controllers.Team.Team_http;
|
||||
|
||||
namespace asg_form.Controllers
|
||||
{
|
||||
|
@ -112,12 +112,12 @@ namespace asg_form.Controllers
|
||||
{
|
||||
try {
|
||||
string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
||||
var ouser = userManager.Users.Include(a => a.myteam.role).FirstOrDefault(a => a.Id == id.ToInt64());
|
||||
foreach (var role in ouser.myteam.role)
|
||||
var ouser = userManager.Users.Include(a => a.haveform.role).FirstOrDefault(a => a.Id == id.ToInt64());
|
||||
foreach (var role in ouser.haveform.role)
|
||||
{
|
||||
role.Team = null;
|
||||
role.form = null;
|
||||
}
|
||||
return Ok(ouser.myteam);
|
||||
return Ok(ouser.haveform);
|
||||
|
||||
}
|
||||
catch
|
||||
|
@ -2,7 +2,6 @@
|
||||
using System.ComponentModel;
|
||||
using System.Reflection.Metadata;
|
||||
using asg_form.Controllers;
|
||||
using asg_form.Controllers.Team;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace asg_form
|
||||
@ -16,7 +15,7 @@ namespace asg_form
|
||||
//public string? CreationTime { get; set; }
|
||||
|
||||
public form? haveform { get; set; }
|
||||
public T_Team? myteam { get; set; }
|
||||
// public T_Team? myteam { get; set; }
|
||||
|
||||
public bool? isbooking { get; set; }
|
||||
public string? chinaname { get; set; }
|
||||
|
@ -77,6 +77,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\Team\" />
|
||||
<Folder Include="Model\" />
|
||||
</ItemGroup>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user