This commit is contained in:
王炜翔 2024-11-07 14:33:50 +08:00
parent b7c9cbdc89
commit fcb54dfb5a
6 changed files with 72 additions and 26 deletions

View File

@ -24,6 +24,7 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static asg_form.Controllers.InviteReferee;
using static Microsoft.ApplicationInsights.MetricDimensionNames.TelemetryContext;
using AngleSharp.Css;
namespace asg_form.Controllers
{
@ -44,6 +45,7 @@ namespace asg_form.Controllers
public string lastOperateTime { get; set; }
public string approvalPerson { get; set; }
public string priority { get; set; }
}
public class TaskCreate
{
@ -54,7 +56,7 @@ namespace asg_form.Controllers
public string TaskName { get; set; }
public string TaskDescription { get; set; }
public long Money { get; set; }
public string priority { get; set; }
}
public class AssignmentController : ControllerBase
{
@ -96,12 +98,13 @@ namespace asg_form.Controllers
status = "0",
createTime = dateString.ToString(),
lastOperateTime = dateString.ToString(),
approvalPerson = "未审核"
approvalPerson = "未审核",
priority = taskinfo.priority
};
sub.T_Task.Add(task);
wp = -1;
string msg = $"ASG管理系统{taskinfo.Chinaname} 同学,您有新的待办任务,请您登录后台管理系统查看任务详情,并及时完成任务。--{taskinfo.CreatePerson}";
string msg = $"ASG管理系统{taskinfo.Chinaname} 同学,您有新的{taskinfo.priority}星级待办任务,请您登录后台管理系统查看任务详情,并及时完成任务。--{taskinfo.CreatePerson}";
string qqgroup = "925510646";
wp = 0;
var atuserqq = user.qqnumber;
@ -283,6 +286,13 @@ namespace asg_form.Controllers
t.status == "3" ? 1 :
t.status == "2" ? 0 :
10)
.ThenByDescending(n => n.priority == "5" ? 5 :
n.priority == "4" ? 4 :
n.priority == "3" ? 3 :
n.priority == "2" ? 2 :
n.priority == "1" ? 1 :
n.priority == "0" ? 0 :
10)
.Skip((page - 1) * limit)
.Take(limit)
.ToListAsync();
@ -331,6 +341,7 @@ namespace asg_form.Controllers
public string taskName { get; set; }
public string taskDescription { get; set; }
public long money { get; set; }
public string priority { get; set; }
}
[Route("api/v1/admin/UpdateTasks")]
[HttpPut]
@ -351,6 +362,7 @@ namespace asg_form.Controllers
task.taskDescription = msg.taskDescription;
task.money = msg.money;
task.taskName = msg.taskName;
task.priority = msg.priority;
await db.SaveChangesAsync();
return Ok(new { code = 200, message = "已修改" });
}

View File

