diff --git a/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs b/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs index 999b26c..7c2fc1a 100644 --- a/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs +++ b/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs @@ -38,7 +38,7 @@ namespace IBKLinker_Minio.Controller.MinioController /// minio数据库创建文件夹接口 /// [HttpPost, Route("CreateFolder")] - public RequestEntity CreateFolder(List cert) + public RequestEntity CreateFolder(List cert) { RequestEntity result = new RequestEntity(); try @@ -58,7 +58,7 @@ namespace IBKLinker_Minio.Controller.MinioController result.msg = "文件夹创建成功"; } } - catch (Exception ex) + catch (Exception ex) { result.msg = ex.ToString(); result.code = "1"; @@ -70,7 +70,7 @@ namespace IBKLinker_Minio.Controller.MinioController /// minio数据库删除文件夹接口 /// [HttpPost, Route("RemoveFolder")] - public RequestEntity RemoveFolder(List cert) + public RequestEntity RemoveFolder(List cert) { RequestEntity result = new RequestEntity(); try @@ -82,12 +82,12 @@ namespace IBKLinker_Minio.Controller.MinioController var folderName = ""; //文件或文件夹 if (cert[0].Type.ToString() == "0")//判断是删除文件加还是文件 0为文件夹 1为文件 { - folderName = cert[0].Path.ToString() + "/";//文件夹后缀需要加上/ + folderName = cert[0].Path.ToString() + "/";//文件夹后缀需要加上/ state = "文件夹"; } - else + else { - folderName = cert[0].Path.ToString();//文件不需要后缀/ + folderName = cert[0].Path.ToString();//文件不需要后缀/ state = "文件"; } minio.RemoveObjectAsync(buckname, folderName); @@ -117,7 +117,7 @@ namespace IBKLinker_Minio.Controller.MinioController //var folderName = fileneme + "/"; string bucketName = "dayetegang"; // 获取存储桶中的所有对象 - var objects = minio.ListObjectsAsync(bucketName, null, true); + var objects = minio.ListObjectsAsync(bucketName, null, true); // 存储文件夹名称的集合 var folders = new HashSet(); var stream = new MemoryStream(); @@ -141,7 +141,7 @@ namespace IBKLinker_Minio.Controller.MinioController /// minio数据库上传文件接口 /// [HttpPost, Route("FileUpload")] - public RequestEntity FileUpload(List cert) + public RequestEntity FileUpload(List cert) { RequestEntity result = new RequestEntity(); try @@ -149,19 +149,19 @@ namespace IBKLinker_Minio.Controller.MinioController var minio = new MinioClient("172.15.88.212:9000", "minioadmin", "minioadmin"); string bucketName = "dayetegang"; int a = 0; - for (int i = 0; i < cert[0].FileData.Length; i++) + for (int i = 0; i < cert[0].FileData.Length; i++) { - var contentType = "application/"+ cert[0].FileType[i].ToString(); + var contentType = "application/" + cert[0].FileType[i].ToString(); string strBase64 = cert[0].FileData[i].Split(',')[1];//取文件base64流数据 byte[] bt = Convert.FromBase64String(strBase64);//获取html base64 minio.PutObjectAsync(bucketName, cert[0].StoragePath.ToString(), new MemoryStream(bt), bt.Length, contentType); a++; } result.code = "0"; - result.msg = "共计成功上传"+a+"个文件!"; + result.msg = "共计成功上传" + a + "个文件!"; } - catch (Exception ex) + catch (Exception ex) { result.code = "1"; result.msg = ex.ToString(); @@ -175,9 +175,9 @@ namespace IBKLinker_Minio.Controller.MinioController /// /// 添加minio权限表 /// - /// 合金配比策略一基表Model + /// 权限表 [HttpPost, Route("AddAuthority")] - public RequestEntity AddAuthority(MinioAuthority cS_B04_PL_STEEL_ROW_COMP) + public RequestEntity AddAuthority(MinioAuthority minioAuthority) { RequestEntity request = new RequestEntity(); try @@ -186,12 +186,12 @@ namespace IBKLinker_Minio.Controller.MinioController using (IDbContext db = ObjectContainer.GetObject("db")) { ///拿到表自增长的值赋值给自增长主键pk - cS_B04_PL_STEEL_ROW_COMP.Id = getPk("S_MINIO_AUTHORITY", "MINIO_AUTHORITY"); + minioAuthority.Id = getPk("S_MINIO_AUTHORITY", "MINIO_AUTHORITY"); ///给创建时间赋值 - cS_B04_PL_STEEL_ROW_COMP.CreatorTime = DateTime.Now; - + minioAuthority.CreatorTime = DateTime.Now; + ///把需要添加的数据同步到数据库 - db.Insert(cS_B04_PL_STEEL_ROW_COMP); + db.Insert(minioAuthority); request.code = "0"; } } @@ -288,7 +288,7 @@ namespace IBKLinker_Minio.Controller.MinioController IList result = new List(); if (!string.IsNullOrEmpty(minioAuthority.LimitsAuthorityId.ToString())) { - sql += " and LIMITS_AUTHORITY_ID ='" + minioAuthority.LimitsAuthorityId +"'"; + sql += " and LIMITS_AUTHORITY_ID ='" + minioAuthority.LimitsAuthorityId + "'"; } request.data = db.Query("select * from MINIO_AUTHORITY where 1=1 " + sql + " ORDER BY PK"); @@ -309,7 +309,7 @@ namespace IBKLinker_Minio.Controller.MinioController /// /// 添加minio角色表 /// - /// 合金配比策略一基表Model + /// 角色表 [HttpPost, Route("AddUSER")] public RequestEntity AddUSER(MinioUser minioUser) { @@ -422,7 +422,7 @@ namespace IBKLinker_Minio.Controller.MinioController IList result = new List(); if (!string.IsNullOrEmpty(minioUser.UserName.ToString())) { - sql += " and USER_NAME ='" + minioUser.UserName+"'"; + sql += " and USER_NAME ='" + minioUser.UserName + "'"; } request.data = db.Query("select * from MINIO_USER where 1=1 " + sql + " ORDER BY PK"); @@ -439,11 +439,11 @@ namespace IBKLinker_Minio.Controller.MinioController #endregion - #region minio文件关联表表 + #region minio文件关联表 /// /// 添加minio角色表 /// - /// 合金配比策略一基表Model + /// 文件关联表 [HttpPost, Route("AddFileassociation")] public RequestEntity AddFileassociation(MinioFileassociation minioFileassociation) { @@ -556,7 +556,7 @@ namespace IBKLinker_Minio.Controller.MinioController IList result = new List(); if (!string.IsNullOrEmpty(minioFileassociation.FileName.ToString())) { - sql += " and FILE_NAME ='" + minioFileassociation.FileName+"'"; + sql += " and FILE_NAME ='" + minioFileassociation.FileName + "'"; } request.data = db.Query("select * from MINIO_FILEASSOCIATION where 1=1 " + sql + " ORDER BY PK"); @@ -824,7 +824,7 @@ namespace IBKLinker_Minio.Controller.MinioController IList result = new List(); if (!string.IsNullOrEmpty(minioStoragePath.FileName.ToString())) { - sql += " and FILE_NAME ='" + minioStoragePath.FileName+"'"; + sql += " and FILE_NAME ='" + minioStoragePath.FileName + "'"; } request.data = db.Query("select * from MINIO_STORAGE_PATH where 1=1 " + sql + " ORDER BY PK"); @@ -847,21 +847,22 @@ namespace IBKLinker_Minio.Controller.MinioController /// /// /// - public List GetMenuTree(string PK = "") + [HttpPost, Route("GetMenuTree")] + public List GetMenuTree(string PK = "") { List date = new List(); using (IDbContext db = ObjectContainer.GetObject("db")) { string sql = string.Empty; - + if (!string.IsNullOrEmpty(PK)) { - sql += " and UPK =" +int.Parse(PK); + sql += " and UPK =" + int.Parse(PK); } - date = db.Query("select * from MINIO_STORAGE_PATH where 1=1 " + sql + " ORDER BY PK").ToList(); - + date = db.Query("select * from MINIO_STORAGE_PATH where 1=1 " + sql + " ORDER BY PK").ToList(); + } return date; } @@ -869,7 +870,8 @@ namespace IBKLinker_Minio.Controller.MinioController /// 获取根目录和根目录下一级得菜单信息 /// /// - public RequestEntity GetRecursion() + [HttpPost, Route("GetRecursion")] + public RequestEntity GetRecursion() { RequestEntity request = new RequestEntity(); try @@ -916,18 +918,49 @@ namespace IBKLinker_Minio.Controller.MinioController request.code = "1"; throw; } - + return request; } - public bool GetEmpower(string UserID,string FileName,string EmpowerType) + /// + /// 权限查询 + /// + /// + /// + /// + /// + [HttpPost, Route("GetEmpower")] + public bool GetEmpower(string UserID, string FileName, string EmpowerType) { + bool Empower=false; //用户ID,文件ID,文件操作类型(查看/移动) + using (IDbContext db = ObjectContainer.GetObject("db")) + { + string sql = string.Empty; + if (!string.IsNullOrEmpty(UserID)) + { + sql += "a.USER_ID=" + UserID; + } + if (!string.IsNullOrEmpty(FileName)) + { + sql += "d.File_Name='" + FileName + "'"; + } + if (!string.IsNullOrEmpty(FileName)) + { + sql += "b." + EmpowerType + "=1"; + } + + List dt = db.Query("select a.* from minio_user a left join minio_role_permission b on a.role_id=b.id left join minio_authority c on b.limits_authority_id=c.limits_authority_id left join minio_storage_path d on c.file_id=d.pk where 1=1 " + sql + " ORDER BY a.creator_time").ToList(); + if (dt.Count > 0) + { + Empower = true; + } + } //通过用户ID查询用户得角色ID, //判断当前角色是否有操作权限 //通过角色ID查询用户有权限得文件夹 - return false; + return Empower; } #endregion #region 公用方法