q-koa 8.8.3 → 8.8.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/config.js CHANGED
@@ -1,3 +1,4 @@
1
+ const axios = require('axios')
1
2
  const { Sequelize } = require('sequelize')
2
3
  const db = new Map()
3
4
  module.exports = {
@@ -131,6 +132,15 @@ module.exports = {
131
132
  },
132
133
  cacheModel: [],
133
134
  defaultRouter: (router) => (app) => {
135
+ router.get('/weixin/h5_login', app.controller.weixin.h5_login)
136
+ router.get(
137
+ '/weixin/h5_login_callback',
138
+ app.controller.weixin.h5_login_callback
139
+ )
140
+ router.get(
141
+ '/weixin/h5_login_info_callback',
142
+ app.controller.weixin.h5_login_info_callback
143
+ )
134
144
  router.get('/common/getAppConfig', app.controller.common.getAppConfig)
135
145
  router.get('/weixin/messagePush', app.controller.weixin.messagePush)
136
146
  router.get('/common/createQr', app.controller.common.createQr)
@@ -182,6 +182,7 @@ exports.createQr = async (ctx) => {
182
182
  const { app, appName } = getAppByCtx(ctx)
183
183
 
184
184
  const { url, size = 10 } = ctx.request.query
185
+ if (!url) return ctx.ERROR('?url')
185
186
  const img = qr.image(url, {
186
187
  size: Number(size),
187
188
  })
@@ -48,3 +48,56 @@ exports.copyOther = async (ctx) => {
48
48
 
49
49
  ctx.SUCCESS('ok')
50
50
  }
51
+
52
+ exports.init = async (ctx) => {
53
+ const { app, appName } = getAppByCtx(ctx)
54
+
55
+ const parentList = await app.model.setting.findAll({
56
+ where: {
57
+ parent_id: 0,
58
+ },
59
+ order: [['id', 'ASC']],
60
+ raw: true,
61
+ })
62
+
63
+ let list = []
64
+ let number = 0
65
+ for (let i = 0; i < parentList.length; i++) {
66
+ number += 1
67
+ const { id: parent_id, ...rest } = parentList[i]
68
+ list = [
69
+ ...list,
70
+ {
71
+ id: number,
72
+ ...rest,
73
+ parent_id: 0,
74
+ },
75
+ ]
76
+ const childList = await app.model.setting.findAll({
77
+ where: {
78
+ parent_id,
79
+ },
80
+ order: [['id', 'ASC']],
81
+ raw: true,
82
+ })
83
+ list = [
84
+ ...list,
85
+ ...childList.map((item, index) => {
86
+ const { id: child_id, ...restChild } = item
87
+ const id = number + index + 1
88
+
89
+ return {
90
+ id,
91
+ ...restChild,
92
+ parent_id: number,
93
+ }
94
+ }),
95
+ ]
96
+ number += childList.length
97
+ }
98
+
99
+ await app.model.setting.sync({ force: true })
100
+ await app.model.setting.bulkCreate(list)
101
+
102
+ ctx.SUCCESS(list)
103
+ }
@@ -183,6 +183,8 @@ exports.showTables = async (ctx) => {
183
183
  deleteCheckList: lodash.get(target, 'deleteCheckList', []),
184
184
  // 批量更新字段
185
185
  bulkCreateList: lodash.get(target, 'bulkCreateList', []),
186
+
187
+ fn: app.controller[_model] ? Object.keys(app.controller[_model]) : [],
186
188
  }
187
189
  })
188
190
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "8.8.3",
3
+ "version": "8.8.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {