q-koa 9.8.1 → 9.9.9

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 CHANGED
@@ -21,7 +21,8 @@ const util = require('util')
21
21
  const jwt = require('jsonwebtoken')
22
22
  const verify = util.promisify(jwt.verify)
23
23
  const fsExtra = require('fs-extra')
24
- const { getObject } = require('./file/utils')
24
+ const { getObject, getAppConfig } = require('./file/utils')
25
+
25
26
  const restc = require('./restc')
26
27
  const APP_DIR = 'app'
27
28
  const PLUGINS_DIR = 'plugins'
@@ -2001,4 +2002,6 @@ APP.getConfig = (app) => ({
2001
2002
  },
2002
2003
  })
2003
2004
 
2005
+ APP.getAppConfig = getAppConfig
2006
+
2004
2007
  module.exports = APP
@@ -950,7 +950,7 @@ exports.mp_pay = async (ctx) => {
950
950
  throw new Error(
951
951
  payResult.return_msg === '签名错误,请检查后再试'
952
952
  ? payResult.return_msg + '(商户号/APIv2/关联)'
953
- : payResult.return_msg
953
+ : payResult.err_code_des + '(商户号/APIv2/关联)'
954
954
  )
955
955
  }
956
956
  throw new Error(`支付失败,请重试`)
@@ -1,5 +1,12 @@
1
1
  const { lodash } = require('q-koa')
2
2
 
3
+ const findConfig = (type) => (item) =>
4
+ item.key === type ||
5
+ item.config === type ||
6
+ item.pay_config === type ||
7
+ (item.ToUserName && item.ToUserName === type) ||
8
+ (item.appId && item.appId === type)
9
+
3
10
  exports.getSetting = (config) => (type) =>
4
11
  config.find((i) => i.key === type).value
5
12
 
@@ -34,18 +41,12 @@ exports.getObject = (config, app) => async (type) => {
34
41
  flag = true
35
42
  }
36
43
 
37
- const findConfig = (item) =>
38
- item.key === type ||
39
- item.config === type ||
40
- item.pay_config === type ||
41
- (item.ToUserName && item.ToUserName === type) ||
42
- (item.appId && item.appId === type)
43
44
  if (app) {
44
45
  const applicationList = app.cache.get('application')
45
- if (applicationList && applicationList.find(findConfig)) {
46
+ if (applicationList && applicationList.find(findConfig(type))) {
46
47
  flag = true
47
48
  return {
48
- ...applicationList.find(findConfig),
49
+ ...applicationList.find(findConfig(type)),
49
50
  ...temObj,
50
51
  }
51
52
  }
@@ -58,7 +59,7 @@ exports.getObject = (config, app) => async (type) => {
58
59
  const formatData = JSON.parse(JSON.stringify(result))
59
60
  app.cache.set('application', formatData)
60
61
 
61
- const target = formatData.find(findConfig)
62
+ const target = formatData.find(findConfig(type))
62
63
  if (target) {
63
64
  flag = true
64
65
  return {
@@ -159,12 +160,12 @@ exports.getImageType = (fileBuffer) => {
159
160
  return ''
160
161
  }
161
162
 
162
- exports.getAppConfig = async ({ app, config }) => {
163
- if (!config || !app) return null
163
+ exports.getAppConfig = async ({ app, config, key }) => {
164
+ if (!(app && (config || key))) return null
164
165
  const application =
165
166
  app.cache.get('application') || (await app.model.application.findAll())
166
167
 
167
- const target = application.find((a) => a.config === config)
168
+ const target = application.find(findConfig(config || key))
168
169
 
169
- return target
170
+ return target || null
170
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "9.8.1",
3
+ "version": "9.9.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {