q-koa 12.5.0 → 12.5.3
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/core/app.js +16 -1
- package/core/config.js +1 -0
- package/core/file/plugins/system/service.js +1 -1
- package/package.json +1 -1
package/core/app.js
CHANGED
|
@@ -945,6 +945,7 @@ class APP {
|
|
|
945
945
|
'destroy',
|
|
946
946
|
'bulkCreate',
|
|
947
947
|
'count',
|
|
948
|
+
'sum',
|
|
948
949
|
].includes(fn)
|
|
949
950
|
) {
|
|
950
951
|
const excludeAuth =
|
|
@@ -959,7 +960,9 @@ class APP {
|
|
|
959
960
|
await app[appName][hooksList[i]][controller][fn](ctx)
|
|
960
961
|
}
|
|
961
962
|
}
|
|
962
|
-
if (
|
|
963
|
+
if (
|
|
964
|
+
['findOne', 'findAll', 'findAndCountAll', 'count', 'sum'].includes(fn)
|
|
965
|
+
) {
|
|
963
966
|
const {
|
|
964
967
|
where,
|
|
965
968
|
limit,
|
|
@@ -1169,6 +1172,18 @@ class APP {
|
|
|
1169
1172
|
})
|
|
1170
1173
|
ctx.SUCCESS(result)
|
|
1171
1174
|
}
|
|
1175
|
+
if (fn === 'sum') {
|
|
1176
|
+
if (!(attributes && attributes.length === 1)) {
|
|
1177
|
+
throw new Error(`${fn}方法需要attributes一个`)
|
|
1178
|
+
}
|
|
1179
|
+
const result = await app[appName].model[controller][fn](
|
|
1180
|
+
attributes[0],
|
|
1181
|
+
{
|
|
1182
|
+
where: _where,
|
|
1183
|
+
}
|
|
1184
|
+
)
|
|
1185
|
+
ctx.SUCCESS(result)
|
|
1186
|
+
}
|
|
1172
1187
|
if (['findOne', 'findAll', 'findAndCountAll'].includes(fn)) {
|
|
1173
1188
|
// 拆分
|
|
1174
1189
|
if (is_split) {
|
package/core/config.js
CHANGED
|
@@ -135,7 +135,7 @@ exports.initData = async ({ includes, excludes, app, ctx }) => {
|
|
|
135
135
|
if (app.controller[model] && app.controller[model][fn]) {
|
|
136
136
|
return app.controller[model][fn](ctx, data).then((result) => {
|
|
137
137
|
if (!result && process.env.NODE_ENV !== 'production') {
|
|
138
|
-
console.
|
|
138
|
+
console.error(`需要在控制器${fn}中返回`)
|
|
139
139
|
}
|
|
140
140
|
return {
|
|
141
141
|
[item]: result,
|