@ -107,14 +107,14 @@ namespace asg_form.Controllers
[Route("api/v1/anchor")]
[HttpPost]
[Authorize]
public async Task<ActionResult<string>> anchorPost(string gameIds)
public async Task<ActionResult<object>> anchorPost(string gameIds)
{
string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
var user = await userManager.FindByIdAsync(id);
if (user.officium != "Anchor")
{
return BadRequest(new error_mb { code = 401, message = $"你是{user.officium},你不是导播,无法操作" });
return Ok(new error_mb { code = 401, message = $"你是{user.officium},你不是导播,无法操作" });
}
else
@ -166,14 +166,14 @@ namespace asg_form.Controllers
[Route("api/v1/anchor")]
[HttpDelete]
[Authorize]
public async Task<ActionResult<string>> DeleteSelectedGame(int gameId,string reason)
public async Task<ActionResult<object>> DeleteSelectedGame(int gameId,string reason)
{
string userId = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
var user = await userManager.FindByIdAsync(userId);
if (user.officium != "Anchor")
{
return BadRequest(new error_mb { code = 401, message = $"你是{user.officium},你不是导播,无法操作" });
return Ok(new error_mb { code = 401, message = $"你是{user.officium},你不是导播,无法操作" });
}
TestDbContext testDb = new TestDbContext();
@ -204,9 +204,7 @@ namespace asg_form.Controllers
{
return StatusCode(500, new { code = 500, message = "服务器错误", ex });
}
return Ok("删除成功");
return Ok(new { code = 200, message = "删除成功" });
}

View File

@ -90,7 +90,7 @@ namespace asg_form.Controllers
if (!string.IsNullOrEmpty(events.rule_markdown))
{
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "doc", "rule", $"{eventId}.md");
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "doc", "rule", $"{eve.name}.md");
// 如果文件存在,删除旧文件
if (System.IO.File.Exists(filePath))
@ -118,7 +118,7 @@ namespace asg_form.Controllers
await testDb.SaveChangesAsync();
return Ok(eve);
}
return BadRequest(new error_mb { code = 401, message = "无权访问" });
return Ok(new error_mb { code = 401, message = "无权访问" });
}
/// <summary>
@ -136,11 +136,11 @@ namespace asg_form.Controllers
var evernt = test.events.FirstOrDefault(a => a.Id == eventId);
test.Remove(evernt);
await test.SaveChangesAsync();
return Ok("删除");
return Ok(new error_mb { code = 200, message = "删除成功" });
}
else
{
return BadRequest(new error_mb { code = 400, message = "不是管理员" });
return Ok(new error_mb { code = 400, message = "不是管理员" });
}
}

View File

@ -105,7 +105,7 @@ using(TestDbContext db=new TestDbContext()){
[Route("api/v1/admin/config/all")]
[HttpGet]
[Authorize]
public async Task<ActionResult<object>> config_get_all(short page, short limit = 10)
public async Task<ActionResult<object>> config_get_all(string msg="null",short page=1, short limit = 10)
{
if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
@ -114,7 +114,7 @@ using(TestDbContext db=new TestDbContext()){
}
using (TestDbContext db = new TestDbContext())
{
var query = db.T_config.AsQueryable();
var query = db.T_config.AsQueryable().Where(n => msg=="null" || n.msg.Contains(msg) || n.Title.Contains(msg) || n.Substance.Contains(msg));
var TotalRecords = await query.CountAsync();
var config =await query
.Skip((page - 1) * limit)
@ -125,7 +125,7 @@ using(TestDbContext db=new TestDbContext()){
rows = config,
total = TotalRecords,
};
return Ok(result);
return Ok(new { code = 200, message = "", result });
}
}

View File

@ -390,7 +390,7 @@ namespace asg_form.Controllers
[Route("api/v1/admin/rolealluser")]
[HttpGet]
[Authorize]
public async Task<ActionResult<object>> RoleuserAsync(string rolename)
public async Task<ActionResult<object>> RoleuserAsync(string rolename,string onlyId)
{
if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
{
@ -401,16 +401,19 @@ namespace asg_form.Controllers
{
post_user post_User = new post_user();
post_User.id = user1.Id;
post_User.name = user1.UserName;
post_User.email = user1.Email;
post_User.officium = user1.officium;
post_User.chinaname = user1.chinaname;
if(onlyId != "1")
{
post_User.name = user1.UserName;
post_User.email = user1.Email;
post_User.officium = user1.officium;
post_User.chinaname = user1.chinaname;
post_User.Base64 = user1.UserBase64;
post_User.Roles = (List<string>?)await userManager.GetRolesAsync(user1);
post_User.Base64 = user1.UserBase64;
post_User.Roles = (List<string>?)await userManager.GetRolesAsync(user1);
}
data.Add(post_User);
}
return data;
return Ok(new { code = 200, message = "" ,data});
}
else
{

View File

@ -12,6 +12,7 @@ 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
{
@ -338,6 +339,38 @@ namespace asg_form.Controllers
}
/// <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();
var row = await query
.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
{
row,
total,
};
return Ok(new { code = 200, message = "", data });
}
catch (Exception ex)
{
return Ok(new { code = 500, message = "服务器错误", ex });
}
}
/// <summary>
/// 获取我的竞猜
/// </summary>