From 19b41acc6fb5c5699d846fcf56e31d762a3ac9ed Mon Sep 17 00:00:00 2001
From: 张宇恒 <bxyun0@163.com>
Date: 星期五, 01 四月 2022 10:36:03 +0800
Subject: [PATCH] 产品报告书部分

---
 force-app/main/default/classes/FollowTriggerHandler.cls              |   36 ++++++++++++++++++
 force-app/main/default/triggers/FollowTrigger.trigger                |    4 ++
 force-app/main/default/classes/FollowTriggerHandlerTest.cls          |   14 +++++++
 force-app/main/default/classes/FollowTriggerHandler.cls-meta.xml     |    5 ++
 force-app/main/default/classes/FollowTriggerHandlerTest.cls-meta.xml |    5 ++
 force-app/main/default/triggers/FollowTrigger.trigger-meta.xml       |    5 ++
 6 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/force-app/main/default/classes/FollowTriggerHandler.cls b/force-app/main/default/classes/FollowTriggerHandler.cls
new file mode 100644
index 0000000..ac1391f
--- /dev/null
+++ b/force-app/main/default/classes/FollowTriggerHandler.cls
@@ -0,0 +1,36 @@
+public without sharing class FollowTriggerHandler extends Oly_TriggerHandler{
+	private Map<Id, Inquiry_form__c> newMap;
+    private Map<Id, Inquiry_form__c> oldMap;
+    private List<Inquiry_form__c> newList;
+    private List<Inquiry_form__c> oldList;
+	public FollowTriggerHandler() {
+		this.newMap = (Map<Id, Inquiry_form__c>) Trigger.newMap;
+        this.oldMap = (Map<Id, Inquiry_form__c>) Trigger.oldMap;
+        this.newList = (List<Inquiry_form__c>) Trigger.new;
+        this.oldList = (List<Inquiry_form__c>) Trigger.old;
+        Integer i = 0;
+	}
+	protected override void afterUpdate() {
+		followUpdate();
+	}
+	protected override void afterInsert() {
+		followUpdate();
+	}
+	public void followUpdate(){
+		Map<SObject,List<String>> data = new Map<SObject,List<String>>();
+		List<ReportMemo__c> rmList = new List<ReportMemo__c>();
+		for (Inquiry_form__c inquiry : newList) {
+			List<String> strList = new List<String>();
+			Inquiry_form__c oldInquiry = null;
+			if (Trigger.isUpdate) {
+			    oldInquiry = oldMap.get(inquiry.Id);
+			}
+			if (oldInquiry == null || inquiry.Product1__c != oldInquiry.Product1__c) {
+			    strList.add('Product1__c');
+			}
+			data.put(inquiry, strList);
+		}
+		SplitOptionListUtil util = new SplitOptionListUtil();
+		util.makeObject(data);
+	}
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/FollowTriggerHandler.cls-meta.xml b/force-app/main/default/classes/FollowTriggerHandler.cls-meta.xml
new file mode 100644
index 0000000..f3bac1f
--- /dev/null
+++ b/force-app/main/default/classes/FollowTriggerHandler.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>41.0</apiVersion>
+    <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/FollowTriggerHandlerTest.cls b/force-app/main/default/classes/FollowTriggerHandlerTest.cls
new file mode 100644
index 0000000..868f027
--- /dev/null
+++ b/force-app/main/default/classes/FollowTriggerHandlerTest.cls
@@ -0,0 +1,14 @@
+@isTest
+private class FollowTriggerHandlerTest {
+    @isTest static void test_method_1() {
+
+        Inquiry_form__c inquiryform = new Inquiry_form__c();
+        inquiryform.Name = '2019102101';
+        inquiryform.Request1__c = '闇�瑕佹姤浠�';
+        inquiryform.Product1__c = '瓒呭0';
+        inquiryform.Opportunity_Division__c = '璇环';
+        insert inquiryform;
+        inquiryform.Product1__c = '鑳冮暅';
+        upsert inquiryform;
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/FollowTriggerHandlerTest.cls-meta.xml b/force-app/main/default/classes/FollowTriggerHandlerTest.cls-meta.xml
new file mode 100644
index 0000000..f3bac1f
--- /dev/null
+++ b/force-app/main/default/classes/FollowTriggerHandlerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>41.0</apiVersion>
+    <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/triggers/FollowTrigger.trigger b/force-app/main/default/triggers/FollowTrigger.trigger
new file mode 100644
index 0000000..2a9e8c7
--- /dev/null
+++ b/force-app/main/default/triggers/FollowTrigger.trigger
@@ -0,0 +1,4 @@
+trigger FollowTrigger on Inquiry_form__c(after update,after insert) {
+    FollowTriggerHandler fth = new FollowTriggerHandler();
+    fth.run();
+}
\ No newline at end of file
diff --git a/force-app/main/default/triggers/FollowTrigger.trigger-meta.xml b/force-app/main/default/triggers/FollowTrigger.trigger-meta.xml
new file mode 100644
index 0000000..6205514
--- /dev/null
+++ b/force-app/main/default/triggers/FollowTrigger.trigger-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>41.0</apiVersion>
+    <status>Active</status>
+</ApexTrigger>

--
Gitblit v1.9.1