From ddf5a538f42ba1ce675244e93a61974e0a35c4df Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期一, 19 九月 2022 10:29:00 +0800
Subject: [PATCH] 客户缓存

---
 zhengcaioa/Services/IntentionCustomerService.cs |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/zhengcaioa/Services/IntentionCustomerService.cs b/zhengcaioa/Services/IntentionCustomerService.cs
index 3b528fb..e7486d1 100644
--- a/zhengcaioa/Services/IntentionCustomerService.cs
+++ b/zhengcaioa/Services/IntentionCustomerService.cs
@@ -3,6 +3,7 @@
 using System.Linq;
 using System.Text;
 using AutoMapper;
+using CommonToolsCore;
 using DTO;
 using IServices;
 using Microsoft.AspNetCore.Mvc.Rendering;
@@ -103,7 +104,13 @@
                 }
 
             _context.SaveChanges();
-            resultEntity.ReturnID = intentionCustomer.Id;
+
+                var listPosition = _context.IntentionCustomers.Where(r => r.RecStatus == "A").ToList();
+
+              var  intentionCustomerDTOs = _mapper.Map<List<IntentionCustomerDTO>>(listPosition);
+                CacheHelperNetCore.CacheInsert("intentionCustomerDTOs", intentionCustomerDTOs);
+
+                resultEntity.ReturnID = intentionCustomer.Id;
             resultEntity.Result = true;
         }
         catch (Exception ex)
@@ -336,10 +343,17 @@
         /// <returns></returns>
         public List<IntentionCustomerDTO> GetList()
         {
-
+            List<IntentionCustomerDTO> intentionCustomerDTOs = (List<IntentionCustomerDTO>)CacheHelperNetCore.CacheValue("intentionCustomerDTOs");
+            if (intentionCustomerDTOs != null && intentionCustomerDTOs.Count > 0)
+            {
+                return intentionCustomerDTOs;
+            }
 
             var listPosition = _context.IntentionCustomers.Where(r => r.RecStatus == "A").ToList();
 
+            intentionCustomerDTOs = _mapper.Map<List<IntentionCustomerDTO>>(listPosition);
+            CacheHelperNetCore.CacheInsert("intentionCustomerDTOs", intentionCustomerDTOs);
+
             var list = _mapper.Map<List<IntentionCustomerDTO>>(listPosition);
             return list;
         }

--
Gitblit v1.9.1