From bb9ed413a74dda8416f5664a3ff3039b220b4180 Mon Sep 17 00:00:00 2001 From: SHM Date: Thu, 24 Jul 2025 16:54:43 +0900 Subject: [PATCH] =?UTF-8?q?[=EC=84=B1=ED=98=84=EB=AA=A8]=20AccountDB=20Cor?= =?UTF-8?q?e=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/DLL/SystemX.Core.DB.dll | Bin 0 -> 9728 bytes Projects/DLL/SystemX.Core.dll | Bin 50688 -> 50688 bytes .../dacpac/SystemX.DB.AccountDB.dacpac | Bin 3503 -> 3504 bytes .../AccountDB/Context/AccountDBContext.cs | 57 +++++++++++++ .../AccountDB/Tables/tRefreshToken.cs | 11 +++ .../SystemX.Core.DB/AccountDB/Tables/tRole.cs | 13 +++ .../SystemX.Core.DB/AccountDB/Tables/tUser.cs | 19 +++++ .../SystemX.Core.DB/SystemX.Core.DB.csproj} | 10 ++- Projects/SystemX.Core/SystemX.Core.sln | 6 ++ Projects/Tools/Tools_Scaffold_AccountDB.bat | 5 +- Projects/WebApi/AuthApi/AuthApi.csproj | 4 +- .../AuthApi/Controllers/AuthController.cs | 1 - Projects/WebApi/AuthApi/Program.cs | 5 -- .../WebApi/AuthApi/Services/AuthService.cs | 59 ++++++------- .../AccountDB/Context/AccountDbContext.cs | 80 ------------------ .../AccountDB/Tables/TRefreshToken.cs | 11 --- .../DB/DBContext/AccountDB/Tables/TRole.cs | 13 --- .../DB/DBContext/AccountDB/Tables/TUser.cs | 19 ----- .../WebApi.Library/WebApi.Library.csproj | 5 ++ Projects/WebApi/WebApi.sln | 6 -- 20 files changed, 151 insertions(+), 173 deletions(-) create mode 100644 Projects/DLL/SystemX.Core.DB.dll create mode 100644 Projects/SystemX.Core/SystemX.Core.DB/AccountDB/Context/AccountDBContext.cs create mode 100644 Projects/SystemX.Core/SystemX.Core.DB/AccountDB/Tables/tRefreshToken.cs create mode 100644 Projects/SystemX.Core/SystemX.Core.DB/AccountDB/Tables/tRole.cs create mode 100644 Projects/SystemX.Core/SystemX.Core.DB/AccountDB/Tables/tUser.cs rename Projects/{WebApi/WebApi.Library.DBContext/WebApi.Library.DBContext.csproj => SystemX.Core/SystemX.Core.DB/SystemX.Core.DB.csproj} (76%) delete mode 100644 Projects/WebApi/WebApi.Library.DBContext/DB/DBContext/AccountDB/Context/AccountDbContext.cs delete mode 100644 Projects/WebApi/WebApi.Library.DBContext/DB/DBContext/AccountDB/Tables/TRefreshToken.cs delete mode 100644 Projects/WebApi/WebApi.Library.DBContext/DB/DBContext/AccountDB/Tables/TRole.cs delete mode 100644 Projects/WebApi/WebApi.Library.DBContext/DB/DBContext/AccountDB/Tables/TUser.cs diff --git a/Projects/DLL/SystemX.Core.DB.dll b/Projects/DLL/SystemX.Core.DB.dll new file mode 100644 index 0000000000000000000000000000000000000000..91681c171d4c98ec29c7817d9553daddad52d788 GIT binary patch literal 9728 zcmeHMeQX@pai87g?H!NO>3BR!v@J_VebS^t7^Lv&&wK>x@icXqzsyqS5k@4ed{cgBt zMCfak->ZLBJNUi&k>go6G40rsPHHNVN#*mlmq=R)XC|M><`X@KhZ9rwxRqSJI=n@h z9_%GLs2TLsj|+2(MRT+%QKdBzZ2-sgxj)^DdjeMnE~2R5y6-nL*nepSK=8R4H1;^F z@_*^BNM@lu2fK$E=^%QE6S26B5v>C65AGluSu9(LP7sC4^mC;GhI^}_WYdrvD z607nXl(YoVSkiHw3@Guf0|*D2z*W{d;C<4uayAs%R~o~`wu(sx%B_Q_OOP_~SDaTg z_D!b%9o-7OwM3e5e|4}!HyWym!bCeZ=#Rom#g0w7aas^C;FZr11Pr9yX9z-6(_|3m zMVfI2Ggq4BEU{s>ahq`l1D0zc1k;U+7E5f5#aifBuCkY_OSfWL#`W*#9$6%2m2pFgcUqcYK z#HzS4U1q7Ws3!VSpKH(=9jxBWSwi!-0<6vNxK9E%;vC&438x!xsJv$**uVV>OuHawE z(p7}#TiU^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 zcmdlWyo~*-Z zU;lwwMuEw#Qefq(WyY75+_gTIvWDT@jb*c5t}ngl|4RRgioBPlkEb^ z7F7RR@MNO4@(#P!+()k?gXMl~h}V>0cCJ&6c6MFeJ$-RV+w|+D78=M3R2OCRjg zeYyAU+!&dQ^4{JmXX>;4PR%&0b#AYUCzJjX!S5M|ocP%)wslJ^HgwmVaZ25Ig^^|3 zj0%HK1v^|*{3ca0)Cvi46#igTE9R)4So^R+>((c(V{!%u3_LG%ygbd;V(Wg>@Ur!k z`@ZH&w_m^S6`B42V@dBH-K*@oE7#@EIXHpmEZhJ5IicaR{XVXFIydl2{WY7C-BBC- z|CDO;?>Sp$u);$$lw&H(rG_Z!|Bv=gG4flO@Be3B@~VI74$fcJ82rDVZNHJ{@43hO z=49`xdh}+&?zAeNDb%%;;V_1rq z?sVxLjTsv`t{Zfw3F=&Xm=>tR5qC`YBGd7OwK~r49Z#v2S6vUDyR~m$g1zU#sXP9v z9{A$>WIrQva+*Aq`voW&)$^EwsBJt}AnFs3HBzE7 options) + : base(options) + { + } + + public virtual DbSet tRefreshTokens { get; set; } + + public virtual DbSet tRoles { get; set; } + + public virtual DbSet tUsers { get; set; } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.cAuid).HasName("PK__tRefresh__FBF08554C9ECDB70"); + + entity.ToTable("tRefreshToken"); + + entity.Property(e => e.cAuid).HasMaxLength(250); + entity.Property(e => e.cRefreshToken).HasMaxLength(1000); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.cAuid).HasName("PK__tRole__FBF0855413CC5A4E"); + + entity.ToTable("tRole"); + + entity.Property(e => e.cAuid).HasMaxLength(250); + entity.Property(e => e.cRoleName).HasMaxLength(20); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.cUserID).HasName("PK__tUser__A75DC19A4B18524F"); + + entity.ToTable("tUser"); + + entity.Property(e => e.cUserID).HasMaxLength(50); + entity.Property(e => e.cAuid).HasMaxLength(250); + entity.Property(e => e.cPasswordHashed).HasMaxLength(250); + }); + + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); +} diff --git a/Projects/SystemX.Core/SystemX.Core.DB/AccountDB/Tables/tRefreshToken.cs b/Projects/SystemX.Core/SystemX.Core.DB/AccountDB/Tables/tRefreshToken.cs new file mode 100644 index 0000000..f60f278 --- /dev/null +++ b/Projects/SystemX.Core/SystemX.Core.DB/AccountDB/Tables/tRefreshToken.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; + +namespace SystemX.Core.DB; + +public partial class tRefreshToken +{ + public string cAuid { get; set; } = null!; + + public string cRefreshToken { get; set; } = null!; +} diff --git a/Projects/SystemX.Core/SystemX.Core.DB/AccountDB/Tables/tRole.cs b/Projects/SystemX.Core/SystemX.Core.DB/AccountDB/Tables/tRole.cs new file mode 100644 index 0000000..6d3ea48 --- /dev/null +++ b/Projects/SystemX.Core/SystemX.Core.DB/AccountDB/Tables/tRole.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace SystemX.Core.DB; + +public partial class tRole +{ + public string cAuid { get; set; } = null!; + + public byte cRoleID { get; set; } + + public string cRoleName { get; set; } = null!; +} diff --git a/Projects/SystemX.Core/SystemX.Core.DB/AccountDB/Tables/tUser.cs b/Projects/SystemX.Core/SystemX.Core.DB/AccountDB/Tables/tUser.cs new file mode 100644 index 0000000..a88ba82 --- /dev/null +++ b/Projects/SystemX.Core/SystemX.Core.DB/AccountDB/Tables/tUser.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace SystemX.Core.DB; + +public partial class tUser +{ + public string cUserID { get; set; } = null!; + + public string cAuid { get; set; } = null!; + + public string cPasswordHashed { get; set; } = null!; + + public byte cState { get; set; } + + public DateTime cCreateDateTime { get; set; } + + public DateTime? cLastLoginDateTime { get; set; } +} diff --git a/Projects/WebApi/WebApi.Library.DBContext/WebApi.Library.DBContext.csproj b/Projects/SystemX.Core/SystemX.Core.DB/SystemX.Core.DB.csproj similarity index 76% rename from Projects/WebApi/WebApi.Library.DBContext/WebApi.Library.DBContext.csproj rename to Projects/SystemX.Core/SystemX.Core.DB/SystemX.Core.DB.csproj index 085266c..ceb816d 100644 --- a/Projects/WebApi/WebApi.Library.DBContext/WebApi.Library.DBContext.csproj +++ b/Projects/SystemX.Core/SystemX.Core.DB/SystemX.Core.DB.csproj @@ -7,15 +7,19 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/Projects/SystemX.Core/SystemX.Core.sln b/Projects/SystemX.Core/SystemX.Core.sln index 15eec93..96344c5 100644 --- a/Projects/SystemX.Core/SystemX.Core.sln +++ b/Projects/SystemX.Core/SystemX.Core.sln @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SystemX.Core", "SystemX.Cor EndProject Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "SystemX.DB.AccountDB", "SystemX.DB.AccountDB\SystemX.DB.AccountDB.sqlproj", "{B44C85FA-BD31-419F-8481-477E166A5753}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemX.Core.DB", "SystemX.Core.DB\SystemX.Core.DB.csproj", "{78647721-F9BD-4876-89D5-95A2A0F3ADA7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -23,6 +25,10 @@ Global {B44C85FA-BD31-419F-8481-477E166A5753}.Release|Any CPU.ActiveCfg = Release|Any CPU {B44C85FA-BD31-419F-8481-477E166A5753}.Release|Any CPU.Build.0 = Release|Any CPU {B44C85FA-BD31-419F-8481-477E166A5753}.Release|Any CPU.Deploy.0 = Release|Any CPU + {78647721-F9BD-4876-89D5-95A2A0F3ADA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {78647721-F9BD-4876-89D5-95A2A0F3ADA7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {78647721-F9BD-4876-89D5-95A2A0F3ADA7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {78647721-F9BD-4876-89D5-95A2A0F3ADA7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Projects/Tools/Tools_Scaffold_AccountDB.bat b/Projects/Tools/Tools_Scaffold_AccountDB.bat index 425d4f8..9a91e5d 100644 --- a/Projects/Tools/Tools_Scaffold_AccountDB.bat +++ b/Projects/Tools/Tools_Scaffold_AccountDB.bat @@ -1,5 +1,4 @@ ::AccountDB -cd ../SystemX.Core/SystemX.Core +cd ../SystemX.Core/SystemX.Core.DB -::WebApi -dotnet ef dbcontext scaffold "server=127.0.0.1; user id=SystemX; password=X; database=AccountDB; TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer --namespace SystemX.Core.DBContext --context-dir DBContext\AccountDB\Context --output-dir DBContext\AccountDB\Tables -f \ No newline at end of file +dotnet ef dbcontext scaffold "server=127.0.0.1; user id=SystemX; password=X; database=AccountDB; TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer --namespace SystemX.Core.DB --context-dir AccountDB\Context --output-dir AccountDB\Tables -f --use-database-names --no-onconfiguring \ No newline at end of file diff --git a/Projects/WebApi/AuthApi/AuthApi.csproj b/Projects/WebApi/AuthApi/AuthApi.csproj index e65ec2b..bd1f83c 100644 --- a/Projects/WebApi/AuthApi/AuthApi.csproj +++ b/Projects/WebApi/AuthApi/AuthApi.csproj @@ -20,7 +20,6 @@ - @@ -28,6 +27,9 @@ ..\..\DLL\SystemX.Core.dll + + ..\..\DLL\SystemX.Core.DB.dll + diff --git a/Projects/WebApi/AuthApi/Controllers/AuthController.cs b/Projects/WebApi/AuthApi/Controllers/AuthController.cs index db71bef..f03895f 100644 --- a/Projects/WebApi/AuthApi/Controllers/AuthController.cs +++ b/Projects/WebApi/AuthApi/Controllers/AuthController.cs @@ -1,5 +1,4 @@ using AuthApi.Services; -using Azure.Core; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.IdentityModel.Tokens; diff --git a/Projects/WebApi/AuthApi/Program.cs b/Projects/WebApi/AuthApi/Program.cs index 60c7c89..2d284d8 100644 --- a/Projects/WebApi/AuthApi/Program.cs +++ b/Projects/WebApi/AuthApi/Program.cs @@ -1,14 +1,9 @@ using AuthApi.Services; using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Storage; using Microsoft.IdentityModel.Tokens; -using System; -using System.ComponentModel; using System.Text; using SystemX.Core.Services; using WebApi.Library.Config; -using WebApi.Library.DBContext.DB.DBContext.AccountDB.Context; string configDir = @"../../Config"; string configFileName = "WebApi.AuthApi.Config.json"; diff --git a/Projects/WebApi/AuthApi/Services/AuthService.cs b/Projects/WebApi/AuthApi/Services/AuthService.cs index ec601de..cabda8f 100644 --- a/Projects/WebApi/AuthApi/Services/AuthService.cs +++ b/Projects/WebApi/AuthApi/Services/AuthService.cs @@ -2,12 +2,9 @@ using SystemX.Core.Services; using SystemX.Core; using WebApi.Library.Config; -using SystemX.Core.Config.Model; using System.Data; using SystemX.Core.DB; using Microsoft.EntityFrameworkCore; -using WebApi.Library.DBContext.DB.DBContext.AccountDB.Context; -using WebApi.Library.DBContext.DB.DBContext.AccountDB.Tables; namespace AuthApi.Services { @@ -45,25 +42,25 @@ namespace AuthApi.Services { if (context is not null) { - var user = await context.TUsers.AsNoTracking().Where(x => x.CUserId.ToLower() == registerModel.UserID.ToLower()).ToListAsync(); + var user = await context.tUsers.AsNoTracking().Where(x => x.cUserID.ToLower() == registerModel.UserID.ToLower()).ToListAsync(); if (user?.Count <= 0) { string auid = Guid.NewGuid().ToString(); //user - TUser newUser = new TUser + tUser newUser = new tUser { - CAuid = auid, - CUserId = registerModel.UserID, - CPasswordHashed = registerModel.Password, - CCreateDateTime = DateTime.Now, - CLastLoginDateTime = new DateTime() + cAuid = auid, + cUserID = registerModel.UserID, + cPasswordHashed = registerModel.Password, + cCreateDateTime = DateTime.Now, + cLastLoginDateTime = new DateTime() }; //role - TRole newUserRole = new TRole + tRole newUserRole = new tRole { - CAuid = auid, - CRoleId = Convert.ToByte(registerModel.Role), - CRoleName = registerModel.Role.ToString() + cAuid = auid, + cRoleID = Convert.ToByte(registerModel.Role), + cRoleName = registerModel.Role.ToString() }; using (var transaction = await context.CreateTransactionAsync()) @@ -119,29 +116,29 @@ namespace AuthApi.Services using (var transaction = await context.CreateTransactionAsync(IsolationLevel.ReadUncommitted)) { //select user - var selectUser = await context.TUsers.AsNoTracking().FirstOrDefaultAsync(x => x.CUserId.ToLower() == loginModel!.UserID!.ToLower()); + var selectUser = await context.tUsers.AsNoTracking().FirstOrDefaultAsync(x => x.cUserID.ToLower() == loginModel!.UserID!.ToLower()); if (selectUser is not null) { - if (selectUser.CPasswordHashed == loginModel?.Password) + if (selectUser.cPasswordHashed == loginModel?.Password) { //select role - var selectRole = await context.TRoles.FindAsync(selectUser.CAuid); + var selectRole = await context.tRoles.FindAsync(selectUser.cAuid); if (selectRole != null) { - response.Role = (UserRole)Enum.Parse(typeof(UserRole), selectRole.CRoleId.ToString()); - response.RoleName = selectRole.CRoleName; + response.Role = (UserRole)Enum.Parse(typeof(UserRole), selectRole.cRoleID.ToString()); + response.RoleName = selectRole.cRoleName; } Session.Add(response); - if (selectUser.CState == (byte)UserState.Active) + if (selectUser.cState == (byte)UserState.Active) { response.EC = ERROR_CODE.EC_OK; } - else if (selectUser.CState == (byte)UserState.Inactive) + else if (selectUser.cState == (byte)UserState.Inactive) { response.EC = ERROR_CODE.EC_USER_LOGIN_INAVTIVE; } - else if (selectUser.CState == (byte)UserState.Block) + else if (selectUser.cState == (byte)UserState.Block) { response.EC = ERROR_CODE.EC_USER_LOGIN_BLOCKED; } @@ -185,7 +182,7 @@ namespace AuthApi.Services { if (context is not null) { - var selectUser = await context.TUsers.AsNoTracking().FirstOrDefaultAsync(x => x.CUserId.ToLower() == loginModel!.UserID!.ToLower()); + var selectUser = await context.tUsers.AsNoTracking().FirstOrDefaultAsync(x => x.cUserID.ToLower() == loginModel!.UserID!.ToLower()); if (selectUser is not null) { using (var transaction = await context.CreateTransactionAsync()) @@ -193,24 +190,24 @@ namespace AuthApi.Services try { //user info - selectUser.CLastLoginDateTime = DateTime.Now; + selectUser.cLastLoginDateTime = DateTime.Now; context.Update(selectUser); //refresh token - var findRefreshToken = await context.TRefreshTokens.AsNoTracking().FirstOrDefaultAsync(x => x.CAuid == selectUser.CAuid); + var findRefreshToken = await context.tRefreshTokens.AsNoTracking().FirstOrDefaultAsync(x => x.cAuid == selectUser.cAuid); //null이면(없으면) add if (findRefreshToken == null) { - await context.AddAsync(new TRefreshToken + await context.AddAsync(new tRefreshToken { - CAuid = selectUser.CAuid, - CRefreshToken = $"{RefreshToken}" + cAuid = selectUser.cAuid, + cRefreshToken= $"{RefreshToken}" }); } //있으면 update else { - findRefreshToken.CRefreshToken = $"{RefreshToken}"; + findRefreshToken.cRefreshToken = $"{RefreshToken}"; context.Update(findRefreshToken); } @@ -264,10 +261,10 @@ namespace AuthApi.Services return response; } - private AccountDbContext? GetAccountDBContext(DbContextProvider provider, int dbID) + private AccountDBContext? GetAccountDBContext(DbContextProvider provider, int dbID) { var connectionString = _configService?.GetConfig()?.DataBase?.Find(x => x.DBID == dbID); - return provider?.GetDBContext($"{connectionString?.DBName}"); + return provider?.GetDBContext($"{connectionString?.DBName}"); } } } diff --git a/Projects/WebApi/WebApi.Library.DBContext/DB/DBContext/AccountDB/Context/AccountDbContext.cs b/Projects/WebApi/WebApi.Library.DBContext/DB/DBContext/AccountDB/Context/AccountDbContext.cs deleted file mode 100644 index 1775f3d..0000000 --- a/Projects/WebApi/WebApi.Library.DBContext/DB/DBContext/AccountDB/Context/AccountDbContext.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.EntityFrameworkCore; -using WebApi.Library.DBContext.DB.DBContext.AccountDB.Tables; - -namespace WebApi.Library.DBContext.DB.DBContext.AccountDB.Context; - -public partial class AccountDbContext : DbContext -{ - public AccountDbContext() - { - } - - public AccountDbContext(DbContextOptions options) - : base(options) - { - } - - public virtual DbSet TRefreshTokens { get; set; } - - public virtual DbSet TRoles { get; set; } - - public virtual DbSet TUsers { get; set; } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.CAuid).HasName("PK__tRefresh__FBF0855465EB95AB"); - - entity.ToTable("tRefreshToken"); - - entity.Property(e => e.CAuid) - .HasMaxLength(250) - .HasColumnName("cAuid"); - entity.Property(e => e.CRefreshToken) - .HasMaxLength(1000) - .HasColumnName("cRefreshToken"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.CAuid).HasName("PK__tRole__FBF085540BB887D7"); - - entity.ToTable("tRole"); - - entity.Property(e => e.CAuid) - .HasMaxLength(250) - .HasColumnName("cAuid"); - entity.Property(e => e.CRoleId).HasColumnName("cRoleID"); - entity.Property(e => e.CRoleName) - .HasMaxLength(20) - .HasColumnName("cRoleName"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.CUserId).HasName("PK__tUser__A75DC19A721265FF"); - - entity.ToTable("tUser"); - - entity.Property(e => e.CUserId) - .HasMaxLength(50) - .HasColumnName("cUserID"); - entity.Property(e => e.CAuid) - .HasMaxLength(250) - .HasColumnName("cAuid"); - entity.Property(e => e.CCreateDateTime).HasColumnName("cCreateDateTime"); - entity.Property(e => e.CLastLoginDateTime).HasColumnName("cLastLoginDateTime"); - entity.Property(e => e.CPasswordHashed) - .HasMaxLength(250) - .HasColumnName("cPasswordHashed"); - entity.Property(e => e.CState).HasColumnName("cState"); - }); - - OnModelCreatingPartial(modelBuilder); - } - - partial void OnModelCreatingPartial(ModelBuilder modelBuilder); -} diff --git a/Projects/WebApi/WebApi.Library.DBContext/DB/DBContext/AccountDB/Tables/TRefreshToken.cs b/Projects/WebApi/WebApi.Library.DBContext/DB/DBContext/AccountDB/Tables/TRefreshToken.cs deleted file mode 100644 index d807df1..0000000 --- a/Projects/WebApi/WebApi.Library.DBContext/DB/DBContext/AccountDB/Tables/TRefreshToken.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace WebApi.Library.DBContext.DB.DBContext.AccountDB.Tables; - -public partial class TRefreshToken -{ - public string CAuid { get; set; } = null!; - - public string CRefreshToken { get; set; } = null!; -} diff --git a/Projects/WebApi/WebApi.Library.DBContext/DB/DBContext/AccountDB/Tables/TRole.cs b/Projects/WebApi/WebApi.Library.DBContext/DB/DBContext/AccountDB/Tables/TRole.cs deleted file mode 100644 index bc6fa15..0000000 --- a/Projects/WebApi/WebApi.Library.DBContext/DB/DBContext/AccountDB/Tables/TRole.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace WebApi.Library.DBContext.DB.DBContext.AccountDB.Tables; - -public partial class TRole -{ - public string CAuid { get; set; } = null!; - - public byte CRoleId { get; set; } - - public string CRoleName { get; set; } = null!; -} diff --git a/Projects/WebApi/WebApi.Library.DBContext/DB/DBContext/AccountDB/Tables/TUser.cs b/Projects/WebApi/WebApi.Library.DBContext/DB/DBContext/AccountDB/Tables/TUser.cs deleted file mode 100644 index 4c4ec32..0000000 --- a/Projects/WebApi/WebApi.Library.DBContext/DB/DBContext/AccountDB/Tables/TUser.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace WebApi.Library.DBContext.DB.DBContext.AccountDB.Tables; - -public partial class TUser -{ - public string CUserId { get; set; } = null!; - - public string CAuid { get; set; } = null!; - - public string CPasswordHashed { get; set; } = null!; - - public byte CState { get; set; } - - public DateTime CCreateDateTime { get; set; } - - public DateTime? CLastLoginDateTime { get; set; } -} diff --git a/Projects/WebApi/WebApi.Library/WebApi.Library.csproj b/Projects/WebApi/WebApi.Library/WebApi.Library.csproj index 8f25caa..c4fe042 100644 --- a/Projects/WebApi/WebApi.Library/WebApi.Library.csproj +++ b/Projects/WebApi/WebApi.Library/WebApi.Library.csproj @@ -14,6 +14,11 @@ True + + + + + ..\..\DLL\SystemX.Core.dll diff --git a/Projects/WebApi/WebApi.sln b/Projects/WebApi/WebApi.sln index 9b91b76..3e5a113 100644 --- a/Projects/WebApi/WebApi.sln +++ b/Projects/WebApi/WebApi.sln @@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AuthApi", "AuthApi\AuthApi. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApi.Library", "WebApi.Library\WebApi.Library.csproj", "{1B109CFE-B860-4125-8F2B-06D95DE85E91}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApi.Library.DBContext", "WebApi.Library.DBContext\WebApi.Library.DBContext.csproj", "{92599205-8D5B-4630-B669-AA390193BC9E}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{C8D5274F-AC00-46C7-1F8D-E88E81087A52}" ProjectSection(SolutionItems) = preProject ..\Config\WebApi.AuthApi.Config.json = ..\Config\WebApi.AuthApi.Config.json @@ -28,10 +26,6 @@ Global {1B109CFE-B860-4125-8F2B-06D95DE85E91}.Debug|Any CPU.Build.0 = Debug|Any CPU {1B109CFE-B860-4125-8F2B-06D95DE85E91}.Release|Any CPU.ActiveCfg = Release|Any CPU {1B109CFE-B860-4125-8F2B-06D95DE85E91}.Release|Any CPU.Build.0 = Release|Any CPU - {92599205-8D5B-4630-B669-AA390193BC9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {92599205-8D5B-4630-B669-AA390193BC9E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {92599205-8D5B-4630-B669-AA390193BC9E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {92599205-8D5B-4630-B669-AA390193BC9E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE