diff --git a/asg_form/Controllers/Teamregistration/RegisterController.cs b/asg_form/Controllers/Teamregistration/RegisterController.cs index c0344ab..2f991c2 100644 --- a/asg_form/Controllers/Teamregistration/RegisterController.cs +++ b/asg_form/Controllers/Teamregistration/RegisterController.cs @@ -283,22 +283,32 @@ namespace asg_form.Controllers.Teamregistration } return Ok(new error_mb { code = 401, message = "没有管理员,无法设置" }); } - } - /// - /// 根据主键id找申请表所有内容T_Comform - /// - [Route("api/v1/admin/findFormById")] - [HttpGet] - [Authorize] - public async Task> find_by_id(int Id) - { - string userId = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value; - var user = await userManager.FindByIdAsync(userId); - if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) + /// + /// 根据主键id找申请表所有内容T_Comform + /// + [Route("api/v1/admin/findFormById")] + [HttpGet] + [Authorize] + public async Task> find_by_id(int Id) { - return Ok(new error_mb { code = 401, message = "无权访问" }); + string userId = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value; + var user = await userManager.FindByIdAsync(userId); + if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) + { + return Ok(new error_mb { code = 401, message = "无权访问" }); + } + using (TestDbContext sub = new TestDbContext()) + { + var query = sub.T_Comform.AsQueryable() + .Where(n => n.id == Id) + .OrderByDescending(a => a.user_id); + + var result = await query.ToListAsync(); + + return Ok(new { code = 200, data = result }); + } } - } + }