q-koa 7.7.2
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 +1813 -0
- package/core/config.js +124 -0
- package/core/file/plugins/administrator/config.js +17 -0
- package/core/file/plugins/administrator/controller.js +264 -0
- package/core/file/plugins/administrator/model.js +53 -0
- package/core/file/plugins/administrator/validate.js +41 -0
- package/core/file/plugins/alipay/controller.js +68 -0
- package/core/file/plugins/alipay/validate.js +9 -0
- package/core/file/plugins/cache/service.js +16 -0
- package/core/file/plugins/cloudfunction/config.js +4 -0
- package/core/file/plugins/cloudfunction/model.js +15 -0
- package/core/file/plugins/common/controller.js +398 -0
- package/core/file/plugins/common/validate.js +47 -0
- package/core/file/plugins/douyin/config.js +3 -0
- package/core/file/plugins/douyin/controller.js +521 -0
- package/core/file/plugins/douyin/validate.js +40 -0
- package/core/file/plugins/douyin_user/config.js +15 -0
- package/core/file/plugins/douyin_user/model.js +72 -0
- package/core/file/plugins/good_sku/controller.js +80 -0
- package/core/file/plugins/h5_user/config.js +19 -0
- package/core/file/plugins/h5_user/model.js +71 -0
- package/core/file/plugins/lang/config.js +4 -0
- package/core/file/plugins/lang/model.js +15 -0
- package/core/file/plugins/language/config.js +5 -0
- package/core/file/plugins/language/model.js +54 -0
- package/core/file/plugins/log/config.js +25 -0
- package/core/file/plugins/log/controller.js +31 -0
- package/core/file/plugins/log/model.js +51 -0
- package/core/file/plugins/model/config.js +12 -0
- package/core/file/plugins/model/controller.js +69 -0
- package/core/file/plugins/model/model.js +169 -0
- package/core/file/plugins/model/service.js +218 -0
- package/core/file/plugins/model/validate.js +42 -0
- package/core/file/plugins/model_attributes/config.js +12 -0
- package/core/file/plugins/model_attributes/model.js +114 -0
- package/core/file/plugins/mp_user/config.js +19 -0
- package/core/file/plugins/mp_user/model.js +59 -0
- package/core/file/plugins/permission/config.js +15 -0
- package/core/file/plugins/permission/model.js +91 -0
- package/core/file/plugins/role/config.js +27 -0
- package/core/file/plugins/role/controller.js +26 -0
- package/core/file/plugins/role/model.js +58 -0
- package/core/file/plugins/role_permission/config.js +12 -0
- package/core/file/plugins/role_permission/controller.js +27 -0
- package/core/file/plugins/role_permission/model.js +24 -0
- package/core/file/plugins/routes/config.js +17 -0
- package/core/file/plugins/routes/controller.js +153 -0
- package/core/file/plugins/routes/model.js +70 -0
- package/core/file/plugins/routes/service.js +22 -0
- package/core/file/plugins/setting/afterExecute.js +14 -0
- package/core/file/plugins/setting/config.js +14 -0
- package/core/file/plugins/setting/controller.js +50 -0
- package/core/file/plugins/setting/model.js +118 -0
- package/core/file/plugins/setting/validate.js +42 -0
- package/core/file/plugins/system/controller.js +501 -0
- package/core/file/plugins/system/service.js +148 -0
- package/core/file/plugins/system/validate.js +40 -0
- package/core/file/plugins/todolist/config.js +31 -0
- package/core/file/plugins/todolist/model.js +69 -0
- package/core/file/plugins/toutiao/controller.js +201 -0
- package/core/file/plugins/toutiao_user/config.js +15 -0
- package/core/file/plugins/toutiao_user/model.js +66 -0
- package/core/file/plugins/user/afterExecute.js +38 -0
- package/core/file/plugins/user/config.js +9 -0
- package/core/file/plugins/user/controller.js +329 -0
- package/core/file/plugins/user/model.js +96 -0
- package/core/file/plugins/user/test.js +71 -0
- package/core/file/plugins/user/validate.js +44 -0
- package/core/file/plugins/video/config.js +3 -0
- package/core/file/plugins/video/controller.js +15 -0
- package/core/file/plugins/video/validate.js +12 -0
- package/core/file/plugins/weixin/config.js +3 -0
- package/core/file/plugins/weixin/controller.js +994 -0
- package/core/file/plugins/weixin/service.js +105 -0
- package/core/file/plugins/weixin/validate.js +111 -0
- package/core/file/services/aliSms.js +45 -0
- package/core/file/services/alipay.js +123 -0
- package/core/file/services/amap.js +95 -0
- package/core/file/services/card.js +24 -0
- package/core/file/services/config.js +38 -0
- package/core/file/services/douyin.js +151 -0
- package/core/file/services/email.js +45 -0
- package/core/file/services/express.js +37 -0
- package/core/file/services/geo.js +71 -0
- package/core/file/services/qqVideo.js +64 -0
- package/core/file/services/toutiao.js +102 -0
- package/core/file/services/weixin.js +79 -0
- package/core/file/services/weixinArticle.js +53 -0
- package/core/file/services/weixinCrypt.js +34 -0
- package/core/file/services/weixinMP.js +435 -0
- package/core/file/services/weixinPay.js +35 -0
- package/core/file/services/xml.js +33 -0
- package/core/file/task/shop/index.js +589 -0
- package/core/file/task/shop/static/562e45760a44632de6fa7219bab78cce.png +0 -0
- package/core/file/task/shop/static/d7aeaeb6bfd68f71a00a83c0f5548363.png +0 -0
- package/core/file/utils/index.js +61 -0
- package/core/middlewares.js +120 -0
- package/core/restc/.npminstall.done +1 -0
- package/core/restc/LICENSE +21 -0
- package/core/restc/README.md +48 -0
- package/core/restc/faas/index.html +1112 -0
- package/core/restc/faas/index.txt +31 -0
- package/core/restc/faas/install_production.sh +6 -0
- package/core/restc/index.d.ts +7 -0
- package/core/restc/index.js +9 -0
- package/core/restc/lib/express.js +7 -0
- package/core/restc/lib/hapi.js +17 -0
- package/core/restc/lib/hapiLegacy.js +15 -0
- package/core/restc/lib/index.js +46 -0
- package/core/restc/lib/koa.js +9 -0
- package/core/restc/lib/koa2.js +9 -0
- package/core/restc/lib/utils/gateway.js +51 -0
- package/core/restc/package.json +41 -0
- package/core/validator.js +15 -0
- package/index.js +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const { getAppByCtx, lodash } = require('multiple-quick-koa')
|
|
2
|
+
|
|
3
|
+
exports.update = async (ctx) => {
|
|
4
|
+
const { app } = getAppByCtx(ctx)
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
skuList,
|
|
8
|
+
good_id,
|
|
9
|
+
useAttributeList,
|
|
10
|
+
skuModelList,
|
|
11
|
+
forceUpdate = false,
|
|
12
|
+
} = ctx.request.body
|
|
13
|
+
|
|
14
|
+
if (forceUpdate) {
|
|
15
|
+
await app.model.good_attribute.destroy({
|
|
16
|
+
where: {
|
|
17
|
+
good_id,
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const updateAttributeList = []
|
|
23
|
+
for (let i = 0; i < useAttributeList.length; i++) {
|
|
24
|
+
const { id: _id, ...rest } = useAttributeList[i]
|
|
25
|
+
if (forceUpdate) {
|
|
26
|
+
const { id, name, attribute_id } = await app.model.good_attribute.create({
|
|
27
|
+
...rest,
|
|
28
|
+
good_id,
|
|
29
|
+
})
|
|
30
|
+
updateAttributeList.push({
|
|
31
|
+
id,
|
|
32
|
+
attribute_id,
|
|
33
|
+
name,
|
|
34
|
+
})
|
|
35
|
+
} else {
|
|
36
|
+
updateAttributeList.push(useAttributeList[i])
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 会删除所有sku,所以必须在bulkCreate的时候带上
|
|
41
|
+
*/
|
|
42
|
+
await app.model.good_sku.destroy({
|
|
43
|
+
where: {
|
|
44
|
+
good_id,
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
const skuListData = skuList.map((item) => {
|
|
48
|
+
const { attribute_id, good_attribute_id, ...rest } = item
|
|
49
|
+
const _attribute_id = Object.entries(rest)
|
|
50
|
+
.filter(([key, value]) => {
|
|
51
|
+
return updateAttributeList.find((use) => use.name === value)
|
|
52
|
+
})
|
|
53
|
+
.map(([key, value]) => {
|
|
54
|
+
return updateAttributeList.find((use) => use.name === value).id
|
|
55
|
+
})
|
|
56
|
+
if (!forceUpdate) {
|
|
57
|
+
return {
|
|
58
|
+
...rest,
|
|
59
|
+
good_attribute_id: Array.isArray(good_attribute_id)
|
|
60
|
+
? good_attribute_id
|
|
61
|
+
: [good_attribute_id],
|
|
62
|
+
id: rest.id,
|
|
63
|
+
good_id,
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
const { id, ...restNew } = rest
|
|
67
|
+
return {
|
|
68
|
+
...restNew,
|
|
69
|
+
good_id,
|
|
70
|
+
good_attribute_id: lodash.uniq(_attribute_id),
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
await app.model.good_sku.bulkCreate(skuListData, {
|
|
76
|
+
updateOnDuplicate: skuModelList.map((item) => item.key),
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
ctx.SUCCESS('result')
|
|
80
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
name: '微信公众号用户',
|
|
3
|
+
belongs: 'page',
|
|
4
|
+
multiple: false,
|
|
5
|
+
availableSort: false,
|
|
6
|
+
order: ['created_at'],
|
|
7
|
+
select: [{ key: 'user_id' }, { key: 'nick_name' }, { key: 'openid' }],
|
|
8
|
+
excludes: [],
|
|
9
|
+
limit: 20,
|
|
10
|
+
defaultOrder: [{ sort: 'descending', type: 'id' }],
|
|
11
|
+
comment: {
|
|
12
|
+
created_at: {
|
|
13
|
+
comment: '创建时间',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
sortOrder: 1,
|
|
17
|
+
reference: [],
|
|
18
|
+
excludeAuth: [],
|
|
19
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const { Sequelize, Random } = require('multiple-quick-koa')
|
|
2
|
+
|
|
3
|
+
exports.openid = {
|
|
4
|
+
type: Sequelize.STRING,
|
|
5
|
+
comment: 'openid',
|
|
6
|
+
allowNull: false,
|
|
7
|
+
is_mock: false,
|
|
8
|
+
defaultValue: '',
|
|
9
|
+
sortOrder: 1,
|
|
10
|
+
unique: true,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.user_id = {
|
|
14
|
+
type: Sequelize.MEDIUMINT.UNSIGNED,
|
|
15
|
+
comment: '用户',
|
|
16
|
+
allowNull: false,
|
|
17
|
+
is_mock: false,
|
|
18
|
+
defaultValue: 0,
|
|
19
|
+
sortOrder: 2,
|
|
20
|
+
hasOne: true,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.nick_name = {
|
|
24
|
+
type: Sequelize.STRING,
|
|
25
|
+
comment: '昵称',
|
|
26
|
+
allowNull: false,
|
|
27
|
+
is_mock: false,
|
|
28
|
+
defaultValue: '',
|
|
29
|
+
sortOrder: 3,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.avatar = {
|
|
33
|
+
type: Sequelize.STRING(1000),
|
|
34
|
+
comment: '头像',
|
|
35
|
+
allowNull: false,
|
|
36
|
+
is_mock: false,
|
|
37
|
+
defaultValue: '',
|
|
38
|
+
sortOrder: 8,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.name = {
|
|
42
|
+
type: Sequelize.VIRTUAL,
|
|
43
|
+
comment: '名字',
|
|
44
|
+
allowNull: false,
|
|
45
|
+
is_mock: false,
|
|
46
|
+
defaultValue: '',
|
|
47
|
+
sortOrder: 9,
|
|
48
|
+
get: function () {
|
|
49
|
+
return this.getDataValue('nick_name')
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
exports.appid = {
|
|
54
|
+
type: Sequelize.STRING,
|
|
55
|
+
comment: 'APP_ID',
|
|
56
|
+
allowNull: false,
|
|
57
|
+
is_mock: true,
|
|
58
|
+
defaultValue: '',
|
|
59
|
+
sortOrder: 10,
|
|
60
|
+
mock: () => Random.ctitle(),
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
exports.unionid = {
|
|
64
|
+
type: Sequelize.STRING,
|
|
65
|
+
comment: 'unionid',
|
|
66
|
+
allowNull: false,
|
|
67
|
+
is_mock: true,
|
|
68
|
+
defaultValue: '',
|
|
69
|
+
sortOrder: 11,
|
|
70
|
+
mock: () => Random.ctitle(),
|
|
71
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { Sequelize } = require('multiple-quick-koa');
|
|
2
|
+
|
|
3
|
+
exports.name = {
|
|
4
|
+
type: Sequelize.STRING,
|
|
5
|
+
comment: '名字',
|
|
6
|
+
allowNull: false,
|
|
7
|
+
defaultValue: '',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
exports.key = {
|
|
11
|
+
type: Sequelize.STRING,
|
|
12
|
+
comment: 'key',
|
|
13
|
+
allowNull: false,
|
|
14
|
+
defaultValue: '',
|
|
15
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const { Sequelize } = require('multiple-quick-koa');
|
|
2
|
+
|
|
3
|
+
exports.name = {
|
|
4
|
+
type: Sequelize.STRING,
|
|
5
|
+
comment: '名字',
|
|
6
|
+
allowNull: false,
|
|
7
|
+
defaultValue: '',
|
|
8
|
+
validate: {
|
|
9
|
+
notNull: {
|
|
10
|
+
msg: '名字不允许为空',
|
|
11
|
+
},
|
|
12
|
+
notEmpty: {
|
|
13
|
+
msg: '名字不允许为空',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
exports.lang_id = {
|
|
20
|
+
type: Sequelize.INTEGER(11),
|
|
21
|
+
comment: '语言',
|
|
22
|
+
allowNull: false,
|
|
23
|
+
defaultValue: 1,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.key = {
|
|
27
|
+
type: Sequelize.STRING,
|
|
28
|
+
comment: 'key值',
|
|
29
|
+
allowNull: false,
|
|
30
|
+
defaultValue: '',
|
|
31
|
+
validate: {
|
|
32
|
+
notNull: {
|
|
33
|
+
msg: 'key值不允许为空',
|
|
34
|
+
},
|
|
35
|
+
notEmpty: {
|
|
36
|
+
msg: 'key值不允许为空',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
exports.value = {
|
|
42
|
+
type: Sequelize.STRING,
|
|
43
|
+
comment: 'value值',
|
|
44
|
+
allowNull: false,
|
|
45
|
+
defaultValue: '',
|
|
46
|
+
validate: {
|
|
47
|
+
notNull: {
|
|
48
|
+
msg: 'value值不允许为空',
|
|
49
|
+
},
|
|
50
|
+
notEmpty: {
|
|
51
|
+
msg: 'value值不允许为空',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
name: '错误日志',
|
|
3
|
+
belongs: 'auth',
|
|
4
|
+
multiple: true,
|
|
5
|
+
order: ['created_at'],
|
|
6
|
+
select: ['url'],
|
|
7
|
+
excludes: [],
|
|
8
|
+
defaultOrder: [{ sort: 'descending', type: 'id' }],
|
|
9
|
+
comment: {},
|
|
10
|
+
reference: [
|
|
11
|
+
{
|
|
12
|
+
key: 'log_user',
|
|
13
|
+
common: true,
|
|
14
|
+
name: '查询用户',
|
|
15
|
+
width: 200,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
limit: 50,
|
|
19
|
+
personal: [
|
|
20
|
+
{
|
|
21
|
+
key: 'operate_log',
|
|
22
|
+
common: true,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const { getAppByCtx } = require('multiple-quick-koa')
|
|
2
|
+
|
|
3
|
+
exports.clearWeixin = async (ctx) => {
|
|
4
|
+
const { app } = getAppByCtx(ctx)
|
|
5
|
+
const count = await app.model.log.count()
|
|
6
|
+
const limit = 50000
|
|
7
|
+
const page = count / limit
|
|
8
|
+
let result = []
|
|
9
|
+
for (let i = 0; i < page; i++) {
|
|
10
|
+
const data = await app.model.log.findAll({
|
|
11
|
+
attributes: ['id', 'header', 'url'],
|
|
12
|
+
limit,
|
|
13
|
+
offset: i * limit,
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const list = data.filter(
|
|
17
|
+
(item) =>
|
|
18
|
+
JSON.stringify(item.header).includes('TST(Tencent Security Team)') ||
|
|
19
|
+
['/pages/', 'http'].every((h) => !item.url.startsWith(h)) ||
|
|
20
|
+
[('_', ';')].some((sym) => item.url.startsWith(sym))
|
|
21
|
+
)
|
|
22
|
+
result = [...result, ...list.map((item) => item.id)]
|
|
23
|
+
}
|
|
24
|
+
ctx.SUCCESS(
|
|
25
|
+
result.map((id) => {
|
|
26
|
+
return {
|
|
27
|
+
id,
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const { Sequelize } = require('multiple-quick-koa')
|
|
2
|
+
|
|
3
|
+
exports.url = {
|
|
4
|
+
type: Sequelize.STRING,
|
|
5
|
+
comment: 'url',
|
|
6
|
+
allowNull: false,
|
|
7
|
+
defaultValue: '',
|
|
8
|
+
validate: {
|
|
9
|
+
notNull: {
|
|
10
|
+
msg: 'url不允许为空',
|
|
11
|
+
},
|
|
12
|
+
notEmpty: {
|
|
13
|
+
msg: 'url不允许为空',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
extra: {
|
|
17
|
+
tableWidth: 300,
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.header = {
|
|
22
|
+
type: Sequelize.JSON,
|
|
23
|
+
comment: 'Header',
|
|
24
|
+
allowNull: false,
|
|
25
|
+
defaultValue: {},
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.body = {
|
|
29
|
+
type: Sequelize.JSON,
|
|
30
|
+
comment: '参数',
|
|
31
|
+
allowNull: false,
|
|
32
|
+
defaultValue: {},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.message = {
|
|
36
|
+
type: Sequelize.STRING,
|
|
37
|
+
allowNull: false,
|
|
38
|
+
comment: '错误信息',
|
|
39
|
+
defaultValue: '',
|
|
40
|
+
extra: {
|
|
41
|
+
limit: 50,
|
|
42
|
+
tableWidth: 300,
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exports.content = {
|
|
47
|
+
type: Sequelize.TEXT,
|
|
48
|
+
comment: '错误栈',
|
|
49
|
+
allowNull: false,
|
|
50
|
+
defaultValue: '',
|
|
51
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const { getAppByCtx, lodash } = require('multiple-quick-koa')
|
|
2
|
+
|
|
3
|
+
const fs = require('fs')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
|
|
6
|
+
exports.getModel = async (ctx) => {
|
|
7
|
+
const { app, appName } = getAppByCtx(ctx)
|
|
8
|
+
|
|
9
|
+
const { model, option = 'config' } = ctx.request.body
|
|
10
|
+
|
|
11
|
+
const pluginPath = `${process.cwd()}/app/${appName}/plugins/${model}`
|
|
12
|
+
const existDir = fs.existsSync(path.resolve(__dirname, pluginPath))
|
|
13
|
+
if (!existDir) return ctx.SUCCESS('')
|
|
14
|
+
|
|
15
|
+
const existFile = fs.existsSync(
|
|
16
|
+
path.resolve(
|
|
17
|
+
__dirname,
|
|
18
|
+
`${process.cwd()}/app/${appName}/plugins/${model}/${option}.js`
|
|
19
|
+
)
|
|
20
|
+
)
|
|
21
|
+
if (!existFile) return ctx.SUCCESS('')
|
|
22
|
+
const file = fs.readFileSync(
|
|
23
|
+
path.resolve(
|
|
24
|
+
__dirname,
|
|
25
|
+
`${process.cwd()}/app/${appName}/plugins/${model}/${option}.js`
|
|
26
|
+
),
|
|
27
|
+
'utf-8'
|
|
28
|
+
)
|
|
29
|
+
return ctx.SUCCESS(file)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.loadModel = async (ctx) => {
|
|
33
|
+
const { app, appName } = getAppByCtx(ctx)
|
|
34
|
+
await app.service.model.loadModel({
|
|
35
|
+
app,
|
|
36
|
+
appName,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
ctx.SUCCESS('ok')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports.createFile = async (ctx) => {
|
|
43
|
+
const { app, appName } = getAppByCtx(ctx)
|
|
44
|
+
const { plugin, config, model, controller } = ctx.request.body
|
|
45
|
+
|
|
46
|
+
const obj = {
|
|
47
|
+
config,
|
|
48
|
+
model,
|
|
49
|
+
controller,
|
|
50
|
+
}
|
|
51
|
+
if (!config && !model) throw new Error('至少config和model要有')
|
|
52
|
+
const pluginDirPath = path.resolve(
|
|
53
|
+
__dirname,
|
|
54
|
+
`${process.cwd()}/app/${appName}/plugins/${plugin}`
|
|
55
|
+
)
|
|
56
|
+
const exist = fs.existsSync(pluginDirPath)
|
|
57
|
+
if (!exist) fs.mkdirSync(pluginDirPath)
|
|
58
|
+
const list = ['config', 'model', 'controller']
|
|
59
|
+
|
|
60
|
+
for (let i = 0; i < list.length; i++) {
|
|
61
|
+
const type = list[i]
|
|
62
|
+
if (!obj[type]) {
|
|
63
|
+
continue
|
|
64
|
+
}
|
|
65
|
+
fs.writeFileSync(path.resolve(pluginDirPath, `${type}.js`), obj[type])
|
|
66
|
+
}
|
|
67
|
+
// fs.writeFileSync(path.resolve(pluginDirPath, 'config.js'), desc)
|
|
68
|
+
ctx.SUCCESS('ok')
|
|
69
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
const { Sequelize } = require('multiple-quick-koa')
|
|
2
|
+
|
|
3
|
+
exports.model = {
|
|
4
|
+
type: Sequelize.STRING,
|
|
5
|
+
comment: 'model',
|
|
6
|
+
allowNull: false,
|
|
7
|
+
defaultValue: '',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.name = {
|
|
11
|
+
type: Sequelize.STRING,
|
|
12
|
+
comment: '名字',
|
|
13
|
+
allowNull: false,
|
|
14
|
+
defaultValue: '',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.belongs = {
|
|
18
|
+
type: Sequelize.STRING,
|
|
19
|
+
comment: '分类',
|
|
20
|
+
allowNull: false,
|
|
21
|
+
defaultValue: 'setting',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.order = {
|
|
25
|
+
type: Sequelize.JSON,
|
|
26
|
+
comment: '允许排序',
|
|
27
|
+
allowNull: false,
|
|
28
|
+
defaultValue: [],
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.multiple = {
|
|
32
|
+
type: Sequelize.BOOLEAN,
|
|
33
|
+
comment: '允许多选删除',
|
|
34
|
+
allowNull: false,
|
|
35
|
+
defaultValue: false,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.availableSort = {
|
|
39
|
+
type: Sequelize.BOOLEAN,
|
|
40
|
+
comment: '允许自定义排序',
|
|
41
|
+
allowNull: false,
|
|
42
|
+
defaultValue: false,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.select = {
|
|
46
|
+
type: Sequelize.JSON,
|
|
47
|
+
comment: '筛选',
|
|
48
|
+
allowNull: false,
|
|
49
|
+
defaultValue: [],
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
exports.excludes = {
|
|
53
|
+
type: Sequelize.JSON,
|
|
54
|
+
comment: '忽略字段',
|
|
55
|
+
allowNull: false,
|
|
56
|
+
defaultValue: [],
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
exports.reference = {
|
|
60
|
+
type: Sequelize.JSON,
|
|
61
|
+
comment: '自定义组件',
|
|
62
|
+
allowNull: false,
|
|
63
|
+
defaultValue: [],
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
exports.include = {
|
|
67
|
+
type: Sequelize.TEXT,
|
|
68
|
+
comment: '关联表',
|
|
69
|
+
allowNull: false,
|
|
70
|
+
defaultValue: '',
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
exports.comment = {
|
|
74
|
+
type: Sequelize.JSON,
|
|
75
|
+
comment: '自定义名字',
|
|
76
|
+
allowNull: false,
|
|
77
|
+
defaultValue: {},
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
exports.defaultOrder = {
|
|
81
|
+
type: Sequelize.JSON,
|
|
82
|
+
comment: '默认排序',
|
|
83
|
+
allowNull: false,
|
|
84
|
+
defaultValue: [],
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
exports.sortOrder = {
|
|
88
|
+
type: Sequelize.INTEGER,
|
|
89
|
+
comment: '菜单排序',
|
|
90
|
+
allowNull: false,
|
|
91
|
+
defaultValue: 1,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
exports.personal = {
|
|
95
|
+
type: Sequelize.JSON,
|
|
96
|
+
comment: '自定义按钮',
|
|
97
|
+
allowNull: false,
|
|
98
|
+
defaultValue: {},
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
exports.limit = {
|
|
102
|
+
type: Sequelize.INTEGER,
|
|
103
|
+
comment: '每页数量',
|
|
104
|
+
allowNull: false,
|
|
105
|
+
defaultValue: 20,
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
exports.excludeAuth = {
|
|
109
|
+
type: Sequelize.JSON,
|
|
110
|
+
comment: '权限',
|
|
111
|
+
allowNull: false,
|
|
112
|
+
defaultValue: [],
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
exports.initList = {
|
|
116
|
+
type: Sequelize.JSON,
|
|
117
|
+
comment: '初始化model',
|
|
118
|
+
allowNull: false,
|
|
119
|
+
defaultValue: [],
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
exports.autoData = {
|
|
123
|
+
type: Sequelize.JSON,
|
|
124
|
+
comment: 'initData过滤数据',
|
|
125
|
+
allowNull: false,
|
|
126
|
+
defaultValue: {},
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
exports.is_split = {
|
|
130
|
+
type: Sequelize.BOOLEAN,
|
|
131
|
+
comment: '允许拆分sql',
|
|
132
|
+
allowNull: false,
|
|
133
|
+
defaultValue: false,
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
exports.show_virtual = {
|
|
137
|
+
type: Sequelize.BOOLEAN,
|
|
138
|
+
comment: '显示虚拟字段',
|
|
139
|
+
allowNull: false,
|
|
140
|
+
defaultValue: false,
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
exports.is_split_count = {
|
|
144
|
+
type: Sequelize.BOOLEAN,
|
|
145
|
+
comment: '拆分count',
|
|
146
|
+
allowNull: false,
|
|
147
|
+
defaultValue: false,
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
exports.modelQuery = {
|
|
151
|
+
type: Sequelize.JSON,
|
|
152
|
+
comment: '默认查询过滤',
|
|
153
|
+
allowNull: false,
|
|
154
|
+
defaultValue: {},
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
exports.editInline = {
|
|
158
|
+
type: Sequelize.JSON,
|
|
159
|
+
comment: '局部更新',
|
|
160
|
+
allowNull: false,
|
|
161
|
+
defaultValue: {},
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
exports.deleteCheckList = {
|
|
165
|
+
type: Sequelize.JSON,
|
|
166
|
+
comment: '删除检测',
|
|
167
|
+
allowNull: false,
|
|
168
|
+
defaultValue: [],
|
|
169
|
+
}
|