diff --git a/asg_form/Controllers/excel.cs b/asg_form/Controllers/excel.cs index 41fd8ec..e391a5a 100644 --- a/asg_form/Controllers/excel.cs +++ b/asg_form/Controllers/excel.cs @@ -9,6 +9,7 @@ using System.Drawing; using System.IO.Compression; using System.Security.Claims; using static asg_form.Controllers.login; +using static System.Runtime.InteropServices.JavaScript.JSType; namespace asg_form.Controllers { @@ -384,6 +385,46 @@ namespace asg_form.Controllers + + + [Route("api/v1/admin/rolealluser")] + [HttpGet] + [Authorize] + public async Task> RoleuserAsync(string rolename) + { + if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) + { + + List data = new List(); + var users= await userManager.GetUsersInRoleAsync(rolename); + foreach (var user1 in users) + { + 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; + + post_User.Base64 = user1.UserBase64; + post_User.Roles = (List?)await userManager.GetRolesAsync(user1); + data.Add(post_User); + } + return data; + } + else + { + return BadRequest(new error_mb { code = 400, message = "无管理员" }); + } + } + + + + + + + + [Route("api/v1/admin/excel/all")] [HttpGet] [Authorize] diff --git a/asg_form/Controllers/login.cs b/asg_form/Controllers/login.cs index 1ec30b6..ed72fcd 100644 --- a/asg_form/Controllers/login.cs +++ b/asg_form/Controllers/login.cs @@ -534,7 +534,11 @@ namespace asg_form.Controllers } - + if (user.Integral == null) + { + user.Integral = 0; + await userManager.UpdateAsync(user); + } var claims = new List();