cloudcc-cli 1.9.6 → 1.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/java/com/cloudcc/core/CCObject.java +73 -0
- package/{core → java/com/cloudcc}/core/CCService.java +139 -334
- package/java/com/cloudcc/core/CCTrigger.java +38 -0
- package/{core/core/CCTrigger.java → java/com/cloudcc/core/CCTriggerDemo.java} +4 -2
- package/java/com/cloudcc/core/CCTriggerHandler.java +17 -0
- package/java/com/cloudcc/core/SendEmail.java +23 -0
- package/java/com/cloudcc/core/ServiceResult.java +36 -0
- package/java/com/cloudcc/core/TimeUtil.java +11 -0
- package/java/com/cloudcc/core/Tool.java +270 -0
- package/{core → java/com/cloudcc}/core/TriggerInvoker.java +21 -17
- package/java/com/cloudcc/core/UserInfo.java +57 -0
- package/lib/fastjson-1.2.83.jar +0 -0
- package/lib/jackson-databind-2.13.3.jar +0 -0
- package/lib/log4j-1.2.17.jar +0 -0
- package/lib/reflections-0.9.12.jar +0 -0
- package/lib/slf4j-api-1.7.32.jar +0 -0
- package/lib/slf4j-log4j12-1.7.32.jar +0 -0
- package/package.json +3 -2
- package/pom.xml +100 -0
- package/src/classes/create.js +19 -2
- package/template/index.js +38 -1
- package/template/lib/ccopenapi-0.0.1.jar +0 -0
- package/template/lib/fastjson-1.2.83.jar +0 -0
- package/template/lib/reflections-0.9.12.jar +0 -0
- package/core/core/CCObject.java +0 -48
- package/core/core/CCTriggerHandler.java +0 -15
- package/core/core/PeakSvc.java +0 -8
- package/core/core/ServiceResult.java +0 -35
- package/core/core/UserInfo.java +0 -45
- /package/{core → java/com/cloudcc}/core/DevLogger.java +0 -0
- /package/{core → java/com/cloudcc}/core/OperatationEnum.java +0 -0
- /package/{core → java/com/cloudcc}/core/PeakInterf.java +0 -0
- /package/{core → java/com/cloudcc}/core/TriggerMethod.java +0 -0
- /package/{core → java/com/cloudcc}/core/TriggerTimeEnum.java +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package com.cloudcc.core;
|
|
2
|
+
|
|
3
|
+
public class CCTrigger {
|
|
4
|
+
|
|
5
|
+
public void do_insert_before() throws Exception {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
public void do_insert_after() throws Exception {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public void do_update_before() throws Exception {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public void do_update_after() throws Exception {
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public void do_upsert_before() throws Exception {
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public void do_upsert_after() throws Exception {
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public void do_delete_before() throws Exception {
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public void do_delete_after() throws Exception {
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public void setRecordOldVal(String id) {
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public void do_approval() throws Exception {
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public String getObjectApiName() {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
package com.cloudcc.core;
|
|
2
2
|
|
|
3
|
-
public interface
|
|
3
|
+
public interface CCTriggerDemo {
|
|
4
4
|
public void do_insert_before() throws Exception;
|
|
5
5
|
|
|
6
6
|
public void do_insert_after() throws Exception;
|
|
@@ -8,6 +8,7 @@ public interface CCTrigger {
|
|
|
8
8
|
public void do_update_before() throws Exception;
|
|
9
9
|
|
|
10
10
|
public void do_update_after() throws Exception;
|
|
11
|
+
|
|
11
12
|
public void do_upsert_before() throws Exception;
|
|
12
13
|
|
|
13
14
|
public void do_upsert_after() throws Exception;
|
|
@@ -15,7 +16,8 @@ public interface CCTrigger {
|
|
|
15
16
|
public void do_delete_before() throws Exception;
|
|
16
17
|
|
|
17
18
|
public void do_delete_after() throws Exception;
|
|
18
|
-
|
|
19
|
+
|
|
20
|
+
public void setRecordOldVal(String id);
|
|
19
21
|
|
|
20
22
|
public void do_approval() throws Exception;
|
|
21
23
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.cloudcc.core;
|
|
2
|
+
|
|
3
|
+
import java.util.HashMap;
|
|
4
|
+
|
|
5
|
+
public abstract class CCTriggerHandler extends CCService {
|
|
6
|
+
public HashMap<String, Object> record_new;
|
|
7
|
+
public HashMap<String, Object> record_old;
|
|
8
|
+
public ServiceResult trigger;
|
|
9
|
+
|
|
10
|
+
public CCTriggerHandler(HashMap<String, Object> triggernew, HashMap<String, Object> triggerold, ServiceResult svc,
|
|
11
|
+
UserInfo uinfo) {
|
|
12
|
+
super(uinfo);
|
|
13
|
+
this.record_new = triggernew;
|
|
14
|
+
this.record_old = triggerold;
|
|
15
|
+
this.trigger = svc;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package com.cloudcc.core;
|
|
2
|
+
|
|
3
|
+
public class SendEmail {
|
|
4
|
+
public SendEmail(UserInfo userInfo) {
|
|
5
|
+
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Receive address, cc address, password address, subject, email content, text
|
|
9
|
+
// content
|
|
10
|
+
public ServiceResult sendMailFromSystem(String[] toAddress, String[] ccAddress, String bccAddress, String subject,
|
|
11
|
+
String content, boolean isText) {
|
|
12
|
+
ServiceResult srt = new ServiceResult();
|
|
13
|
+
return srt;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Email template id, receipt address, cc address, password address, record id
|
|
17
|
+
public ServiceResult sendEmailNew(String templateId, String[] toAddress, String[] ccAddress, String bccAddress,
|
|
18
|
+
String recordId) {
|
|
19
|
+
ServiceResult srt = new ServiceResult();
|
|
20
|
+
return srt;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
package com.cloudcc.core;
|
|
2
|
+
|
|
3
|
+
import java.util.HashMap;
|
|
4
|
+
|
|
5
|
+
import com.alibaba.fastjson.JSONObject;
|
|
6
|
+
|
|
7
|
+
public class ServiceResult extends HashMap<String, Object> {
|
|
8
|
+
public String success;
|
|
9
|
+
public String message;
|
|
10
|
+
public String Id;
|
|
11
|
+
|
|
12
|
+
public void addErrorMessage(String msg) throws Exception {
|
|
13
|
+
this.put("message", msg);
|
|
14
|
+
this.put("success", "false");
|
|
15
|
+
throw new Exception(msg);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public String getMessage() {
|
|
19
|
+
return (String) this.get("message");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public String getSuccess() {
|
|
23
|
+
return (String) this.get("success");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public String getId() {
|
|
27
|
+
return (String) this.get("id");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Override
|
|
31
|
+
public String toString() {
|
|
32
|
+
JSONObject data = new JSONObject();
|
|
33
|
+
data.putAll(this);
|
|
34
|
+
return data.toString();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
package com.cloudcc.core;
|
|
2
|
+
|
|
3
|
+
import java.io.BufferedReader;
|
|
4
|
+
import java.io.File;
|
|
5
|
+
import java.io.FileReader;
|
|
6
|
+
import java.io.IOException;
|
|
7
|
+
import java.io.InputStreamReader;
|
|
8
|
+
import java.util.HashMap;
|
|
9
|
+
import java.util.Map;
|
|
10
|
+
import java.util.regex.Matcher;
|
|
11
|
+
import java.util.regex.Pattern;
|
|
12
|
+
|
|
13
|
+
import com.alibaba.fastjson.JSONObject;
|
|
14
|
+
|
|
15
|
+
public class Tool {
|
|
16
|
+
/**
|
|
17
|
+
* 读取cloudcc-cli.config.js文件内容,解析use属性,获取对应内容
|
|
18
|
+
*
|
|
19
|
+
* @return Map包含currentEnv和对应的配置信息
|
|
20
|
+
*/
|
|
21
|
+
public static Map<String, String> getConfig() {
|
|
22
|
+
Map<String, String> result = new HashMap<>();
|
|
23
|
+
try {
|
|
24
|
+
// 获取配置文件路径
|
|
25
|
+
String configPath = new File("").getAbsolutePath() + "/cloudcc-cli.config.js";
|
|
26
|
+
File configFile = new File(configPath);
|
|
27
|
+
|
|
28
|
+
if (!configFile.exists()) {
|
|
29
|
+
System.err.println("配置文件不存在: " + configPath);
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 读取文件内容
|
|
34
|
+
StringBuilder content = new StringBuilder();
|
|
35
|
+
try (BufferedReader reader = new BufferedReader(new FileReader(configFile))) {
|
|
36
|
+
String line;
|
|
37
|
+
while ((line = reader.readLine()) != null) {
|
|
38
|
+
// 跳过注释行
|
|
39
|
+
if (line.trim().startsWith("//")) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
content.append(line).append("\n");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
String fileContent = content.toString();
|
|
47
|
+
|
|
48
|
+
// 替换 'module.exports = ' 为空字符串,并移除注释
|
|
49
|
+
String jsonStr = fileContent.replaceFirst("module\\.exports\\s*=\\s*", "")
|
|
50
|
+
.replaceAll("//[^\\n]*", ""); // 移除单行注释
|
|
51
|
+
|
|
52
|
+
// 使用正则表达式提取配置对象,处理最后可能有多余的分号
|
|
53
|
+
Pattern configPattern = Pattern.compile("\\{([\\s\\S]*)\\}\\s*;?\\s*$");
|
|
54
|
+
Matcher configMatcher = configPattern.matcher(jsonStr);
|
|
55
|
+
if (configMatcher.find()) {
|
|
56
|
+
jsonStr = "{" + configMatcher.group(1) + "}";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 使用正则表达式提取use值
|
|
60
|
+
Pattern usePattern = Pattern.compile("\"use\"\\s*:\\s*\"([^\"]*)\"");
|
|
61
|
+
Matcher useMatcher = usePattern.matcher(jsonStr);
|
|
62
|
+
|
|
63
|
+
if (!useMatcher.find()) {
|
|
64
|
+
System.err.println("无法找到use属性");
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
String currentEnv = useMatcher.group(1);
|
|
69
|
+
result.put("currentEnv", currentEnv);
|
|
70
|
+
|
|
71
|
+
// 创建更精确的正则表达式来匹配环境配置块
|
|
72
|
+
Pattern envPattern = Pattern.compile(
|
|
73
|
+
"\"" + Pattern.quote(currentEnv) + "\"\\s*:\\s*\\{([^\\{\\}]*(\\{[^\\{\\}]*\\})*[^\\{\\}]*)\\}");
|
|
74
|
+
Matcher envMatcher = envPattern.matcher(jsonStr);
|
|
75
|
+
|
|
76
|
+
if (envMatcher.find()) {
|
|
77
|
+
String envConfig = envMatcher.group(1);
|
|
78
|
+
// 解析配置项(考虑到键和值可能包含更复杂的内容)
|
|
79
|
+
Pattern itemPattern = Pattern.compile("\"([^\"]+)\"\\s*:\\s*\"([^\"]*)\"");
|
|
80
|
+
Matcher itemMatcher = itemPattern.matcher(envConfig);
|
|
81
|
+
while (itemMatcher.find()) {
|
|
82
|
+
result.put(itemMatcher.group(1), itemMatcher.group(2));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// 获取secretKey
|
|
86
|
+
String secretKey = result.get("secretKey");
|
|
87
|
+
if (secretKey != null) {
|
|
88
|
+
// 从缓存文件中读取相关信息
|
|
89
|
+
Map<String, Object> cacheData = readCache(secretKey);
|
|
90
|
+
if (cacheData != null) {
|
|
91
|
+
// 将缓存信息添加到结果中
|
|
92
|
+
for (Map.Entry<String, Object> entry : cacheData.entrySet()) {
|
|
93
|
+
result.put(entry.getKey(), String.valueOf(entry.getValue()));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
System.err.println("无法找到环境配置: " + currentEnv);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return result;
|
|
102
|
+
} catch (IOException e) {
|
|
103
|
+
System.err.println("读取配置文件失败: " + e.getMessage());
|
|
104
|
+
e.printStackTrace();
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 读取.cloudcc-cache.json缓存文件并根据secretKey获取相关信息
|
|
111
|
+
*
|
|
112
|
+
* @param secretKey 密钥
|
|
113
|
+
* @return 包含缓存信息的Map
|
|
114
|
+
*/
|
|
115
|
+
private static Map<String, Object> readCache(String secretKey) {
|
|
116
|
+
try {
|
|
117
|
+
// 获取缓存文件路径
|
|
118
|
+
String cachePath = new File("").getAbsolutePath() + "/.cloudcc-cache.json";
|
|
119
|
+
File cacheFile = new File(cachePath);
|
|
120
|
+
|
|
121
|
+
// 如果缓存文件不存在,执行刷新token命令
|
|
122
|
+
if (!cacheFile.exists()) {
|
|
123
|
+
boolean refreshed = executeGetTokenCommand();
|
|
124
|
+
if (refreshed) {
|
|
125
|
+
// 重新检查缓存文件是否存在
|
|
126
|
+
if (cacheFile.exists()) {
|
|
127
|
+
return readCacheAfterRefresh(secretKey);
|
|
128
|
+
} else {
|
|
129
|
+
System.err.println("获取token失败");
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
System.err.println("获取token失败");
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 读取文件内容
|
|
139
|
+
StringBuilder content = new StringBuilder();
|
|
140
|
+
try (BufferedReader reader = new BufferedReader(new FileReader(cacheFile))) {
|
|
141
|
+
String line;
|
|
142
|
+
while ((line = reader.readLine()) != null) {
|
|
143
|
+
content.append(line).append("\n");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
String jsonContent = content.toString();
|
|
148
|
+
// 使用Fastjson解析JSON内容
|
|
149
|
+
JSONObject jsonObject = JSONObject.parseObject(jsonContent);
|
|
150
|
+
|
|
151
|
+
// 检查secretKey是否存在,如果不存在,执行刷新token命令
|
|
152
|
+
if (!jsonObject.containsKey(secretKey)) {
|
|
153
|
+
System.out.println("缓存文件中不存在该secretKey: " + secretKey + ",正在获取新的token...");
|
|
154
|
+
boolean refreshed = executeGetTokenCommand();
|
|
155
|
+
if (refreshed) {
|
|
156
|
+
return readCacheAfterRefresh(secretKey);
|
|
157
|
+
} else {
|
|
158
|
+
System.err.println("获取token失败");
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// 获取secretKey对应的数据
|
|
164
|
+
JSONObject secretKeyData = jsonObject.getJSONObject(secretKey);
|
|
165
|
+
|
|
166
|
+
// 检查时间戳是否过期(大于1小时)或者不存在
|
|
167
|
+
if (!secretKeyData.containsKey("timestamp") ||
|
|
168
|
+
(System.currentTimeMillis() - secretKeyData.getLongValue("timestamp") > 60 * 60 * 1000)) {
|
|
169
|
+
boolean refreshed = executeGetTokenCommand();
|
|
170
|
+
if (refreshed) {
|
|
171
|
+
// 重新读取缓存文件
|
|
172
|
+
return readCacheAfterRefresh(secretKey);
|
|
173
|
+
} else {
|
|
174
|
+
System.err.println("刷新Token失败");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// 将JSON对象转换为Map
|
|
179
|
+
Map<String, Object> resultMap = new HashMap<>();
|
|
180
|
+
for (String key : secretKeyData.keySet()) {
|
|
181
|
+
resultMap.put(key, secretKeyData.get(key));
|
|
182
|
+
}
|
|
183
|
+
return resultMap;
|
|
184
|
+
} catch (IOException e) {
|
|
185
|
+
System.err.println("读取缓存文件失败: " + e.getMessage());
|
|
186
|
+
e.printStackTrace();
|
|
187
|
+
// 发生IO异常时,尝试获取新的token
|
|
188
|
+
boolean refreshed = executeGetTokenCommand();
|
|
189
|
+
if (refreshed) {
|
|
190
|
+
return readCacheAfterRefresh(secretKey);
|
|
191
|
+
}
|
|
192
|
+
return null;
|
|
193
|
+
} catch (Exception e) {
|
|
194
|
+
System.err.println("解析缓存文件失败: " + e.getMessage());
|
|
195
|
+
e.printStackTrace();
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* 执行命令 cc get token 刷新token
|
|
202
|
+
*
|
|
203
|
+
* @return 执行是否成功
|
|
204
|
+
*/
|
|
205
|
+
private static boolean executeGetTokenCommand() {
|
|
206
|
+
try {
|
|
207
|
+
ProcessBuilder processBuilder = new ProcessBuilder("cc", "get", "token");
|
|
208
|
+
processBuilder.redirectErrorStream(true);
|
|
209
|
+
Process process = processBuilder.start();
|
|
210
|
+
|
|
211
|
+
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
|
|
212
|
+
// consume the stream if necessary
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
int exitCode = process.waitFor();
|
|
216
|
+
return exitCode == 0;
|
|
217
|
+
} catch (IOException | InterruptedException e) {
|
|
218
|
+
System.err.println("执行命令失败: " + e.getMessage());
|
|
219
|
+
e.printStackTrace();
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* 在刷新token后重新读取缓存文件
|
|
226
|
+
*
|
|
227
|
+
* @param secretKey 密钥
|
|
228
|
+
* @return 包含缓存信息的Map
|
|
229
|
+
*/
|
|
230
|
+
private static Map<String, Object> readCacheAfterRefresh(String secretKey) {
|
|
231
|
+
try {
|
|
232
|
+
// 获取缓存文件路径
|
|
233
|
+
String cachePath = new File("").getAbsolutePath() + "/.cloudcc-cache.json";
|
|
234
|
+
File cacheFile = new File(cachePath);
|
|
235
|
+
|
|
236
|
+
if (!cacheFile.exists()) {
|
|
237
|
+
System.err.println("缓存文件不存在: " + cachePath);
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// 读取文件内容
|
|
242
|
+
StringBuilder content = new StringBuilder();
|
|
243
|
+
try (BufferedReader reader = new BufferedReader(new FileReader(cacheFile))) {
|
|
244
|
+
String line;
|
|
245
|
+
while ((line = reader.readLine()) != null) {
|
|
246
|
+
content.append(line).append("\n");
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
String jsonContent = content.toString();
|
|
251
|
+
JSONObject jsonObject = JSONObject.parseObject(jsonContent);
|
|
252
|
+
|
|
253
|
+
if (!jsonObject.containsKey(secretKey)) {
|
|
254
|
+
System.err.println("缓存文件中不存在该secretKey: " + secretKey);
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
JSONObject secretKeyData = jsonObject.getJSONObject(secretKey);
|
|
259
|
+
Map<String, Object> resultMap = new HashMap<>();
|
|
260
|
+
for (String key : secretKeyData.keySet()) {
|
|
261
|
+
resultMap.put(key, secretKeyData.get(key));
|
|
262
|
+
}
|
|
263
|
+
return resultMap;
|
|
264
|
+
} catch (Exception e) {
|
|
265
|
+
System.err.println("刷新后读取缓存失败: " + e.getMessage());
|
|
266
|
+
e.printStackTrace();
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
@@ -1,40 +1,44 @@
|
|
|
1
1
|
package com.cloudcc.core;
|
|
2
2
|
|
|
3
|
-
import com.cloudcc.core.CCObject;
|
|
4
|
-
import org.reflections.Reflections;
|
|
5
|
-
|
|
6
3
|
import java.lang.reflect.Constructor;
|
|
7
4
|
import java.lang.reflect.InvocationTargetException;
|
|
8
5
|
import java.util.Set;
|
|
9
6
|
|
|
7
|
+
import org.reflections.Reflections;
|
|
8
|
+
|
|
10
9
|
public class TriggerInvoker {
|
|
11
10
|
UserInfo uinfo = null;
|
|
12
11
|
String operate = "";
|
|
13
12
|
String triggerTime = "";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
|
|
14
|
+
public TriggerInvoker(UserInfo userInfo, String operate, String triggerTime) {
|
|
15
|
+
this.uinfo = userInfo;
|
|
16
|
+
this.operate = operate;
|
|
17
|
+
this.triggerTime = triggerTime;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
public TriggerInvoker() {
|
|
20
21
|
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
+
|
|
24
|
+
@SuppressWarnings("rawtypes")
|
|
25
|
+
public ServiceResult handler(CCObject data) throws Exception {
|
|
23
26
|
String objectApiName = data.getObjectApiName();
|
|
24
27
|
ServiceResult sr = new ServiceResult();
|
|
25
28
|
Reflections ref = new Reflections("com.cloudcc.trigger");
|
|
26
29
|
Set<Class<? extends CCTrigger>> clsSets = ref.getSubTypesOf(CCTrigger.class);
|
|
27
|
-
for (Class<? extends CCTrigger> subCls : clsSets){
|
|
30
|
+
for (Class<? extends CCTrigger> subCls : clsSets) {
|
|
28
31
|
try {
|
|
29
|
-
Constructor cons = subCls.getConstructor(CCObject.class,CCObject.class,ServiceResult.class,
|
|
30
|
-
|
|
32
|
+
Constructor cons = subCls.getConstructor(CCObject.class, CCObject.class, ServiceResult.class,
|
|
33
|
+
UserInfo.class);
|
|
34
|
+
CCTrigger trigger = (CCTrigger) cons.newInstance(data, null, sr, uinfo);
|
|
31
35
|
String objectApiNameTmp = (String) trigger.getObjectApiName();
|
|
32
36
|
if (objectApiName != null && objectApiName.equals(objectApiNameTmp)) {
|
|
33
37
|
if ("before".equals(triggerTime) && "insert".equals(operate)) {
|
|
34
38
|
trigger.do_insert_before();
|
|
35
39
|
}
|
|
36
40
|
if ("after".equals(triggerTime) && "insert".equals(operate)) {
|
|
37
|
-
String id = (String)data.get("id");
|
|
41
|
+
String id = (String) data.get("id");
|
|
38
42
|
trigger.setRecordOldVal(id);
|
|
39
43
|
trigger.do_insert_after();
|
|
40
44
|
}
|
|
@@ -42,7 +46,7 @@ public class TriggerInvoker {
|
|
|
42
46
|
trigger.do_update_before();
|
|
43
47
|
}
|
|
44
48
|
if ("after".equals(triggerTime) && "update".equals(operate)) {
|
|
45
|
-
String id = (String)data.get("id");
|
|
49
|
+
String id = (String) data.get("id");
|
|
46
50
|
trigger.setRecordOldVal(id);
|
|
47
51
|
trigger.do_update_after();
|
|
48
52
|
}
|
|
@@ -50,7 +54,7 @@ public class TriggerInvoker {
|
|
|
50
54
|
trigger.do_upsert_before();
|
|
51
55
|
}
|
|
52
56
|
if ("after".equals(triggerTime) && "upsert".equals(operate)) {
|
|
53
|
-
String id = (String)data.get("id");
|
|
57
|
+
String id = (String) data.get("id");
|
|
54
58
|
trigger.setRecordOldVal(id);
|
|
55
59
|
trigger.do_upsert_after();
|
|
56
60
|
}
|
|
@@ -58,7 +62,7 @@ public class TriggerInvoker {
|
|
|
58
62
|
trigger.do_delete_before();
|
|
59
63
|
}
|
|
60
64
|
if ("after".equals(triggerTime) && "delete".equals(operate)) {
|
|
61
|
-
String id = (String)data.get("id");
|
|
65
|
+
String id = (String) data.get("id");
|
|
62
66
|
trigger.setRecordOldVal(id);
|
|
63
67
|
trigger.do_delete_after();
|
|
64
68
|
}
|
|
@@ -74,7 +78,7 @@ public class TriggerInvoker {
|
|
|
74
78
|
throw new RuntimeException(e);
|
|
75
79
|
} catch (IllegalAccessException e) {
|
|
76
80
|
throw new RuntimeException(e);
|
|
77
|
-
}catch (Exception ex) {
|
|
81
|
+
} catch (Exception ex) {
|
|
78
82
|
throw ex;
|
|
79
83
|
}
|
|
80
84
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
package com.cloudcc.core;
|
|
2
|
+
|
|
3
|
+
public class UserInfo extends CCObject {
|
|
4
|
+
// 绑定信息
|
|
5
|
+
public String binding;
|
|
6
|
+
|
|
7
|
+
// 获取用户ID
|
|
8
|
+
public String getUserId() {
|
|
9
|
+
return (String) this.get("id");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// 获取角色ID
|
|
13
|
+
public String getRoleId() {
|
|
14
|
+
return (String) this.get("role");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 构造方法,传入用户名和密码
|
|
18
|
+
public UserInfo(String username, String pwd) throws Exception {
|
|
19
|
+
this.put("userName", username);
|
|
20
|
+
this.put("password", pwd);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 默认构造方法
|
|
24
|
+
public UserInfo() {
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 获取登录名
|
|
29
|
+
public String getLoginName() {
|
|
30
|
+
return (String) this.get("userName");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 获取配置文件ID
|
|
34
|
+
public String getProfileId() {
|
|
35
|
+
return (String) this.get("profileId");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 设置绑定信息
|
|
39
|
+
public void setBinding(String bind) {
|
|
40
|
+
this.binding = bind;
|
|
41
|
+
this.put("binding", bind);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 获取绑定信息
|
|
45
|
+
public String getBinding() {
|
|
46
|
+
if (this.binding == null) {
|
|
47
|
+
return (String) this.get("binding");
|
|
48
|
+
} else {
|
|
49
|
+
return this.binding;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// 获取用户名
|
|
54
|
+
public String getUserName() {
|
|
55
|
+
return (String) this.get("name");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudcc-cli",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.8",
|
|
4
4
|
"description": "cloudcc-cli",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudcc",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"cc-pull": "git fetch --tags -f && git pull",
|
|
19
|
-
"publish-lib": "npm publish --registry https://registry.npmjs.org && git add . && git commit -m 'update' && git push && curl https://npmmirror.com/sync/cloudcc-cli"
|
|
19
|
+
"publish-lib": "npm publish --registry https://registry.npmjs.org && git add . && git commit -m 'update' && git push && curl https://npmmirror.com/sync/cloudcc-cli",
|
|
20
|
+
"package-jar": "mvn clean && mvn package"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
23
|
"axios": "^0.21.4",
|