Ver código fonte

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

amigotrip 7 meses atrás
pai
commit
1686bb4b4d

+ 64 - 2
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -3571,6 +3571,7 @@ namespace OASystem.API.Controllers
         public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
         {
             var jw = JsonView(false);
+            long M = 1024 * 1024;
 
             if (dto.Files == null || dto.Files.Count == 0)
             {
@@ -3578,6 +3579,12 @@ namespace OASystem.API.Controllers
                 return Ok(jw);
             }
 
+            if (dto.Files.Sum(x=>x.Length) > 20 * M)
+            {
+                jw.Msg = "文件大小超过20M!";
+                return Ok(jw);
+            }
+
             //var nameSp = dto.File.FileName.Split(".");
             //if (nameSp.Length < 2)
             //{
@@ -3670,14 +3677,32 @@ namespace OASystem.API.Controllers
             return Ok(jw);
         }
 
+        /// <summary>
+        /// 查询各模块已保存文件
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
         [HttpPost]
 
         public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
         {
-            var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid).ToList();
-            return Ok(JsonView(true, "success", dbQuery.Select(x => x.FileName)));
+            var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
+                .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
+                .WhereIF(dto.UserId != -1,x=>x.CreateUserId == dto.UserId)
+                .ToList();
+            return Ok(JsonView(true, "success", dbQuery.Select(x => new
+            {
+                x.FileName,
+                x.Id,
+                Url =  x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath")),
+            })));
         }
 
+        /// <summary>
+        /// 下载该团组下的所有文件
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
         [HttpPost]
         public IActionResult ExportGroupZip(ExportGroupZipDto dto)
         {
@@ -3724,6 +3749,43 @@ namespace OASystem.API.Controllers
             return Ok(jw);
         }
 
+        /// <summary>
+        /// 删除该团组下的指定文件
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
+        {
+            var jw = JsonView(false);
+            var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
+            if (sing == null)
+            {
+                jw.Msg = "暂无";
+                return Ok(jw);
+            }
+
+            if (System.IO.File.Exists(sing.FilePath))
+            {
+                try
+                {
+                    System.IO.File.Delete(sing.FilePath);
+                }
+                catch (Exception ex)
+                {
+                    jw.Msg = "删除失败!" + ex.Message;
+                    return Ok(jw);
+                }
+            }
+
+            sing.IsDel = 1;
+            sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+            sing.DeleteUserId = dto.UserId;
+            _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
+            jw = JsonView(true, "删除成功!");
+            return Ok(jw);
+        }
+
         #endregion
 
         #region 团组英文资料

+ 8 - 0
OASystem/OASystem.Domain/Dtos/FileDto/FileDto.cs

@@ -41,10 +41,18 @@ namespace OASystem.Domain.Dtos.FileDto
         public int Ctable { get; set; }
         public int Diid { get; set; }
         public int Cid { get; set; }
+
+        public int UserId { get; set; }
     }
 
     public class ExportGroupZipDto
     {
         public int Diid { get; set; }
     }
+
+    public class DeleteGroupFileDto
+    {
+        public int Id { get; set; }
+        public int UserId { get; set; }
+    }
 }