haha600 před 5 roky
rodič
revize
cffb67940c

binární
1.dmp


+ 0 - 2
facade/src/app/routes/sys/list/list.component.ts

@@ -76,8 +76,6 @@ export class SysListComponent implements OnInit {
76 76
     }
77 77
 
78 78
 
79
-
80
-
81 79
   }
82 80
 
83 81
 

+ 19 - 0
facade/src/app/service/module.service.ts

@@ -303,6 +303,25 @@ constructor(private http: _HttpClient,
303 303
             return this['http'].post('rest/' + name, body);
304 304
         }
305 305
 
306
+
307
+        /**
308
+         * 读取列表数据
309
+         */
310
+        getList(name: string, body?: any) {
311
+          return this['http'].get('rest/' + name, {body: JSON.stringify(body || {})} );
312
+        }
313
+
314
+        /**
315
+         * 删除操作
316
+         * @param name api
317
+         * @param params 参数
318
+         */
319
+        deleteData(name: string, params?: any) {
320
+          if (typeof params === 'object')
321
+            params = JSON.stringify(params);
322
+          return this['http'].delete('rest/' + name + '/' + params);
323
+        }
324
+
306 325
         post(name: string, body?: any, params?: any, options?: any) { // TODO 即将删除,不建议使用
307 326
           return this['moduleSvr'].post(this['module'].id, name, body, params, options);
308 327
         }

+ 6 - 1
src/main/java/com/kingkong/bljs/api/RestController.java

@@ -25,7 +25,7 @@ public class RestController extends BaseController {
25 25
      * @return
26 26
      */
27 27
     @GetMapping("{code}")
28
-    public Object get(@PathVariable String code, @RequestBody String body) throws Exception{
28
+    public Object get(@PathVariable String code, @RequestParam("body") String body) throws Exception{
29 29
         return restService.getData(code,body);
30 30
     }
31 31
 
@@ -42,6 +42,11 @@ public class RestController extends BaseController {
42 42
         return restService.post(code,body);
43 43
     }
44 44
 
45
+    @DeleteMapping("{code}/{params}")
46
+    public Object delete(@PathVariable String code,@PathVariable String params) throws Exception{
47
+        return restService.delete(code,params);
48
+    }
49
+
45 50
 }
46 51
 
47 52
 

+ 43 - 5
src/main/java/com/kingkong/bljs/service/RestService.java

@@ -1,13 +1,18 @@
1 1
 package com.kingkong.bljs.service;
2 2
 
3 3
 
4
+import com.alibaba.fastjson.JSONArray;
4 5
 import com.alibaba.fastjson.JSONObject;
5 6
 import com.kingkong.bljs.dao.UserApiMapper;
6 7
 import com.kingkong.bljs.entity.UserApi;
8
+import com.kingkong.bljs.util.ListUtil;
7 9
 import org.apache.catalina.User;
8 10
 import org.springframework.beans.factory.annotation.Autowired;
9 11
 import org.springframework.stereotype.Service;
10 12
 
13
+import java.util.ArrayList;
14
+import java.util.List;
15
+
11 16
 @Service
12 17
 public class RestService {
13 18
 
@@ -39,15 +44,15 @@ public class RestService {
39 44
             throw new Exception("未实现的的操作!");
40 45
         }
41 46
         else if(2 == api.getType()) { //JS
42
-            return jsAction(api,request);
47
+            JSONObject object = JSONObject.parseObject(request);
48
+            return jsAction(api,object);
43 49
         }
44 50
 
45 51
         return null;
46 52
     }
47 53
 
48
-    private Object jsAction(UserApi api,String request) throws Exception{
49
-        JSONObject object = JSONObject.parseObject(request);
50
-        return moduleService.batchOperation(api.getContent(),object);
54
+    private Object jsAction(UserApi api,Object request) throws Exception{
55
+        return moduleService.batchOperation(api.getContent(),request);
51 56
     }
52 57
 
53 58
     private Object sqlAction(UserApi api,String request) {
@@ -76,7 +81,40 @@ public class RestService {
76 81
             //TODO
77 82
         }
78 83
         else if(2 == api.getType()) { //JS
79
-            return jsAction(api,request);
84
+            JSONObject object = JSONObject.parseObject(request);
85
+            return jsAction(api,object);
86
+        }
87
+
88
+        return null;
89
+    }
90
+
91
+
92
+    /**
93
+     * 删除操作
94
+     * @param code api
95
+     * @param params 参数
96
+     * @return
97
+     */
98
+    public Object delete(String code,String params) throws Exception{
99
+        UserApi api = userApiMapper.findByCodeAndType(code,2);
100
+        if(null == api)
101
+            throw new Exception("未找到操作 " + code);
102
+
103
+        if(0 == api.getType()) { //SQL
104
+            throw new Exception("未实现的的操作!");
105
+        }
106
+        else if(1 == api.getType()){ //存储过程,要求参数为数组
107
+            JSONArray arr = JSONObject.parseArray(params);
108
+
109
+            List<Object> ps = new ArrayList<Object>();
110
+            for(int i = 0;i < arr.size() ;i ++)
111
+                ps.add(arr.get(i));
112
+
113
+            this.queryService.executeProc(api.getContent(),ps);
114
+            return null;
115
+        }
116
+        else if(2 == api.getType()) { //JS
117
+            return jsAction(api,params);
80 118
         }
81 119
 
82 120
         return null;

+ 1 - 1
src/main/resources/application-c.properties

@@ -49,6 +49,6 @@ spring.thymeleaf.encoding=UTF-8
49 49
 
50 50
 
51 51
 #websocketĹäÖĂ
52
-netty-websocket.host=192.168.1.146
52
+netty-websocket.host=127.0.0.1
53 53
 netty-websocket.path=/
54 54
 netty-websocket.port=9021

+ 6 - 1
src/main/resources/application-h.properties

@@ -46,4 +46,9 @@ spring.thymeleaf.cache=false
46 46
 spring.thymeleaf.prefix=classpath:/templates/
47 47
 spring.thymeleaf.check-template-location=true
48 48
 spring.thymeleaf.suffix=.html
49
-spring.thymeleaf.encoding=UTF-8
49
+spring.thymeleaf.encoding=UTF-8
50
+
51
+#websocketÅäÖÃ
52
+netty-websocket.host=127.0.0.1
53
+netty-websocket.path=/
54
+netty-websocket.port=9021