q-koa 12.4.5 → 12.4.6
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 +10 -6
- package/core/file/plugins/system/controller.js +38 -0
- package/package.json +1 -1
package/core/app.js
CHANGED
|
@@ -648,12 +648,16 @@ class APP {
|
|
|
648
648
|
beforeCreate: (res, t) => {
|
|
649
649
|
try {
|
|
650
650
|
if (folder === 'log') {
|
|
651
|
-
this.
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
651
|
+
if (this.is_dev && !this.app[appName].service.log) {
|
|
652
|
+
console.error('缺少log/service.js,')
|
|
653
|
+
}
|
|
654
|
+
this.app[appName].service.log &&
|
|
655
|
+
this.app[appName].service.log.push({
|
|
656
|
+
app: this.app[appName],
|
|
657
|
+
appName,
|
|
658
|
+
message: res.toJSON().message,
|
|
659
|
+
url: res.toJSON().url,
|
|
660
|
+
})
|
|
657
661
|
}
|
|
658
662
|
if (res.toJSON().user_id) {
|
|
659
663
|
res.createdid = res.toJSON().user_id
|
|
@@ -561,6 +561,44 @@ exports.dashboard = async (ctx) => {
|
|
|
561
561
|
ctx.SUCCESS(result)
|
|
562
562
|
}
|
|
563
563
|
|
|
564
|
+
exports.showModelCount = async (ctx) => {
|
|
565
|
+
const { app, appName } = getAppByCtx(ctx)
|
|
566
|
+
const { is_count = false } = ctx.request.body
|
|
567
|
+
const result = await app.sequelize.showAllSchemas()
|
|
568
|
+
const list = result.map(
|
|
569
|
+
(item) => item[`Tables_in_${app.sequelize.config.database}`]
|
|
570
|
+
)
|
|
571
|
+
let tableList = []
|
|
572
|
+
for (let i = 0; i < list.length; i++) {
|
|
573
|
+
if (!app.model[list[i]]) continue
|
|
574
|
+
const defaultConfigPath = path.resolve(__dirname, `../${list[i]}/config.js`)
|
|
575
|
+
const defaultConfigExist = fs.existsSync(defaultConfigPath)
|
|
576
|
+
const target =
|
|
577
|
+
app.config[list[i]] &&
|
|
578
|
+
Object.keys(app.config[list[i]]).length === 0 &&
|
|
579
|
+
defaultConfigExist
|
|
580
|
+
? require(defaultConfigPath)
|
|
581
|
+
: app.config[list[i]]
|
|
582
|
+
const count = await app.model[list[i]].count()
|
|
583
|
+
const maxTarget = await app.model[list[i]].findOne({
|
|
584
|
+
order: [['id', 'DESC']],
|
|
585
|
+
attributes: ['id'],
|
|
586
|
+
})
|
|
587
|
+
if (maxTarget) {
|
|
588
|
+
tableList = [
|
|
589
|
+
...tableList,
|
|
590
|
+
{
|
|
591
|
+
count,
|
|
592
|
+
max_id: maxTarget.id,
|
|
593
|
+
name: target.name,
|
|
594
|
+
model: list[i],
|
|
595
|
+
},
|
|
596
|
+
]
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return ctx.SUCCESS(tableList.sort((a, b) => b.count - a.count))
|
|
600
|
+
}
|
|
601
|
+
|
|
564
602
|
exports.showAllModel = async (ctx) => {
|
|
565
603
|
const { app, appName } = getAppByCtx(ctx)
|
|
566
604
|
const { is_count = false } = ctx.request.body
|