cloudcc-cli 1.9.7 → 1.9.9

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.
@@ -1,806 +0,0 @@
1
- package com.cloudcc.core;
2
-
3
-
4
- import com.alibaba.fastjson.JSONArray;
5
- import com.alibaba.fastjson.JSONObject;
6
- import com.fasterxml.jackson.databind.ObjectMapper;
7
-
8
- import java.io.*;
9
- import java.net.HttpURLConnection;
10
- import java.net.URL;
11
- import java.nio.charset.StandardCharsets;
12
- import java.util.*;
13
-
14
- import org.slf4j.Logger;
15
- import org.slf4j.LoggerFactory;
16
-
17
- /**
18
- * @author T.han
19
- * @date 2023/8/17 15:09
20
- * @project CloudccNewPro
21
- * @Description //TODO
22
- */
23
- public class CCService {
24
-
25
- public static UserInfo userInfo;
26
- public String ACCESSTOKEN;
27
- public String path;
28
- public String URL;
29
- protected Map<String,Object> record_new;
30
- protected Map<String,Object> record_old;
31
- public ServiceResult trigger = new ServiceResult();
32
- public String objectApiName;
33
- ResourceBundle prb = PropertyResourceBundle.getBundle("application");// 获取配置文件;
34
- String orgId = prb.getString("orgId");
35
- Logger logger = LoggerFactory.getLogger(this.getClass());
36
-
37
- public CCService(UserInfo userInfo) {
38
- this.URL=getOrgApiUrl();
39
- this.ACCESSTOKEN = getToken();
40
- this.path = URL+ "/openApi/common";
41
- }
42
-
43
- /**
44
- * @return java.lang.String
45
- * @Description //TODO 获取公有云api网关地址
46
- * @Author T.han
47
- * @Date 2023/8/17 15:48
48
- * @Param
49
- **/
50
- public String getOrgApiUrl() {
51
- String apiUrl = "";
52
- String url = prb.getString("url");
53
- if(!"".equals(url)){
54
- String parUrl = url + "?scope=cloudccCRM&orgId=" + orgId;
55
- String relStr = sendGet(parUrl);
56
- JSONObject relObj = new JSONObject();
57
- relObj = JSONObject.parseObject(relStr);
58
- String result = relObj.getString("result");
59
- if ("true".equals(result)) {
60
- apiUrl = relObj.getString("orgapi_address");
61
- }
62
- }else {
63
- apiUrl="https://quectelcrm-dev.quectel.com/ccdomaingateway/apisvc-interface";
64
- }
65
-
66
- return apiUrl;
67
- }
68
-
69
- /**
70
- * @return java.lang.String
71
- * @Description //TODO 获取token
72
- * @Author T.han
73
- * @Date 2023/8/17 16:10
74
- * @Param
75
- **/
76
- public String getToken() {
77
- String accessToken = "";
78
- String username = prb.getString("username");
79
- String safetyMark = prb.getString("safetyMark");
80
- String clientId = prb.getString("clientId");
81
- String secretKey = prb.getString("secretKey");
82
- String grant_type = prb.getString("grant_type");
83
- //拼接 parObj 参数
84
- JSONObject parObj = new JSONObject();
85
- parObj.put("username", username);
86
- parObj.put("safetyMark", safetyMark);
87
- parObj.put("clientId", clientId);
88
- parObj.put("secretKey", secretKey);
89
- parObj.put("orgId", orgId);
90
- parObj.put("grant_type", grant_type);
91
- path= URL+ "/api/cauth/token";
92
- if (!"".equals(path)) {
93
- String relStr = sendPost(path, parObj.toString());
94
- JSONObject relObj = new JSONObject();
95
- relObj = JSONObject.parseObject(relStr);
96
- boolean result = relObj.getBoolean("result");
97
- if (result) {
98
- JSONObject data = (JSONObject)relObj.get("data");
99
- if (data != null && data.containsKey("accessToken")) {
100
- accessToken = relObj.getJSONObject("data").getString("accessToken");
101
- } else {
102
- logger.error("CCService.getToken报错:未获取到accessToken");
103
- }
104
- } else {
105
- String returnInfo = relObj.getString("returnInfo");
106
- logger.error("CCService.getToken报错:" + returnInfo);
107
- }
108
- } else {
109
- logger.error("CCService.getToken报错:未获取到网关地址");
110
- }
111
- return accessToken;
112
- }
113
-
114
- /**
115
- * @return java.util.List<com.cloudcc.newxm.util.CCObject>
116
- * @Description //TODO cquery 查询不加条件
117
- * @Author T.han
118
- * @Date 2023/8/17 16:38
119
- * @Param apiName 对象名
120
- **/
121
- public List<CCObject> cquery(String apiName) {
122
- List<CCObject> orst = new ArrayList<CCObject>();
123
- //拼接 parObj 参数
124
- JSONObject parObj = new JSONObject();
125
- parObj.put("serviceName", "cquery"); //服务名
126
- parObj.put("objectApiName", apiName); //对象名
127
- parObj.put("expressions", "1=1"); //查询条件
128
- parObj.put("isAddDelete", "false"); //是否包含删除数据 true:包含 false:不包含
129
- parObj.put("fields", "");//查询字段 不填写时sql按 * 返回
130
-
131
- String relStr = CCPost(path, parObj.toString());
132
- JSONObject relObj = new JSONObject();
133
- relObj = JSONObject.parseObject(relStr);
134
- String result = relObj.getString("result");
135
- if ("true".equals(result)) {
136
- List<Map> rst = relObj.getJSONArray("data").toJavaList(Map.class);
137
- for (Map m : rst) {
138
- CCObject co = new CCObject(apiName);
139
- for (Object _key : m.keySet()) {
140
- String key = (String) _key;
141
- co.put(key, m.get(key));
142
- }
143
- orst.add(co);
144
- }
145
- }
146
- return orst;
147
- }
148
-
149
- /**
150
- * @return java.util.List<com.cloudcc.newxm.util.CCObject>
151
- * @Description //TODO cquery 查询方法
152
- * @Author T.han
153
- * @Date 2023/8/17 16:42
154
- * @Param apiName 对象名
155
- * @Param expression 查询条件
156
- **/
157
- public List<CCObject> cquery(String apiName, String expression) {
158
- List<CCObject> orst = new ArrayList<CCObject>();
159
- //拼接 parObj 参数
160
- JSONObject parObj = new JSONObject();
161
- parObj.put("serviceName", "cquery"); //服务名
162
- parObj.put("objectApiName", apiName); //对象名
163
- parObj.put("expressions", expression); //查询条件
164
- parObj.put("isAddDelete", "false"); //是否包含删除数据 true:包含 false:不包含
165
- parObj.put("fields", "");//查询字段 不填写时sql按 * 返回
166
-
167
- String relStr = CCPost(path, parObj.toString());
168
- JSONObject relObj = new JSONObject();
169
- relObj = JSONObject.parseObject(relStr);
170
- String result = relObj.getString("result");
171
- if ("true".equals(result)) {
172
- List<Map> rst = relObj.getJSONArray("data").toJavaList(Map.class);
173
- for (Map m : rst) {
174
- CCObject co = new CCObject(apiName);
175
- for (Object _key : m.keySet()) {
176
- String key = (String) _key;
177
- co.put(key, m.get(key));
178
- }
179
- orst.add(co);
180
- }
181
- }
182
- return orst;
183
- }
184
-
185
- /**
186
- * @return java.util.List<com.cloudcc.newxm.util.CCObject>
187
- * @Description //TODO cqlQuery 查询方法
188
- * @Author T.han
189
- * @Date 2023/8/17 16:41
190
- * @Param apiName 对象名
191
- * @Param expression 查询sql
192
- **/
193
- public List<CCObject> cqlQuery(String apiName, String expression) {
194
- List<CCObject> orst = new ArrayList<CCObject>();
195
- //拼接 parObj 参数
196
- JSONObject parObj = new JSONObject();
197
- parObj.put("serviceName", "cqlQueryWithLogInfo"); //服务名
198
- parObj.put("objectApiName", apiName); //对象名
199
- parObj.put("expressions", expression); //查询条件
200
- //拼接接口地址
201
- // String path = getOrgApiUrl() + "/openApi/common";
202
- String relStr = CCPost(path, parObj.toString());
203
- JSONObject relObj = new JSONObject();
204
- relObj = JSONObject.parseObject(relStr);
205
- String result = relObj.getString("result");
206
- if ("true".equals(result)) {
207
- List<Map> rst = relObj.getJSONArray("data").toJavaList(Map.class);
208
- for (Map<String,Object> m : rst) {
209
- CCObject co = new CCObject(apiName);
210
- for (Object _key : m.keySet()) {
211
- String key = (String) _key;
212
- co.put(key, m.get(key));
213
- }
214
- orst.add(co);
215
- }
216
- }
217
- return orst;
218
- }
219
-
220
- /**
221
- * @Description //TODO update方法
222
- * @Author T.han
223
- * @Date 2023/8/18 10:02
224
- * @Param cobj
225
- * @return void
226
- **/
227
- public void update(CCObject cobj) {
228
- JSONArray arry = new JSONArray();
229
- JSONObject obj = new JSONObject();
230
- String objectApiName = "";
231
- for (String _key : cobj.keySet()) {
232
- if ("CCObjectAPI".equals(_key)) {
233
- objectApiName = cobj.get("CCObjectAPI") == null ? "" : cobj.get("CCObjectAPI") + "";
234
- } else {
235
- String values = cobj.get(_key) == null ? "" : cobj.get(_key) + "";
236
- obj.put(_key, values);
237
- }
238
- }
239
- arry.add(obj);
240
-
241
- //拼接 parObj 参数
242
- JSONObject parObj = new JSONObject();
243
- parObj.put("serviceName", "update"); //服务名
244
- parObj.put("objectApiName", objectApiName); //对象名
245
- parObj.put("data", arry.toString()); //查询条件
246
- try {
247
- TriggerInvoker invoker = new TriggerInvoker(userInfo,"update","before");
248
- invoker.handler(cobj);
249
- String relStr = CCPost(path, parObj.toString());
250
- JSONObject relObj = JSONObject.parseObject(relStr);
251
- boolean result = relObj.getBoolean("result");
252
- if(result){
253
- JSONObject outObj = relObj.getJSONObject("data");
254
- if(outObj.containsKey("ids")){
255
- JSONArray outData = outObj.getJSONArray("ids");
256
- StringBuilder sb = new StringBuilder();
257
- boolean hasSuccess = false; // 用于跟踪是否有成功处理的条目
258
- for(int i=0;i < outData.size();i++) {
259
- JSONObject acc = outData.getJSONObject(i);
260
- if(acc.getBoolean("success")){
261
- String id = acc.getString("id");
262
- if (sb.length() > 0) {
263
- sb.append(',');
264
- }
265
- sb.append(id);
266
- hasSuccess = true;
267
- }else{
268
- logger.error("update报错: " + acc.getString("errors"));
269
- }
270
- }
271
- if (hasSuccess) {
272
- String retIds = sb.toString();
273
- logger.info("update成功: " + retIds);
274
- cobj.put("id",retIds);
275
- invoker = new TriggerInvoker(userInfo,"update","before");
276
- invoker.handler(cobj);
277
- }
278
- }else{
279
- logger.error("update未获取到ids 参数");
280
- }
281
-
282
- }else{
283
- logger.error("update报错= " + relObj.getString("returnInfo"));
284
- }
285
-
286
- } catch (Exception e) {
287
- e.printStackTrace();
288
- logger.error("update报错= " + e);
289
- }
290
- }
291
-
292
- /**
293
- * @Description //TODO insert 方法
294
- * @Author T.han
295
- * @Date 2023/8/18 10:27
296
- * @Param cobj 新建 json参数
297
- * @return com.cloudcc.newxm.util.ServiceResult 返回新建数据id
298
- **/
299
- public ServiceResult insert(CCObject cobj) {
300
- ServiceResult sr = new ServiceResult();
301
- JSONArray arry = new JSONArray();
302
- JSONObject obj = new JSONObject();
303
- String objectApiName = "";
304
- for (String _key : cobj.keySet()) {
305
- if ("CCObjectAPI".equals(_key)) {
306
- objectApiName = cobj.get("CCObjectAPI") == null ? "" : cobj.get("CCObjectAPI") + "";
307
- } else {
308
- String values = cobj.get(_key) == null ? "" : cobj.get(_key) + "";
309
- obj.put(_key, values);
310
- }
311
- }
312
- // cobj.remove("CCObjectAPI");
313
- arry.add(obj);
314
- //拼接 parObj 参数
315
- JSONObject parObj = new JSONObject();
316
- parObj.put("serviceName", "insert"); //服务名
317
- parObj.put("objectApiName", objectApiName); //对象名
318
- parObj.put("data", arry.toString()); //查询条件
319
- logger.info("parObj = " + parObj);
320
- try {
321
- //执行触发器
322
- TriggerInvoker invoker = new TriggerInvoker(userInfo,"insert","before");
323
- invoker.handler(cobj);
324
- String relStr = CCPost(path, parObj.toString());
325
- logger.info("insert_relStr = " + relStr);
326
- JSONObject relObj = JSONObject.parseObject(relStr);
327
-
328
- String result = relObj.getString("result");
329
- if ("true".equals(result)) {
330
- JSONArray outData = relObj.getJSONObject("data").getJSONArray("ids");
331
- StringBuilder sb = new StringBuilder();
332
- for(int i=0;i < outData.size();i++) {
333
- JSONObject acc = outData.getJSONObject(i);
334
- if(acc.getBoolean("success")){
335
- String id = acc.getString("id");
336
- if (sb.length() > 0) {
337
- sb.append(',');
338
- }
339
- sb.append(id);
340
- }else{
341
- logger.error("insert报错: " + acc.getString("errors"));
342
- }
343
- }
344
- String retIds = sb.toString();
345
- sr.put("id",retIds);
346
- cobj.put("id",retIds);
347
- invoker = new TriggerInvoker(userInfo,"insert","after");
348
- invoker.handler(cobj);
349
- }
350
- } catch (Exception e) {
351
- e.printStackTrace();
352
- System.out.println("insert报错= " + e);
353
- }
354
- System.out.println("sr = " + sr);
355
- return sr;
356
- }
357
-
358
- public ServiceResult insert(List<CCObject> datalist) {
359
- // TODO Auto-generated method stub
360
- ServiceResult sr = new ServiceResult();
361
- JSONArray arry = new JSONArray();
362
- JSONObject obj = new JSONObject();
363
- String objectApiName = "";
364
-
365
- for (CCObject cobj : datalist) {
366
- for (String _key : cobj.keySet()) {
367
- if ("CCObjectAPI".equals(_key)) {
368
- objectApiName = cobj.get("CCObjectAPI") == null ? "" : cobj.get("CCObjectAPI") + "";
369
- } else {
370
- String values = cobj.get(_key) == null ? "" : cobj.get(_key) + "";
371
- obj.put(_key, values);
372
- }
373
- }
374
- arry.add(obj);
375
- }
376
- //拼接 parObj 参数
377
- JSONObject parObj = new JSONObject();
378
- parObj.put("serviceName", "insert"); //服务名
379
- parObj.put("objectApiName", objectApiName); //对象名
380
- parObj.put("data", arry.toString()); //查询条件
381
- System.out.println("parObj = " + parObj);
382
- try {
383
- String relStr = CCPost(path, parObj.toString());
384
- logger.info("insert_relStr = " + relStr);
385
- JSONObject relObj = new JSONObject();
386
- relObj = JSONObject.parseObject(relStr);
387
- String result = relObj.getString("result");
388
- if ("true".equals(result)) {
389
- JSONArray outData = relObj.getJSONObject("data").getJSONArray("ids");
390
- StringBuilder sb = new StringBuilder();
391
- for(int i=0;i < outData.size();i++) {
392
- JSONObject acc = outData.getJSONObject(i);
393
- if(acc.getBoolean("success")){
394
- String id = acc.getString("id");
395
- if (sb.length() > 0) {
396
- sb.append(',');
397
- }
398
- sb.append(id);
399
- }else{
400
- logger.error("insert报错: " + acc.getString("errors"));
401
- }
402
- }
403
- String retIds = sb.toString();
404
- sr.put("id",retIds);
405
- }
406
- } catch (Exception e) {
407
- e.printStackTrace();
408
- logger.error("insert报错= " + e);
409
- }
410
- System.out.println("sr = " + sr);
411
- return sr;
412
- }
413
-
414
-
415
- /**
416
- * @Description //TODO 删除方法
417
- * @Author T.han
418
- * @Date 2023/8/18 10:38
419
- * @Param cobj 参数数据 {“id”:"a1231111"}
420
- * @return void
421
- **/
422
- public void delete(CCObject cobj) {
423
- JSONArray arry = new JSONArray();
424
- JSONObject obj = new JSONObject();
425
- String objectApiName = "";
426
- for (String _key : cobj.keySet()) {
427
- if ("CCObjectAPI".equals(_key)) {
428
- objectApiName = cobj.get("CCObjectAPI") == null ? "" : cobj.get("CCObjectAPI") + "";
429
- } else {
430
- String values = cobj.get(_key) == null ? "" : cobj.get(_key) + "";
431
- obj.put(_key, values);
432
- }
433
- }
434
- arry.add(obj);
435
- //拼接 parObj 参数
436
- JSONObject parObj = new JSONObject();
437
- parObj.put("serviceName", "delete"); //服务名
438
- parObj.put("objectApiName", objectApiName); //对象名
439
- parObj.put("data", arry.toString()); //查询条件
440
- System.out.println("parObj = " + parObj);
441
- try {
442
- TriggerInvoker invoker = new TriggerInvoker(userInfo,"delete","before");
443
- invoker.handler(cobj);
444
- String relStr = CCPost(path, parObj.toString());
445
- invoker = new TriggerInvoker(userInfo,"delete","after");
446
- invoker.handler(cobj);
447
- } catch (Exception e) {
448
- // e.printStackTrace();
449
- logger.error("delete报错= " + e);
450
- }
451
- }
452
-
453
-
454
- public ServiceResult upsert(CCObject cobj) {
455
- ServiceResult sr = new ServiceResult();
456
- JSONArray arry = new JSONArray();
457
- JSONObject obj = new JSONObject();
458
- String objectApiName = "";
459
- for (String _key : cobj.keySet()) {
460
- if ("CCObjectAPI".equals(_key)) {
461
- objectApiName = cobj.get("CCObjectAPI") == null ? "" : cobj.get("CCObjectAPI") + "";
462
- } else {
463
- String values = cobj.get(_key) == null ? "" : cobj.get(_key) + "";
464
- obj.put(_key, values);
465
- }
466
- }
467
- arry.add(obj);
468
- //拼接 parObj 参数
469
- JSONObject parObj = new JSONObject();
470
- parObj.put("serviceName", "upsert"); //服务名
471
- parObj.put("objectApiName", objectApiName); //对象名
472
- parObj.put("data", arry.toString()); //查询条件
473
- try {
474
- TriggerInvoker invoker = new TriggerInvoker(userInfo,"upsert","before");
475
- invoker.handler(cobj);
476
- String relStr = CCPost(path, parObj.toString());
477
- JSONObject relObj = new JSONObject();
478
- relObj = JSONObject.parseObject(relStr);
479
- String result = relObj.getString("result");
480
- if ("true".equals(result)) {
481
- JSONArray outData = relObj.getJSONObject("data").getJSONArray("ids");
482
- JSONObject acc = outData.getJSONObject(0);
483
- if(acc.getBoolean("success")){
484
- sr.put("id",acc.getString("id"));
485
- cobj.put("id",acc.getString("id"));
486
- }
487
- invoker = new TriggerInvoker(userInfo,"upsert","before");
488
- invoker.handler(cobj);
489
- }
490
- } catch (Exception e) {
491
- e.printStackTrace();
492
- System.out.println("upsert报错= " + e);
493
- }
494
- return sr;
495
- }
496
-
497
-
498
-
499
-
500
-
501
- /**
502
- * @Description //TODO post请求
503
- * @Author T.han
504
- * @Date 2023/8/18 10:03
505
- * @Param path 接口地址 http://127.0.0.1/cloudcc/outken
506
- * @Param param 参数 json
507
- * @Param IsToken headers是否添加token false:不添加 true:添加
508
- * @return java.lang.String
509
- **/
510
- public String sendPost(String path, String param) {
511
- OutputStreamWriter out = null;
512
- BufferedReader br = null;
513
- StringBuffer sb = new StringBuffer();
514
- String exception = "";
515
- String result = "";
516
- try {
517
- URL url = new URL(path);
518
- HttpURLConnection conn = null;
519
- // 打开和URL之间的连接
520
- conn = (HttpURLConnection) url.openConnection();
521
- // 发送POST请求必须设置如下两行
522
- conn.setDoOutput(true);
523
- conn.setDoInput(true);
524
- conn.setRequestMethod("POST"); // POST方法
525
- conn.setConnectTimeout(15 * 1000);// 设置连接超时时间为5秒
526
- conn.setReadTimeout(20 * 1000);// 设置读取超时时间为20秒
527
- String tokens = "";
528
- // 设置通用的请求属性
529
- conn.setRequestProperty("Content-Type", "application/json");
530
- conn.setRequestProperty("accept", "*/*");
531
- conn.connect();
532
- // 获取URLConnection对象对应的输出流
533
- out = new OutputStreamWriter(conn.getOutputStream());
534
- // 发送请求参数
535
- BufferedWriter bw = new BufferedWriter(out);
536
- bw.write(param);
537
- // flush输出流的缓冲
538
- bw.flush();
539
- // 定义BufferedReader输入流来读取URL的响应
540
- br = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
541
- String line;
542
- while ((line = br.readLine()) != null) {
543
- sb.append(line);
544
- }
545
- } catch (Exception e) {
546
- System.out.println("发送 POST 请求出现异常!" + e);
547
- exception = "发送 POST 请求出现异常!" + e;
548
- e.printStackTrace();
549
- } finally {
550
- try {
551
- if (out != null) {
552
- out.close();
553
- }
554
- if (br != null) {
555
- br.close();
556
- }
557
- } catch (IOException ex) {
558
- ex.printStackTrace();
559
- }
560
- }
561
- if (sb.toString().isEmpty()) {
562
- result = exception;
563
- } else {
564
- result = sb.toString();
565
- }
566
- return result;
567
- }
568
-
569
- public String CCPost(String path, String param) {
570
- OutputStreamWriter out = null;
571
- BufferedReader br = null;
572
- StringBuffer sb = new StringBuffer();
573
- String exception = "";
574
- String result = "";
575
- try {
576
- URL url = new URL(path);
577
- HttpURLConnection conn = null;
578
- // 打开和URL之间的连接
579
- conn = (HttpURLConnection) url.openConnection();
580
- // 发送POST请求必须设置如下两行
581
- conn.setDoOutput(true);
582
- conn.setDoInput(true);
583
- conn.setRequestMethod("POST"); // POST方法
584
- conn.setConnectTimeout(15 * 1000);// 设置连接超时时间为5秒
585
- conn.setReadTimeout(20 * 1000);// 设置读取超时时间为20秒
586
- String tokens = "";
587
- // 设置通用的请求属性
588
- conn.setRequestProperty("Content-Type", "application/json");
589
- conn.setRequestProperty("accept", "*/*");
590
- conn.setRequestProperty("accessToken", ACCESSTOKEN);
591
- conn.connect();
592
- // 获取URLConnection对象对应的输出流
593
- out = new OutputStreamWriter(conn.getOutputStream());
594
- // 发送请求参数
595
- BufferedWriter bw = new BufferedWriter(out);
596
- bw.write(param);
597
- // flush输出流的缓冲
598
- bw.flush();
599
- // 定义BufferedReader输入流来读取URL的响应
600
- br = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
601
- String line;
602
- while ((line = br.readLine()) != null) {
603
- sb.append(line);
604
- }
605
- } catch (Exception e) {
606
- System.out.println("发送 POST 请求出现异常!" + e);
607
- exception = "发送 POST 请求出现异常!" + e;
608
- e.printStackTrace();
609
- } finally {
610
- try {
611
- if (out != null) {
612
- out.close();
613
- }
614
- if (br != null) {
615
- br.close();
616
- }
617
- } catch (IOException ex) {
618
- ex.printStackTrace();
619
- }
620
- }
621
- if (sb.toString().isEmpty()) {
622
- result = exception;
623
- } else {
624
- result = sb.toString();
625
- }
626
- return result;
627
- }
628
-
629
- /**
630
- * @Description //TODO GET请求方法
631
- * @Author T.han
632
- * @Date 2023/8/18 10:06
633
- * @Param path 地址 http://127.0.0.1/cloudcc/outoken?key1=value1&key2=value2
634
- * @return java.lang.String
635
- **/
636
- public static String sendGet(String path) {
637
- StringBuffer sb = new StringBuffer();
638
- String exception = "";
639
- String result = "";
640
- try {
641
- URL url = new URL(path);
642
- InputStream is = url.openStream();
643
- InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);
644
- BufferedReader br = new BufferedReader(isr);
645
- String line;//读取数据
646
- while ((line = br.readLine()) != null) {
647
- sb.append(line);
648
- }
649
- br.close();
650
- isr.close();
651
- is.close();
652
- } catch (Exception e) {
653
- e.printStackTrace();
654
- exception = "发送 GET 请求出现异常!" + e;
655
- }
656
- if (sb.toString().isEmpty()) {
657
- result = exception;
658
- } else {
659
- result = sb.toString();
660
- }
661
- return result;
662
- }
663
-
664
- /**
665
- * 获取自定义列表设置
666
- * @param api 接口名称,用于指定获取哪个接口的自定义设置
667
- * @return 返回一个包含自定义设置数据的Map对象
668
- */
669
- public Map<String,Object> getListCustomSetting(String api) {
670
-
671
- // 初始化数据映射对象,用于存放最终返回的数据
672
- Map<String,Object> datMap = new HashMap<String,Object>();
673
-
674
- // 创建参数数组,用于存放调用接口的参数
675
- JSONArray argArray = new JSONArray();
676
- JSONObject arryStr = new JSONObject();
677
- arryStr.put("argType", String.class);
678
- arryStr.put("argValue", api);
679
- argArray.add(arryStr);
680
-
681
- JSONObject parObj = new JSONObject();
682
- parObj.put("className", "upsert"); //服务名
683
- parObj.put("methodName", "getListCustomSetting"); //方法名
684
- parObj.put("params", argArray); //查询条件
685
- try {
686
- String relStr = CCPost(path, parObj.toString());
687
- JSONObject.parseObject(relStr);
688
- ObjectMapper objectMapper = new ObjectMapper();
689
- // 将对象描述转换为字符串并添加到结果中
690
- datMap = objectMapper.convertValue(objectMapper, Map.class);
691
- } catch (Exception e) {
692
- e.printStackTrace();
693
- logger.error("upsert报错= " + e);
694
- }
695
-
696
- return datMap;
697
- }
698
- /**
699
- * 获取自定义设置列表。
700
- * 通过调用指定API和键值,来获取相应的自定义设置数据。
701
- * @author admin
702
- * @Version Created on 2024.4.10
703
- * @param api 要调用的API名称。
704
- * @param key 查询设置列表时使用的键值。
705
- * @return 返回一个包含自定义设置数据的Map对象。如果发生错误,可能返回空或错误信息的Map。
706
- */
707
- public Map<String,Object> getListCustomSetting(String api, String key) {
708
- Map<String,Object> datMap = new HashMap<String,Object>();
709
- JSONArray argArray = new JSONArray();
710
-
711
- JSONObject apiParam = new JSONObject();
712
- apiParam.put("argType", String.class);
713
- apiParam.put("argValue", api);
714
- argArray.add(apiParam);
715
-
716
- JSONObject keyParam = new JSONObject();
717
- keyParam.put("argType", String.class);
718
- keyParam.put("argValue", api);
719
- argArray.add(keyParam);
720
-
721
- JSONObject parObj = new JSONObject();
722
- parObj.put("className", "TCCCustomSetting"); //服务名
723
- parObj.put("methodName", "getListCustomSetting"); //方法名
724
- parObj.put("params", argArray); //查询条件
725
-
726
- try {
727
- String relStr = CCPost(path, parObj.toString());
728
- JSONObject.parseObject(relStr);
729
- ObjectMapper objectMapper = new ObjectMapper();
730
- // 将对象描述转换为字符串并添加到结果中
731
- datMap = objectMapper.convertValue(objectMapper, Map.class);
732
- } catch (Exception e) {
733
- e.printStackTrace();
734
- logger.error("upsert报错= " + e);
735
- }
736
-
737
- return datMap;
738
- }
739
-
740
- public Map cqueryForEs(String account, String where, String aTrue, String s) {
741
- return null;
742
- }
743
-
744
- public String getPermission(String service_record, String id, String edit) {
745
- return null;
746
- }
747
-
748
- public List<CCObject> cqueryWithRoleRight(String service_record, String s) {
749
- return null;
750
- }
751
-
752
- public ServiceResult insert(CCObject reminder, boolean b, boolean b1, boolean b2, boolean b3) {
753
- return null;
754
- }
755
-
756
- public void addCaseTeam(List<Map> caseteamList, String recordid) {
757
- }
758
-
759
- public ServiceResult update(CCObject serv, boolean b, boolean b1, boolean b2, boolean b3) {
760
- return null;
761
- }
762
- public ServiceResult insertLt(CCObject in) throws Exception {
763
- // TODO Auto-generated method stub
764
- List<CCObject> datalist = new ArrayList<CCObject>();
765
- datalist.add(in);
766
- insert(datalist);
767
- return null;
768
- }
769
-
770
- public ServiceResult updateLt(CCObject objectData) throws Exception {
771
- // TODO Auto-generated method stub
772
- //不执行触发器
773
- return null;
774
- }
775
-
776
- public void addMicroPost(String string, Object object, Object object2, Object object3, Object object4,
777
- Object object5, Object object6, String string2, String emailSubject, String string3, String stkhid,
778
- String stkhid2) {
779
- // TODO Auto-generated method stub
780
-
781
- }
782
-
783
- public String sendEmail(String subject, String htmlBody, String toAddress, String relatedid, String ccaddress, String bccaddress, String attachmentId, String s, String s1) {
784
- return "";
785
- }
786
-
787
- public String uploadAttachment(Map m){
788
- return null;
789
- }
790
-
791
- public void deleteShareObjectBySql(String account, String s) {
792
-
793
- }
794
- public List<CCObject> cqueryByFields(String object, String exp, String fileds) {
795
- return null;
796
- }
797
-
798
- public String submitForApproval(String id, String s, String s1) {
799
- return null;
800
- }
801
-
802
- public String process(String processType, String tid, String touserId, String comments, String appPath) {
803
- return null;
804
- }
805
-
806
- }