@steedos/service-rest 2.7.0-beta.16 → 2.7.0-beta.17
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/package.json +4 -4
- package/package.service.js +96 -96
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-rest",
|
|
3
|
-
"version": "2.7.0-beta.
|
|
3
|
+
"version": "2.7.0-beta.17",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"repository": {},
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@steedos/objectql": "2.7.0-beta.
|
|
20
|
-
"@steedos/service-object-mixin": "2.7.0-beta.
|
|
19
|
+
"@steedos/objectql": "2.7.0-beta.17",
|
|
20
|
+
"@steedos/service-object-mixin": "2.7.0-beta.17",
|
|
21
21
|
"lodash": "^4.17.21"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "f2bf560c34c9ad19951c39d8fb045fd7b2fe69e6"
|
|
24
24
|
}
|
package/package.service.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: sunhaolin@hotoa.com
|
|
3
3
|
* @Date: 2023-03-23 15:12:14
|
|
4
4
|
* @LastEditors: baozhoutao@steedos.com
|
|
5
|
-
* @LastEditTime: 2024-
|
|
5
|
+
* @LastEditTime: 2024-04-01 16:41:07
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
8
|
"use strict";
|
|
@@ -59,102 +59,102 @@ module.exports = {
|
|
|
59
59
|
* @apiBody {Object[]} delete 删除数据, 例如: [{objectName: 'contracts', id: "xxx"}]
|
|
60
60
|
* @apiName batch
|
|
61
61
|
*/
|
|
62
|
-
batch: {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
62
|
+
// batch: {
|
|
63
|
+
// rest: {
|
|
64
|
+
// method: "POST",
|
|
65
|
+
// path: "/batch"
|
|
66
|
+
// },
|
|
67
|
+
// async handler(ctx){
|
|
68
|
+
|
|
69
|
+
// const { find, count, findOne, insert, update, delete: deleteAs } = ctx.params;
|
|
70
|
+
|
|
71
|
+
// const res = {}
|
|
72
|
+
|
|
73
|
+
// const findRes = [];
|
|
74
|
+
// if(find){
|
|
75
|
+
// for (const item of find) {
|
|
76
|
+
// const args = {...item};
|
|
77
|
+
// if(_.has(item, 'fields') && !_.isString(item.fields) ){
|
|
78
|
+
// args.fields = JSON.stringify(item.fields)
|
|
79
|
+
// }
|
|
80
|
+
// if(_.has(item, 'uiFields') && !_.isString(item.uiFields) ){
|
|
81
|
+
// args.uiFields = JSON.stringify(item.uiFields)
|
|
82
|
+
// }
|
|
83
|
+
// if(_.has(item, 'expandFields') && !_.isString(item.expandFields) ){
|
|
84
|
+
// args.expandFields = JSON.stringify(item.expandFields)
|
|
85
|
+
// }
|
|
86
|
+
// if(_.has(item, 'filters') && !_.isString(item.filters) ){
|
|
87
|
+
// args.filters = JSON.stringify(item.filters)
|
|
88
|
+
// }
|
|
89
|
+
// findRes.push(ctx.broker.call(`rest.find`, args).catch(err => {
|
|
90
|
+
// return err;
|
|
91
|
+
// }))
|
|
92
|
+
// }
|
|
93
|
+
|
|
94
|
+
// res.find = await Promise.all(findRes);
|
|
95
|
+
// }
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
},
|
|
97
|
+
// const countRes = [];
|
|
98
|
+
// if(count){
|
|
99
|
+
// for (const item of count) {
|
|
100
|
+
// const args = {...item};
|
|
101
|
+
// if(_.has(item, 'filters') && !_.isString(item.filters) ){
|
|
102
|
+
// args.filters = JSON.stringify(item.filters)
|
|
103
|
+
// }
|
|
104
|
+
// countRes.push(ctx.broker.call(`rest.count`, args).catch(err => {
|
|
105
|
+
// return err;
|
|
106
|
+
// }))
|
|
107
|
+
// }
|
|
108
|
+
// res.count = await Promise.all(countRes);
|
|
109
|
+
// }
|
|
110
|
+
|
|
111
|
+
// const findOneRes = []
|
|
112
|
+
// if(findOne){
|
|
113
|
+
// for (const item of findOne) {
|
|
114
|
+
// const args = {...item};
|
|
115
|
+
// if(_.has(item, 'fields') && !_.isString(item.fields) ){
|
|
116
|
+
// args.fields = JSON.stringify(item.fields)
|
|
117
|
+
// }
|
|
118
|
+
// findOneRes.push(ctx.broker.call(`rest.findOne`, args).catch(err => {
|
|
119
|
+
// return err;
|
|
120
|
+
// }))
|
|
121
|
+
// }
|
|
122
|
+
// res.findOne = await Promise.all(findOneRes);
|
|
123
|
+
// }
|
|
124
|
+
|
|
125
|
+
// const insertRes = []
|
|
126
|
+
// if(insert){
|
|
127
|
+
// for (const item of insert) {
|
|
128
|
+
// insertRes.push(ctx.broker.call(`rest.insert`, item).catch(err => {
|
|
129
|
+
// return err;
|
|
130
|
+
// }))
|
|
131
|
+
// }
|
|
132
|
+
// res.insert = await Promise.all(insertRes);
|
|
133
|
+
// }
|
|
134
|
+
|
|
135
|
+
// const updateRes = []
|
|
136
|
+
// if(update){
|
|
137
|
+
// for (const item of update) {
|
|
138
|
+
// updateRes.push(ctx.broker.call(`rest.update`, item).catch(err => {
|
|
139
|
+
// return err;
|
|
140
|
+
// }))
|
|
141
|
+
// }
|
|
142
|
+
// res.update = await Promise.all(updateRes);
|
|
143
|
+
// }
|
|
144
|
+
|
|
145
|
+
// const deleteRes = []
|
|
146
|
+
// if(deleteAs){
|
|
147
|
+
// for (const item of deleteAs) {
|
|
148
|
+
// deleteRes.push(ctx.broker.call(`rest.delete`, item).catch(err => {
|
|
149
|
+
// return err;
|
|
150
|
+
// }))
|
|
151
|
+
// }
|
|
152
|
+
// res.delete = await Promise.all(deleteRes);
|
|
153
|
+
// }
|
|
154
|
+
|
|
155
|
+
// return res;
|
|
156
|
+
// }
|
|
157
|
+
// },
|
|
158
158
|
/**
|
|
159
159
|
* @api {GET} /api/v1/:objectName 获取列表记录
|
|
160
160
|
* @apiVersion 0.0.0
|