74 lines
2.0 KiB
C#
Raw Normal View History

2024-08-03 20:40:34 +08:00
2024-11-07 16:31:07 +08:00
using AngleSharp.Dom;
2024-08-03 20:40:34 +08:00
using Manganese.Array;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using NLog;
using System.Collections.Generic;
namespace asg_form.Controllers
{
public class : ControllerBase
{
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
/// <summary>
/// 获取所有video
/// </summary>
/// <returns></returns>
[Route("api/v1/video/")]
[HttpGet]
public async Task<ActionResult<List<string>>> get_video()
{
DirectoryInfo di = new DirectoryInfo($@"{AppDomain.CurrentDomain.BaseDirectory}video");
FileInfo[] files = di.GetFiles();
List<string> result = new List<string>();
foreach (FileInfo file in files)
{
result.Add(file.Name);
}
return result;
}
[Route("api/v1/Duplicate_name/")]
[HttpGet]
public async Task<ActionResult<string>> Post(string name,string event_name)
{
TestDbContext ctx = new TestDbContext();
bool b = ctx.Forms.Include(a=>a.events).Any(a=>a.team_name==name&&a.events.name==event_name);
if (b)
{
return BadRequest("Have a CHONG NAME");
}
else
{
return "No have a chong name";
}
}
2024-11-07 16:31:07 +08:00
[Route("api/v2/repeatName/")]
[HttpGet]
public async Task<ActionResult<string>> rpName(string teamName, int eventId)
{
TestDbContext ctx = new TestDbContext();
bool isRepeat = ctx.Forms.Include(a => a.events).Any(a => a.team_name == teamName && a.events.Id == eventId);
if (isRepeat)
{
return Ok(new { code = 200, message = "不重复" ,data = true});
}
else
{
return Ok(new { code = 200, message = "重复" ,data = false});
}
}
}
2024-08-03 20:40:34 +08:00
}