Răsfoiți Sursa

(pushReport)增加删除功能

dodo hold 1 an în urmă
părinte
comite
1e9bc256d5

+ 22 - 54
molilian.api/Controllers/admin/DataReportController.cs

@@ -122,6 +122,27 @@ namespace molilian.api.Controllers
         }
 
 
+        [HttpPost]
+        public async Task<ActionResult> delete([FromBody] JsonElement form)
+        {
+            int id = form.Read<int>("id");
+
+            using var conn = DBContext.GetOpenConnection();
+            var item = new DBContext.Table(conn, "push_data_report").Get<PushDataReportDTO>("id=@id", new { id });
+            if (item == null) return new APIResult(new { data = new { success = false, msg = "删除失败,记录不存在" } });
+
+            // 临时锁定所有口令推送数据
+            if (item.type == 1) return new APIResult(new { data = new { success = false, msg = "删除失败,类型错误" } });
+
+            var result = new DBContext.Table("push_data_report").Delete("id=@id", new { id });
+            bool success = result > 0;
+            return new APIResult(new
+            {
+                data = new { success, msg = success ? "删除成功" : "删除失败" },
+            });
+        }
+
+
         [HttpPost]
         public async Task<ActionResult> save([FromBody] JsonElement from)
         {
@@ -142,7 +163,6 @@ namespace molilian.api.Controllers
                 // 临时锁定所有口令推送数据
                 if (type == 1) return new APIResult(new { data = new { success = false, msg = "更新失败,类型错误" } });
 
-
                 var update = new DBContext.Table("push_data_report");
 
                 //PushDataReportCore core = new();
@@ -156,6 +176,7 @@ namespace molilian.api.Controllers
                 update.Fill(from);
                 update.Add("report_date", report_date);
                 update.Loader<bool>("is_settlement");
+                update.Loader<int>("status");
                 update.Loader<int>("type");
                 update.Loader<int>("sub_type");
                 update.Loader<int>("platform");
@@ -180,9 +201,6 @@ namespace molilian.api.Controllers
 
                     result = update.Create();
                     success = result > 0;
-
-
-
                     if (success)
                     {
                         OperationLogCore.LogOperation(token.AccessKey, clientIp, $"push_data_report:{report_date}:{platform}:{type}", from.Convert2Json(), "新增");
@@ -190,7 +208,6 @@ namespace molilian.api.Controllers
                 }
                 else
                 {
-
                     var item = new DBContext.Table(conn, "push_data_report").Get<PushDataReportDTO>("id=@id", new { id });
                     if (item == null) return new APIResult(new { data = new { success = false, msg = "更新失败,记录不存在" } });
 
@@ -219,55 +236,6 @@ namespace molilian.api.Controllers
         }
 
 
-        [HttpPost]
-        public async Task<ActionResult> save2([FromBody] PushDataReportDTO data)
-        {
-            var clientIp = _accessor.HttpContext.GetUserIp();
-            var token = provider.Get(_accessor.HttpContext);
-
-            using var conn = DBContext.GetOpenConnection();
-            int result = 0;
-            bool success = false;
-
-            try
-            {
-
-                if (data.id == 0)
-                {
-                    result = (int)conn.Insert(data);
-                    success = result > 0;
-                    if (success)
-                    {
-                        OperationLogCore.LogOperation(token.AccessKey, clientIp, $"push_data_report:{data.report_date}:{data.platform}:{data.distribution}", data.Convert2Json(), "新增");
-                    }
-                }
-                else
-                {
-                    var item = new DBContext.Table(conn, "push_data_report").Get<PushDataReportDTO>("id=@id", new { data.id });
-                    if (item == null) return new APIResult(new { data = new { success = false, msg = "更新失败,记录不存在" } });
-
-                    result = (int)conn.Replace(data);
-                    string desc = ObjectComparer.PrintCompareToString(item, data).Trim();
-                    success = result > 0;
-                    if (success)
-                    {
-                        OperationLogCore.LogOperation(token.AccessKey, clientIp, $"push_data_report:{data.report_date}:{data.platform}:{data.distribution}", item.Convert2Json(), desc);
-                    }
-                }
-
-            }
-            catch (Exception ex)
-            {
-                return new APIResult(new
-                {
-                    data = new { success = false, msg = $"更新失败,{ex.Message}" },
-                });
-            }
-            return new APIResult(new
-            {
-                data = new { success, msg = success ? "更新成功" : "更新失败,请检查输入信息" },
-            });
-        }
 
 
     }

Fișier diff suprimat deoarece este prea mare
+ 0 - 0
molilian.api/Properties/PublishProfiles/latest.pubxml.user


Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff