From 4300549904f56699d9d044321513b859ba6a30db Mon Sep 17 00:00:00 2001 From: cheng19920620 <511180749@qq.com> Date: Wed, 15 Nov 2023 10:47:58 +0800 Subject: [PATCH] =?UTF-8?q?--=E4=BF=AE=E6=94=B9=E8=A7=92=E8=89=B2=E6=9D=83?= =?UTF-8?q?=E9=99=90=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MinioController/MinioApiController.cs | 42 +++++++++++++++---- .../Entity/MinioController/MinioAuthority.cs | 2 +- .../MinioController/MinioRolePermission.cs | 2 +- .../Entity/MinioController/UserModel.cs | 9 +++- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs b/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs index 53ed6e8..ba607f1 100644 --- a/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs +++ b/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs @@ -35,6 +35,7 @@ using NPOI.SS.Formula.Functions; using System.Xml.Linq; using NPOI.HPSF; using IBKLinker_Minio.Common; +using NPOI.POIFS.Crypt.Dsig; namespace IBKLinker_Minio.Controller.MinioController { @@ -166,12 +167,12 @@ namespace IBKLinker_Minio.Controller.MinioController using (IDbContext db = ObjectContainer.GetObject("db")) { string sql = string.Empty; - IList result = new List(); - if (minioAuthority.LimitsAuthorityId >0) + //IList result = new List(); + if (!string.IsNullOrEmpty(minioAuthority.LimitsAuthorityId)) { sql += " and LIMITS_AUTHORITY_ID ='" + minioAuthority.LimitsAuthorityId + "'"; } - request.data = db.Query("select * from MINIO_AUTHORITY where 1=1 " + sql + " ORDER BY ID"); + request.data = db.Query("select a.*,.Role_Name as RoleName from MINIO_AUTHORITY a left join MINIO_ROLE_PERMISSION b on a. LimitsAuthorityId=b.ID where 1=1 " + sql + " ORDER BY PK"); request.code = "0"; } } @@ -480,14 +481,22 @@ namespace IBKLinker_Minio.Controller.MinioController /// /// minio角色权限表 [HttpPost, Route("AddRolePermission")] - public RequestEntity AddRolePermission(MinioRolePermission minioRolePermission) + public RequestEntity AddRolePermission(MinioRolePermission minioRolePermission, List ds) { RequestEntity request = new RequestEntity(); try { + minioRolePermission.Id = Guid.NewGuid().ToString(); + minioRolePermission.LimitsAuthorityId = Guid.NewGuid().ToString(); + foreach (var item in ds) + { + item.LimitsAuthorityId = minioRolePermission.LimitsAuthorityId; + item.CreatorTime = DateTime.Now; + } ///创建数据库连接上下文对象 using (IDbContext db = ObjectContainer.GetObject("db")) { + db.BeginTransaction(); ///拿到表自增长的值赋值给自增长主键pk minioRolePermission.Pk = getPk("S_MINIO_ROLE_PERMISSION", "MINIO_ROLE_PERMISSION"); ///给创建时间赋值 @@ -495,6 +504,8 @@ namespace IBKLinker_Minio.Controller.MinioController ///把需要添加的数据同步到数据库 db.Insert(minioRolePermission); + db.Insert(ds); + db.Commit(); request.code = "0"; } } @@ -510,11 +521,22 @@ namespace IBKLinker_Minio.Controller.MinioController /// /// 修改数据 [HttpPost, Route("UpdateRolePermission")] - public RequestEntity UpdateRolePermission(MinioRolePermission data) + public RequestEntity UpdateRolePermission(MinioRolePermission data,List ds) { RequestEntity request = new RequestEntity(); try { + //data.Id=Guid.NewGuid().ToString(); + if (string.IsNullOrEmpty(data.LimitsAuthorityId)) + { + data.LimitsAuthorityId = Guid.NewGuid().ToString(); + } + + foreach (var item in ds) + { + item.LimitsAuthorityId = data.LimitsAuthorityId; + item.CreatorTime = DateTime.Now; + } ///创建数据库连接上下文对象 using (IDbContext db = ObjectContainer.GetObject("db")) { @@ -523,8 +545,11 @@ namespace IBKLinker_Minio.Controller.MinioController ///启动事务 db.BeginTransaction(); ///给修改时间赋值 - DateTime time = DateTime.Now; + //DateTime time = DateTime.Now; db.Update(data); + //删除历史记录加入新的记录 + db.Query("delete from MINIO_AUTHORITY where LIMITS_AUTHORITY_ID='"+ data.LimitsAuthorityId + "' "); + db.Insert(ds); db.Commit(); request.code = "0"; } @@ -611,11 +636,10 @@ namespace IBKLinker_Minio.Controller.MinioController { string sql = string.Empty; IList result = new List(); - if (minioRolePermission.Id >0) + if (!string.IsNullOrEmpty(minioRolePermission.Id)) { - sql += " and ID =" + minioRolePermission.Id; + sql += " and ID ='" + minioRolePermission.Id+"'"; } - request.data = db.Query("select * from MINIO_ROLE_PERMISSION where 1=1 " + sql + " ORDER BY PK"); request.code = "0"; } diff --git a/IBKLinker-Minio/Entity/MinioController/MinioAuthority.cs b/IBKLinker-Minio/Entity/MinioController/MinioAuthority.cs index e8d4cd8..97f31c9 100644 --- a/IBKLinker-Minio/Entity/MinioController/MinioAuthority.cs +++ b/IBKLinker-Minio/Entity/MinioController/MinioAuthority.cs @@ -25,7 +25,7 @@ namespace IBKLinker_Minio.Entity.MinioController ///权限ID /// [Persistent("LIMITS_AUTHORITY_ID"), DisplayName("权限ID")] - public int LimitsAuthorityId { get; set; } + public string LimitsAuthorityId { get; set; } /// diff --git a/IBKLinker-Minio/Entity/MinioController/MinioRolePermission.cs b/IBKLinker-Minio/Entity/MinioController/MinioRolePermission.cs index 8c02042..b8ed86d 100644 --- a/IBKLinker-Minio/Entity/MinioController/MinioRolePermission.cs +++ b/IBKLinker-Minio/Entity/MinioController/MinioRolePermission.cs @@ -25,7 +25,7 @@ namespace IBKLinker_Minio.Entity.MinioController ///角色ID /// [Persistent("ID"), DisplayName("角色ID")] - public int Id { get; set; } + public string Id { get; set; } /// diff --git a/IBKLinker-Minio/Entity/MinioController/UserModel.cs b/IBKLinker-Minio/Entity/MinioController/UserModel.cs index 2c1ec4d..6c89da5 100644 --- a/IBKLinker-Minio/Entity/MinioController/UserModel.cs +++ b/IBKLinker-Minio/Entity/MinioController/UserModel.cs @@ -8,7 +8,14 @@ using System.Threading.Tasks; namespace IBKLinker_Minio.Entity.MinioController { - internal class UserModel: MinioUser + public class UserModel : MinioUser + { + /// + ///角色 + /// + public string RoleName { get; set; } + } + public class AuthorityModel : MinioAuthority { /// ///角色