q-koa 11.6.2 → 11.8.0
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 +11 -30
- package/package.json +1 -1
package/core/app.js
CHANGED
|
@@ -797,13 +797,9 @@ class APP {
|
|
|
797
797
|
Array.isArray(
|
|
798
798
|
this.app[appName].attributes[model][model1 + '_id'].defaultValue
|
|
799
799
|
)) ||
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
(this.app[appName].attributes[model][model1 + '_id'].type &&
|
|
804
|
-
this.app[appName].attributes[model][model1 + '_id'].type.key &&
|
|
805
|
-
this.app[appName].attributes[model][model1 + '_id'].type.key ===
|
|
806
|
-
'JSON')
|
|
800
|
+
this.app[appName].attributes[model][model1 + '_id'].type ===
|
|
801
|
+
Sequelize.DataTypes.JSON
|
|
802
|
+
|
|
807
803
|
if (!is_multiple) {
|
|
808
804
|
this.app[appName].model[model].hasOne(
|
|
809
805
|
this.app[appName].model[model1],
|
|
@@ -1385,13 +1381,7 @@ class APP {
|
|
|
1385
1381
|
(app[appName].attributes[controller][modelName + '_id']
|
|
1386
1382
|
.type &&
|
|
1387
1383
|
app[appName].attributes[controller][modelName + '_id']
|
|
1388
|
-
.type ===
|
|
1389
|
-
(app[appName].attributes[controller][modelName + '_id']
|
|
1390
|
-
.type &&
|
|
1391
|
-
app[appName].attributes[controller][modelName + '_id']
|
|
1392
|
-
.type.key &&
|
|
1393
|
-
app[appName].attributes[controller][modelName + '_id']
|
|
1394
|
-
.type.key === 'JSON')
|
|
1384
|
+
.type === Sequelize.DataTypes.JSON)
|
|
1395
1385
|
)
|
|
1396
1386
|
if (is_single) {
|
|
1397
1387
|
rows[i].setDataValue(
|
|
@@ -1544,13 +1534,7 @@ class APP {
|
|
|
1544
1534
|
(app[appName].attributes[controller][modelName + '_id']
|
|
1545
1535
|
.type &&
|
|
1546
1536
|
app[appName].attributes[controller][modelName + '_id']
|
|
1547
|
-
.type ===
|
|
1548
|
-
(app[appName].attributes[controller][modelName + '_id']
|
|
1549
|
-
.type &&
|
|
1550
|
-
app[appName].attributes[controller][modelName + '_id']
|
|
1551
|
-
.type.key &&
|
|
1552
|
-
app[appName].attributes[controller][modelName + '_id']
|
|
1553
|
-
.type.key === 'JSON')
|
|
1537
|
+
.type === Sequelize.DataTypes.JSON)
|
|
1554
1538
|
)
|
|
1555
1539
|
|
|
1556
1540
|
if (is_single) {
|
|
@@ -1620,14 +1604,7 @@ class APP {
|
|
|
1620
1604
|
app[appName].attributes[controller][modelName + '_id']
|
|
1621
1605
|
.type &&
|
|
1622
1606
|
app[appName].attributes[controller][modelName + '_id']
|
|
1623
|
-
.type ===
|
|
1624
|
-
(app[appName].attributes[controller][modelName + '_id'] &&
|
|
1625
|
-
app[appName].attributes[controller][modelName + '_id']
|
|
1626
|
-
.type &&
|
|
1627
|
-
app[appName].attributes[controller][modelName + '_id'].type
|
|
1628
|
-
.key &&
|
|
1629
|
-
app[appName].attributes[controller][modelName + '_id'].type
|
|
1630
|
-
.key === 'JSON')
|
|
1607
|
+
.type === Sequelize.DataTypes.JSON)
|
|
1631
1608
|
)
|
|
1632
1609
|
|
|
1633
1610
|
if (is_single) {
|
|
@@ -1826,6 +1803,7 @@ class APP {
|
|
|
1826
1803
|
}
|
|
1827
1804
|
}
|
|
1828
1805
|
|
|
1806
|
+
let createTarget = null
|
|
1829
1807
|
if (fn === 'upsert' || fn === 'create') {
|
|
1830
1808
|
if (_.isEmpty(ctx.request.body)) {
|
|
1831
1809
|
throw new Error('新增不能为空')
|
|
@@ -1863,6 +1841,9 @@ class APP {
|
|
|
1863
1841
|
: 0,
|
|
1864
1842
|
...newData,
|
|
1865
1843
|
})
|
|
1844
|
+
if (fn === 'create') {
|
|
1845
|
+
createTarget = flag.toJSON ? flag.toJSON() : flag
|
|
1846
|
+
}
|
|
1866
1847
|
ctx.SUCCESS(flag)
|
|
1867
1848
|
|
|
1868
1849
|
if (cacheModel.includes(controller)) {
|
|
@@ -1910,7 +1891,7 @@ class APP {
|
|
|
1910
1891
|
}
|
|
1911
1892
|
|
|
1912
1893
|
if (_.get(app, `${appName}.afterExecute.${controller}.${fn}`)) {
|
|
1913
|
-
app[appName].afterExecute[controller][fn](ctx)
|
|
1894
|
+
app[appName].afterExecute[controller][fn](ctx, createTarget)
|
|
1914
1895
|
.then((res) => {
|
|
1915
1896
|
if (is_dev) {
|
|
1916
1897
|
console.log('afterUpdate', res)
|