diff --git a/asg_form/Controllers/AssignmentController.cs b/asg_form/Controllers/AssignmentController.cs index 0a8fbd7..4fdf82d 100644 --- a/asg_form/Controllers/AssignmentController.cs +++ b/asg_form/Controllers/AssignmentController.cs @@ -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 { @@ -43,7 +44,8 @@ namespace asg_form.Controllers public string lastOperateTime { get; set; } - public string approvalPerson { 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 = "已修改" }); } diff --git a/asg_form/Controllers/Com.cs b/asg_form/Controllers/Com.cs index fbf7e90..b15d63c 100644 --- a/asg_form/Controllers/Com.cs +++ b/asg_form/Controllers/Com.cs @@ -107,14 +107,14 @@ namespace asg_form.Controllers [Route("api/v1/anchor")] [HttpPost] [Authorize] - public async Task> anchorPost(string gameIds) + public async Task> 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> DeleteSelectedGame(int gameId,string reason) + public async Task> 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 = "删除成功" }); } diff --git a/asg_form/Controllers/Events.cs b/asg_form/Controllers/Events.cs index 35bfd88..bb988d2 100644 --- a/asg_form/Controllers/Events.cs +++ b/asg_form/Controllers/Events.cs @@ -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 = "无权访问" }); } /// @@ -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 = "不是管理员" }); } } diff --git a/asg_form/Controllers/config.cs b/asg_form/Controllers/config.cs index f28e319..cdd4cf9 100644 --- a/asg_form/Controllers/config.cs +++ b/asg_form/Controllers/config.cs @@ -105,7 +105,7 @@ using(TestDbContext db=new TestDbContext()){ [Route("api/v1/admin/config/all")] [HttpGet] [Authorize] - public async Task> config_get_all(short page, short limit = 10) + public async Task> 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 }); } } diff --git a/asg_form/Controllers/excel.cs b/asg_form/Controllers/excel.cs index e391a5a..8e4811e 100644 --- a/asg_form/Controllers/excel.cs +++ b/asg_form/Controllers/excel.cs @@ -390,7 +390,7 @@ namespace asg_form.Controllers [Route("api/v1/admin/rolealluser")] [HttpGet] [Authorize] - public async Task> RoleuserAsync(string rolename) + public async Task> 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?)await userManager.GetRolesAsync(user1); + post_User.Base64 = user1.UserBase64; + post_User.Roles = (List?)await userManager.GetRolesAsync(user1); + } data.Add(post_User); } - return data; + return Ok(new { code = 200, message = "" ,data}); } else { diff --git a/asg_form/Controllers/schedule.cs b/asg_form/Controllers/schedule.cs index 83d3492..acb7ab7 100644 --- a/asg_form/Controllers/schedule.cs +++ b/asg_form/Controllers/schedule.cs @@ -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 } + /// + /// 获得所有比赛(new) + /// + [Route("api/v2/game/")] + [HttpGet] + public async Task> 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 }); + } + + } + /// /// 获取我的竞猜 ///