q-koa 8.6.5 → 8.7.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.
@@ -4,7 +4,7 @@ module.exports = {
4
4
  multiple: false,
5
5
  availableSort: true,
6
6
  order: [],
7
- select: [],
7
+ select: [{ key: 'parent_id' }],
8
8
  excludes: [],
9
9
  limit: 40,
10
10
  defaultOrder: [{ sort: 'ascending', type: 'sortOrder' }],
@@ -16,13 +16,32 @@ exports.getList = (config) => (type) => {
16
16
  }
17
17
 
18
18
  exports.getObject = (config, app) => async (type) => {
19
+ const obj = config.find((i) => i.code === type)
20
+ if (!obj) throw new Error(`找不到${type}相关设置`)
21
+ const list = config.filter((i) => i.parent_id === obj.id)
22
+ const temObj = {}
23
+ for (let i = 0; i < list.length; i++) {
24
+ if (list[i].type === 'decimal') {
25
+ temObj[list[i].code] = Number(list[i].value)
26
+ } else if (list[i].type === 'switch') {
27
+ temObj[list[i].code] = Boolean(Number(list[i].value))
28
+ } else {
29
+ temObj[list[i].code] = list[i].value
30
+ }
31
+ }
32
+
33
+ const findConfig = (item) => item.config === type || item.pay_config === type
19
34
  if (app) {
20
35
  const applicationList = app.cache.get('application')
21
36
  if (
22
37
  applicationList &&
23
- applicationList.find((item) => item.config === type)
38
+ applicationList.find(findConfig) &&
39
+ applicationList.find(findConfig)
24
40
  ) {
25
- return applicationList.find((item) => item.config === type)
41
+ return {
42
+ ...applicationList.find(findConfig),
43
+ ...temObj,
44
+ }
26
45
  }
27
46
 
28
47
  if (!applicationList) {
@@ -32,27 +51,18 @@ exports.getObject = (config, app) => async (type) => {
32
51
  if (result.length > 0) {
33
52
  app.cache.set('application', JSON.parse(JSON.stringify(result)))
34
53
 
35
- const target = result.find((item) => item.config === type)
54
+ const target = result.find(findConfig)
36
55
  if (target) {
37
- return target
56
+ return {
57
+ ...target,
58
+ ...temObj,
59
+ }
38
60
  }
39
61
  }
40
62
  }
41
63
  }
42
64
  }
43
- const obj = config.find((i) => i.code === type)
44
- if (!obj) throw new Error(`找不到${type}相关设置`)
45
- const list = config.filter((i) => i.parent_id === obj.id)
46
- const temObj = {}
47
- for (let i = 0; i < list.length; i++) {
48
- if (list[i].type === 'decimal') {
49
- temObj[list[i].code] = Number(list[i].value)
50
- } else if (list[i].type === 'switch') {
51
- temObj[list[i].code] = Boolean(Number(list[i].value))
52
- } else {
53
- temObj[list[i].code] = list[i].value
54
- }
55
- }
65
+
56
66
  return temObj
57
67
  }
58
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "8.6.5",
3
+ "version": "8.7.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {