diff --git a/AGSS/Areas/Identity/Pages/Account/Register.cshtml b/AGSS/Areas/Identity/Pages/Account/Register.cshtml
index 1fb3d03..cdbeffe 100644
--- a/AGSS/Areas/Identity/Pages/Account/Register.cshtml
+++ b/AGSS/Areas/Identity/Pages/Account/Register.cshtml
@@ -18,15 +18,20 @@
-
+
-
+
+
+
+
+
+
diff --git a/AGSS/Areas/Identity/Pages/Account/Register.cshtml.cs b/AGSS/Areas/Identity/Pages/Account/Register.cshtml.cs
index 8a449c6..3884aff 100644
--- a/AGSS/Areas/Identity/Pages/Account/Register.cshtml.cs
+++ b/AGSS/Areas/Identity/Pages/Account/Register.cshtml.cs
@@ -104,6 +104,12 @@ namespace AGSS.Areas.Identity.Pages.Account
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
+
+
+ [MaxLength(10)]
+ [Display(Name = "Confirm password")]
+ public string Sex { get; set; }
+
}
@@ -120,7 +126,8 @@ namespace AGSS.Areas.Identity.Pages.Account
if (ModelState.IsValid)
{
var user = CreateUser();
-
+ user.Id = Guid.NewGuid().ToString();
+ user.Sex = Input.Sex;
await _userStore.SetUserNameAsync(user, Input.Email, CancellationToken.None);
await _emailStore.SetEmailAsync(user, Input.Email, CancellationToken.None);
var result = await _userManager.CreateAsync(user, Input.Password);
diff --git a/AGSS/Controllers/Admin/AdminRoleControllers.cs b/AGSS/Controllers/Admin/AdminRoleControllers.cs
index ddcb89e..95c7429 100644
--- a/AGSS/Controllers/Admin/AdminRoleControllers.cs
+++ b/AGSS/Controllers/Admin/AdminRoleControllers.cs
@@ -1,3 +1,4 @@
+using AGSS.Models.DTOs;
using AGSS.Models.Entities;
using AGSS.Models.Template;
using Microsoft.AspNetCore.Authorization;
@@ -96,6 +97,69 @@ public class AdminRoleControllers:ControllerBase
}
+ ///
+ /// 删除指定用户。
+ ///
+ /// 要删除的用户的唯一标识符。
+ /// 返回操作结果,包含状态码、消息和数据。如果删除成功,则返回200状态码;如果用户ID为空或未找到指定用户,则分别返回400或404状态码;若删除过程中出现错误,则返回500状态码并附带错误信息。
+ [HttpPost]
+ public async Task DelUser(string userId)
+ {
+ if (string.IsNullOrWhiteSpace(userId))
+ {
+ return Ok(new ReturnTemplate(400, "你填写的用户ID是空的~", null));
+ }
+
+ var user = await _userManager.FindByIdAsync(userId);
+ if (user == null)
+ {
+ return Ok(new ReturnTemplate(404, "未找到指定用户哦·~", null));
+ }
+
+ // 删除用户
+ var result = await _userManager.DeleteAsync(user);
+ if (result.Succeeded)
+ {
+ return Ok(new ReturnTemplate(200, "用户删除成功,不要留念这个用户哦~", null));
+ }
+ else
+ {
+ return StatusCode(500, new ReturnTemplate(500, "发生了一些不可预料的错误,555", result.Errors));
+ }
+ }
+
+
+ [HttpPost]
+ public async Task SetMenu([FromBody]MenuRequest request)
+ {
+ if (string.IsNullOrWhiteSpace(request.Id) || string.IsNullOrWhiteSpace(request.MenuName))
+ {
+ return Ok(new ReturnTemplate(400, "请求参数无效(有的参数是空的哦~)", ""));
+ }
+ var user=await _userManager.FindByIdAsync(request.Id);
+ if (user==null)
+ {
+ return Ok(new ReturnTemplate(404, "Sorry,你输入的用户我们找不到!", ""));
+ }
+ user.MenuCode = request.MenuCode;
+ user.MenuName = request.MenuName;
+ var result= await _userManager.UpdateAsync(user);
+ if (result.Succeeded)
+ {
+ return Ok(new ReturnTemplate(200, "配置成功啦!", ""));
+ }
+ else
+ {
+ return StatusCode(500, new ReturnTemplate(500, "删除用户时发生错误", result.Errors));
+ }
+
+
+ }
+
+
+
+
+
///
/// 通过角色查询用户,支持分页
///
diff --git a/AGSS/Migrations/ApplicationDbContextModelSnapshot.cs b/AGSS/Migrations/ApplicationDbContextModelSnapshot.cs
index 74624bb..058cb5a 100644
--- a/AGSS/Migrations/ApplicationDbContextModelSnapshot.cs
+++ b/AGSS/Migrations/ApplicationDbContextModelSnapshot.cs
@@ -93,6 +93,14 @@ namespace AGSS.Migrations
b.Property("LockoutEnd")
.HasColumnType("timestamp with time zone");
+ b.Property("MenuCode")
+ .HasMaxLength(500)
+ .HasColumnType("character varying(500)");
+
+ b.Property("MenuName")
+ .HasMaxLength(500)
+ .HasColumnType("character varying(500)");
+
b.Property("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
diff --git a/AGSS/Migrations/DBContextModelSnapshot.cs b/AGSS/Migrations/DBContextModelSnapshot.cs
deleted file mode 100644
index e76171d..0000000
--- a/AGSS/Migrations/DBContextModelSnapshot.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-//
-using System;
-using AGSS.Models;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-
-#nullable disable
-
-namespace AGSS.Migrations
-{
- [DbContext(typeof(DBContext))]
- partial class DBContextModelSnapshot : ModelSnapshot
- {
- protected override void BuildModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "9.0.6")
- .HasAnnotation("Relational:MaxIdentifierLength", 63);
-
- NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
-
- modelBuilder.Entity("AGSS.Models.Entities.UserModel", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property("AuthId")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("character varying(50)");
-
- b.Property("Birthday")
- .HasMaxLength(20)
- .HasColumnType("character varying(20)");
-
- b.Property("Config")
- .HasMaxLength(200)
- .HasColumnType("character varying(200)");
-
- b.Property("Description")
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property("JobCode")
- .HasMaxLength(10)
- .HasColumnType("character varying(10)");
-
- b.Property("JobName")
- .HasMaxLength(10)
- .HasColumnType("character varying(10)");
-
- b.Property("Sex")
- .HasMaxLength(20)
- .HasColumnType("character varying(20)");
-
- b.HasKey("Id");
-
- b.ToTable("UserModels");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/AGSS/Models/DTOs/MenuRequest.cs b/AGSS/Models/DTOs/MenuRequest.cs
new file mode 100644
index 0000000..b8a76c2
--- /dev/null
+++ b/AGSS/Models/DTOs/MenuRequest.cs
@@ -0,0 +1,8 @@
+namespace AGSS.Models.DTOs;
+
+public struct MenuRequest
+{
+ public string Id { get; set; }
+ public string MenuName { get; set; }
+ public string? MenuCode { get; set; }
+}
\ No newline at end of file
diff --git a/AGSS/Models/Entities/User.cs b/AGSS/Models/Entities/User.cs
index 7949e56..0ac6258 100644
--- a/AGSS/Models/Entities/User.cs
+++ b/AGSS/Models/Entities/User.cs
@@ -17,6 +17,10 @@ public class UserModel:IdentityUser
public string? JobName { get; set; }
[MaxLength(20)]
public string? Birthday { get; set; }
+ [MaxLength(500)]
+ public string? MenuCode { get; set; }
+ [MaxLength(500)]
+ public string? MenuName { get; set; }
}
diff --git a/AGSS/Program.cs b/AGSS/Program.cs
index e68de46..427490c 100644
--- a/AGSS/Program.cs
+++ b/AGSS/Program.cs
@@ -33,7 +33,7 @@ builder.Services.AddDbContext(opt =>
opt.UseNpgsql(builder.Configuration.GetConnectionString("DBContext")));
// Identity 配置
-builder.Services.AddIdentity()
+builder.Services.AddIdentity()
.AddEntityFrameworkStores()
.AddDefaultTokenProviders()
.AddDefaultUI();
diff --git a/AGSS/Utilities/Jwt.cs b/AGSS/Utilities/Jwt.cs
index b97fbdc..6d3c49f 100644
--- a/AGSS/Utilities/Jwt.cs
+++ b/AGSS/Utilities/Jwt.cs
@@ -28,7 +28,7 @@ public class Jwt
return new JwtSecurityTokenHandler().WriteToken(tokenDescriptor);
}
- public async Task GenerateJwtToken(UserModel user,IList roles)
+ public string GenerateJwtToken(UserModel user,IList roles)
{
var claims = new List();
claims.Add(new Claim(JwtRegisteredClaimNames.Sub, user.Id.ToString()));
diff --git a/AGSS/appsettings.Development.json b/AGSS/appsettings.Development.json
index f061d7b..d1c269e 100644
--- a/AGSS/appsettings.Development.json
+++ b/AGSS/appsettings.Development.json
@@ -15,6 +15,7 @@
},
"AllowedHosts": "*",
"Jwt": {
+ "ExpireMinutes": "4",
"Issuer": "https://api.zeronode.cn/api",
"Audience": "https://api.zeronode.cn/api",
"Key": "7wU9bdVfBsX3jITh0w4bgE6fkvLk8pIcZRSUw6r8HQUnXfslYxlx4c4E0ZAIw4Ak"
diff --git a/AGSS/appsettings.json b/AGSS/appsettings.json
index f595462..6527a3d 100644
--- a/AGSS/appsettings.json
+++ b/AGSS/appsettings.json
@@ -15,6 +15,7 @@
},
"AllowedHosts": "*",
"Jwt": {
+ "ExpireMinutes": "4",
"Issuer": "https://api.zeronode.cn/api",
"Audience": "https://api.zeronode.cn/api",
"Key": "7wU9bdVfBsX3jITh0w4bgE6fkvLk8pIcZRSUw6r8HQUnXfslYxlx4c4E0ZAIw4Ak"