student il y a 2 semaines
Parent
commit
8f90e08679

+ 28 - 0
KITTY_FALL.sql

@@ -3557,6 +3557,18 @@ STORAGE (
 )
 )
    USABLE;
    USABLE;
 
 
+-- ----------------------------
+-- Primary Key structure for table PERMISSION
+-- ----------------------------
+ALTER TABLE "PERMISSION" MODIFY ("ID" NOT NULL);
+ALTER TABLE "PERMISSION" ADD CONSTRAINT "PERMISSION_PK" PRIMARY KEY ("ID");
+
+-- ----------------------------
+-- Primary Key structure for table ROLE
+-- ----------------------------
+ALTER TABLE "ROLE" MODIFY ("ID" NOT NULL);
+ALTER TABLE "ROLE" ADD CONSTRAINT "ROLE_PK" PRIMARY KEY ("ID");
+
 -- ----------------------------
 -- ----------------------------
 -- Primary Key structure for table ROLE_PERMISSION
 -- Primary Key structure for table ROLE_PERMISSION
 -- ----------------------------
 -- ----------------------------
@@ -3652,7 +3664,23 @@ STORAGE (
   FLASH_CACHE DEFAULT
   FLASH_CACHE DEFAULT
 )
 )
    USABLE;
    USABLE;
+ALTER TABLE "ROLE_PERMISSION" ADD CONSTRAINT "ROLE_PERMISSION_PK" PRIMARY KEY ("ID");
+-- ----------------------------
+-- Primary Key structure for table PERMISSION
+-- ----------------------------
+ALTER TABLE "PERMISSION" MODIFY ("ID" NOT NULL);
+ALTER TABLE "PERMISSION" ADD CONSTRAINT "PERMISSION_PK" PRIMARY KEY ("ID");
+
+-- ----------------------------
+-- Primary Key structure for table ROLE
+-- ----------------------------
+ALTER TABLE "ROLE" MODIFY ("ID" NOT NULL);
+ALTER TABLE "ROLE" ADD CONSTRAINT "ROLE_PK" PRIMARY KEY ("ID");
 
 
+-- ----------------------------
+-- Primary Key structure for table ROLE_PERMISSION
+-- ----------------------------
+ALTER TABLE "ROLE_PERMISSION" ADD CONSTRAINT "ROLE_PERMISSION_PK" PRIMARY KEY ("ID");
 -- ----------------------------
 -- ----------------------------
 -- Foreign Keys structure for table GAME_LEVEL_ATTEMPT
 -- Foreign Keys structure for table GAME_LEVEL_ATTEMPT
 -- ----------------------------
 -- ----------------------------

+ 6 - 6
Kitty_Fall/Kitty_Fall/Database/Database/ModelContext.cs

@@ -1703,9 +1703,9 @@ public partial class ModelContext : DbContext
 
 
         modelBuilder.Entity<Permission>(entity =>
         modelBuilder.Entity<Permission>(entity =>
         {
         {
-            entity
-                .HasNoKey()
-                .ToTable("PERMISSION");
+            entity.HasKey(e => e.Id).HasName("PERMISSION_PK");
+
+            entity.ToTable("PERMISSION");
 
 
             entity.Property(e => e.Action)
             entity.Property(e => e.Action)
                 .HasMaxLength(200)
                 .HasMaxLength(200)
@@ -1859,9 +1859,9 @@ public partial class ModelContext : DbContext
 
 
         modelBuilder.Entity<Role>(entity =>
         modelBuilder.Entity<Role>(entity =>
         {
         {
-            entity
-                .HasNoKey()
-                .ToTable("ROLE");
+            entity.HasKey(e => e.Id).HasName("ROLE_PK");
+
+            entity.ToTable("ROLE");
 
 
             entity.Property(e => e.Code)
             entity.Property(e => e.Code)
                 .HasMaxLength(20)
                 .HasMaxLength(20)

+ 1 - 1
Kitty_Fall/Kitty_Fall/Database/Database/Role.cs

@@ -5,7 +5,7 @@ namespace Database.Database;
 
 
 public partial class Role
 public partial class Role
 {
 {
-    public decimal? Id { get; set; }
+    public decimal Id { get; set; }
 
 
     public string? Name { get; set; }
     public string? Name { get; set; }
 
 

+ 1 - 1
Kitty_Fall/Kitty_Fall/Kitty_Fall.Cms/Controllers/CmsAccountController.cs

@@ -177,7 +177,7 @@ public class CmsAccountController : CmsAuthorizedController
                 return Json(new { errorCode = 400, message = "Role code is required." });
                 return Json(new { errorCode = 400, message = "Role code is required." });
             }
             }
 
 
-            if (role.Id == null || role.Id == 0)
+            if (role.Id == 0)
             {
             {
                 var newId = await Database.DbLogic.GenIdAsync(_db, "ROLE_SEQ") ?? 0;
                 var newId = await Database.DbLogic.GenIdAsync(_db, "ROLE_SEQ") ?? 0;
                 await _db.Database.ExecuteSqlInterpolatedAsync($@"
                 await _db.Database.ExecuteSqlInterpolatedAsync($@"

+ 0 - 8
Kitty_Fall/Kitty_Fall/Kitty_Fall.Cms/Helpers/CmsSecurityHelper.cs

@@ -196,14 +196,6 @@ public static class CmsSecurityHelper
                 "/monthlywinner/updatestatus"
                 "/monthlywinner/updatestatus"
             }
             }
         },
         },
-        //new()
-        //{
-        //    Key = EmployersMenuKey,
-        //    Title = "Companies",
-        //    Url = "/Admin/Companies",
-        //    IconClass = "fas fa-building",
-        //    PermissionPaths = new List<string> { "/admin/companies", "/admin/employers" }
-        //},
         new()
         new()
         {
         {
             Key = AccountsMenuKey,
             Key = AccountsMenuKey,

+ 22 - 1
Kitty_Fall/Kitty_Fall/Kitty_Fall.Cms/Program.cs

@@ -56,9 +56,30 @@ if (!app.Environment.IsDevelopment())
     app.UseHsts();
     app.UseHsts();
 }
 }
 
 
-var pathBase = builder.Configuration["PathBase"];
+var pathBase = builder.Configuration["PathBase"]?.Trim().TrimEnd('/');
 if (!string.IsNullOrWhiteSpace(pathBase))
 if (!string.IsNullOrWhiteSpace(pathBase))
 {
 {
+    if (!pathBase.StartsWith('/'))
+    {
+        pathBase = $"/{pathBase}";
+    }
+
+    // launchSettings chi mo applicationUrl (duong dan "/"). Redirect tai runtime
+    // de URL khoi dong luon bam theo PathBase trong appsettings cua moi moi truong.
+    app.Use(async (context, next) =>
+    {
+        if (context.Request.Path == "/"
+            || context.Request.Path == pathBase
+            || context.Request.Path == $"{pathBase}/")
+        {
+            // Dung URL tuong doi de domain, protocol va port tu dong theo request.
+            context.Response.Redirect($"{pathBase}/Home/Login");
+            return;
+        }
+
+        await next();
+    });
+
     app.UsePathBase(pathBase);
     app.UsePathBase(pathBase);
 }
 }
 
 

+ 1 - 1
Kitty_Fall/Kitty_Fall/Kitty_Fall.Cms/appsettings.json

@@ -1,7 +1,7 @@
 {
 {
   "PathBase": "/cms",
   "PathBase": "/cms",
   // "Connection": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1539))(CONNECT_DATA=(SERVICE_NAME=ORA12C)));User Id=myjob;Password=123456;Connection Timeout=120;",
   // "Connection": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1539))(CONNECT_DATA=(SERVICE_NAME=ORA12C)));User Id=myjob;Password=123456;Connection Timeout=120;",
-  "Connection": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORA12C)));User Id=myjob;Password=HHwx4ISVN51cDam;Connection Timeout=120;",
+  "Connection": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1539))(CONNECT_DATA=(SERVICE_NAME=ORA12C)));User Id=Kitty_Fall;Password=123456;Connection Timeout=120;",
   "Logging": {
   "Logging": {
     "LogLevel": {
     "LogLevel": {
       "Default": "Information",
       "Default": "Information",

+ 13 - 1
database_usesAndSub.sql

@@ -944,6 +944,18 @@ Insert into WS_USER (WS_USER_ID,USERNAME,PASSWORD,IP_ADDRESS) values (1,'ws_myjo
   BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) ENABLE;
   BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) ENABLE;
   ALTER TABLE "ACCOUNT_USER" ADD CONSTRAINT "SYS_C00135670" CHECK ("ID" IS NOT NULL) ENABLE;
   ALTER TABLE "ACCOUNT_USER" ADD CONSTRAINT "SYS_C00135670" CHECK ("ID" IS NOT NULL) ENABLE;
 --------------------------------------------------------
 --------------------------------------------------------
+--  Constraints for Table PERMISSION
+--------------------------------------------------------
+
+  ALTER TABLE "PERMISSION" MODIFY ("ID" NOT NULL ENABLE);
+  ALTER TABLE "PERMISSION" ADD CONSTRAINT "PERMISSION_PK" PRIMARY KEY ("ID") ENABLE;
+--------------------------------------------------------
+--  Constraints for Table ROLE
+--------------------------------------------------------
+
+  ALTER TABLE "ROLE" MODIFY ("ID" NOT NULL ENABLE);
+  ALTER TABLE "ROLE" ADD CONSTRAINT "ROLE_PK" PRIMARY KEY ("ID") ENABLE;
+--------------------------------------------------------
 --  Constraints for Table ROLE_PERMISSION
 --  Constraints for Table ROLE_PERMISSION
 --------------------------------------------------------
 --------------------------------------------------------
 
 
@@ -1039,4 +1051,4 @@ BEGIN
     END IF;
     END IF;
 
 
     COMMIT;
     COMMIT;
-END ADD_TURN;
+END ADD_TURN;