Ver código fonte

优化代码格式和逻辑,新增属性

在 `StatisticsController.cs` 中,调整了 `defaultParentIds` 列表格式,改为多行以提高可读性,并优化了查询链式调用的格式。同时,简化了 `y.IsChecked` 的赋值逻辑,并调整了返回的 JSON 结构以确保正确返回数据。

在 `DailypaymentView.cs` 中,添加了 `using Org.BouncyCastle.Crypto;` 引用,并在 `DailypaymentSubTypeView` 类中新增了 `IsChecked` 属性,标记为忽略数据库映射,以便在前端使用。
Lyyyi 2 semanas atrás
pai
commit
090d93f395

+ 19 - 21
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -5657,43 +5657,41 @@ Group By CnName");
             #endregion
             if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 3) // web/Android/IOS
             {
-                var defaultParentIds = new List<int>() {
-                                                        48,//  人员费用
-                                                        49,//  办公费用
-                                                        50,//  销售费用
-                                                        51,//  其他费用
-                                                        55,//  大运会
-                                                         };
+                var defaultParentIds = new List<int>()
+                {
+                    48,//  人员费用
+                    49,//  办公费用
+                    50,//  销售费用
+                    51,//  其他费用
+                    55,//  大运会
+                };
 
                 var dailypaymentTypeData = await RedisRepository.RedisFactory
-                                                                .CreateRedisRepository()
-                                                                .StringGetAsync<List<int>>("DailypaymentTypeData") ?? new List<int>();
+                    .CreateRedisRepository()
+                    .StringGetAsync<List<int>>("DailypaymentTypeData") ?? new List<int>();
 
                 var dailyTypeData = await _sqlSugar.Queryable<DailypaymentParentTypeView>()
-                                                   .Includes(x => x.SubData)
-                                                   .Where(x => defaultParentIds.Contains(x.Id))
-                                                   .ToListAsync();
+                    .Includes(x => x.SubData)
+                    .Where(x => defaultParentIds.Contains(x.Id))
+                    .ToListAsync();
                 dailyTypeData.ForEach(x =>
                 {
                     x.SubData.ForEach(y =>
                     {
                         int currId = dailypaymentTypeData.Find(z => z == y.Id);
-                        y.IsChecked = currId == 0 ? false : true;
+                        y.IsChecked = currId != 0;
                     });
                 });
 
 
                 var companyData = await _sqlSugar.Queryable<Sys_Company>()
-                                                 .Where(x => x.IsDel == 0)
-                                                 .Select(x => new { id = x.Id, name = x.CompanyName })
-                                                 .ToListAsync();
+                    .Where(x => x.IsDel == 0)
+                    .Select(x => new { id = x.Id, name = x.CompanyName })
+                    .ToListAsync();
 
-                return Ok(JsonView(true, "查询成功!", new { dailyTypeData = dailyTypeData, companyData = companyData }));
-            }
-            else
-            {
-                return Ok(JsonView(false, "查询失败"));
+                return Ok(JsonView(true, "查询成功!", new { dailyTypeData, companyData }));
             }
+            else return Ok(JsonView(false, "查询失败"));
         }
 
         /// <summary>

+ 3 - 2
OASystem/OASystem.Domain/ViewModels/Statistics/DailypaymentView.cs

@@ -1,4 +1,5 @@
-using System;
+using Org.BouncyCastle.Crypto;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -26,12 +27,12 @@ namespace OASystem.Domain.ViewModels.Statistics
     [SqlSugar.SugarTable("Sys_SetData")]
     public class DailypaymentSubTypeView
     {
-
         [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
         public int Id { get; set; }
         public int STid { get; set; }
         public string Name { get; set; }
 
+        [SqlSugar.SugarColumn(IsIgnore = true)]
         public bool IsChecked { get; set; } = false;
     }