Bladeren bron

修复文件下载方法并优化查询逻辑

- 更新 `FeeAuditOtherFileDownlaod` 方法的参数错误信息。
- 添加常量 `baseUrl` 用于文件下载链接。
- 使用 `_sqlSugar` 进行联接查询以获取相关信息。
- 优化生成下载链接的逻辑。
- 统一返回的错误信息格式。
Lyyyi 1 week geleden
bovenliggende
commit
66191d1938
1 gewijzigde bestanden met toevoegingen van 18 en 7 verwijderingen
  1. 18 7
      OASystem/OASystem.Api/Controllers/GroupsController.cs

+ 18 - 7
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -4335,17 +4335,28 @@ FROM
         /// <returns></returns>
         [HttpGet("{id}")]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1,int.MaxValue,ErrorMessage ="")]int id)
+        public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1,int.MaxValue,ErrorMessage ="请传入有效的ID")]int id)
         {
-            var otherInfo = await _decreasePaymentsRep.Query(x => x.Id == id && x.IsDel == 0).FirstAsync();
-            string url = "暂无附件!";
-            if (otherInfo != null)
+            //网站域名
+            const string baseUrl = "http://132.232.92.186:24/Office/GrpFile/%E5%9B%A2%E7%BB%84%E5%A2%9E%E5%87%8F%E6%AC%BE%E9%A1%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6/";
+
+            var otherInfo = await _decreasePaymentsRep._sqlSugar
+                .Queryable<Grp_DecreasePayments>()
+                .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
+                .Where(((x, y) =>  x.IsDel == 0 && y.IsDel == 0))
+                .Select((x, y) => new
+                {
+                    x.Id,
+                    x.FilePath
+                })
+                .FirstAsync();
+            if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
             {
-                url = $"http://132.232.92.186:24/Office/GrpFile/%E5%9B%A2%E7%BB%84%E5%A2%9E%E5%87%8F%E6%AC%BE%E9%A1%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6/{otherInfo.FilePath}";
-                return Ok(JsonView(true,  "操作成功!", url));
+                var url = $"{baseUrl}{otherInfo.FilePath}";
+                return Ok(JsonView(true, "操作成功!", url));
             }
 
-            return Ok(JsonView(false, url));
+            return Ok(JsonView(false, "暂无附件"));
         }
 
         #endregion