q-koa 8.6.6 → 8.7.1

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