mm_os 3.3.0 → 4.0.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.
- package/LICENSE +21 -201
- package/README.md +491 -99
- package/README_EN.md +498 -0
- package/adapter/adapter.js +431 -0
- package/adapter/custom_persistence.js +660 -0
- package/adapter/mqtt.js +273 -0
- package/adapter/socket.js +113 -0
- package/adapter/web.js +67 -0
- package/adapter/websocket.js +146 -0
- package/com/api/com.json +5 -0
- package/{core/com → com}/api/config.tpl.json +8 -8
- package/com/api/drive.js +708 -0
- package/com/api/index.js +198 -0
- package/com/api/oauth.js +200 -0
- package/com/api/script.tpl.js +32 -0
- package/com/cmd/README.md +11 -0
- package/com/cmd/com.json +5 -0
- package/com/cmd/config.tpl.json +122 -0
- package/com/cmd/drive.js +1548 -0
- package/com/cmd/index.js +1066 -0
- package/com/cmd/msg.json +48 -0
- package/com/cmd/nlp.js +525 -0
- package/com/cmd/script.tpl.js +32 -0
- package/com/db/com.json +5 -0
- package/com/db/drive.js +1999 -0
- package/com/db/index.js +242 -0
- package/com/event/com.json +5 -0
- package/{core/com → com}/event/config.tpl.json +8 -8
- package/com/event/drive.js +59 -0
- package/com/event/index.js +409 -0
- package/com/event/script.tpl.js +23 -0
- package/com/mqtt/com.json +5 -0
- package/{core/com → com}/mqtt/config.tpl.json +3 -5
- package/com/mqtt/drive.js +676 -0
- package/com/mqtt/index.js +822 -0
- package/com/mqtt/mm_mqtt.js +425 -0
- package/com/mqtt/script.tpl.js +723 -0
- package/com/nav/com.json +5 -0
- package/com/nav/config.tpl.json +84 -0
- package/com/nav/drive.js +702 -0
- package/com/nav/index.js +231 -0
- package/{core/com → com}/nav/tpl/admin_pc/page_config.vue +280 -280
- package/{core/com → com}/nav/tpl/admin_pc/page_config_form.vue +194 -194
- package/com/nav/tpl/admin_pc/page_form.vue +180 -0
- package/com/nav/tpl/admin_pc/page_view.vue +124 -0
- package/com/nav/tpl/dev_pc/page_default.vue +247 -0
- package/com/nav/tpl/dev_pc/page_type.vue +313 -0
- package/com/nav/tpl/home_pc/page_default.vue +234 -0
- package/com/nav/tpl/home_pc/page_form.vue +137 -0
- package/com/nav/tpl/home_pc/page_list.vue +234 -0
- package/com/nav/tpl/home_pc/page_nav.vue +221 -0
- package/com/nav/tpl/home_pc/page_type.vue +234 -0
- package/com/nav/tpl/home_pc/page_view.vue +125 -0
- package/com/nav/tpl/home_phone/page_channel.vue +234 -0
- package/com/nav/tpl/home_phone/page_default.vue +234 -0
- package/com/nav/tpl/home_phone/page_form.vue +137 -0
- package/com/nav/tpl/home_phone/page_nav.vue +237 -0
- package/com/nav/tpl/home_phone/page_type.vue +234 -0
- package/com/nav/tpl/home_phone/page_view.vue +125 -0
- package/com/nav/viewmodel.js +446 -0
- package/com/param/com.json +5 -0
- package/{core/com → com}/param/config.tpl.json +7 -1
- package/com/param/drive.js +502 -0
- package/com/param/index.js +155 -0
- package/com/param/script.tpl.js +12 -0
- package/com/pendant/com.json +5 -0
- package/{core/com/component → com/pendant}/config.tpl.json +15 -13
- package/com/pendant/drive.js +204 -0
- package/com/pendant/index.js +441 -0
- package/com/pendant/pendant.html +16 -0
- package/com/pendant/script.tpl.js +18 -0
- package/com/socket/com.json +5 -0
- package/com/socket/config.tpl.json +12 -0
- package/com/socket/drive.js +651 -0
- package/com/socket/index.js +351 -0
- package/com/socket/script.tpl.js +41 -0
- package/com/sql/com.json +5 -0
- package/{core/com → com}/sql/config.tpl.json +13 -9
- package/com/sql/drive.js +1259 -0
- package/com/sql/index.js +150 -0
- package/com/sql/script.tpl.js +47 -0
- package/com/static/com.json +5 -0
- package/{core/com → com}/static/config.tpl.json +10 -6
- package/com/static/drive.js +194 -0
- package/com/static/index.js +226 -0
- package/com/static/script.tpl.js +28 -0
- package/com/task/com.json +5 -0
- package/{core/com → com}/task/config.tpl.json +4 -6
- package/com/task/drive.js +405 -0
- package/com/task/index.js +148 -0
- package/com/task/script.tpl.js +37 -0
- package/com/template/com.json +5 -0
- package/com/template/config.tpl.json +16 -0
- package/com/template/drive.js +80 -0
- package/com/template/index.js +141 -0
- package/com.js +156 -0
- package/common/README.md +2 -0
- package/common/handler/msg/handler.json +22 -0
- package/common/handler/msg/index.js +23 -0
- package/common/handler/player/handler.json +22 -0
- package/common/handler/player/index.js +287 -0
- package/common/handler/user/handler.json +22 -0
- package/common/handler/user/index.js +23 -0
- package/common/middleware/web_after/index.js +29 -0
- package/common/middleware/web_after/middleware.json +9 -0
- package/common/middleware/web_base/index.js +113 -0
- package/common/middleware/web_base/middleware.json +19 -0
- package/common/middleware/web_before/index.js +33 -0
- package/common/middleware/web_before/middleware.json +9 -0
- package/common/middleware/web_cors/index.js +87 -0
- package/common/middleware/web_cors/middleware.json +24 -0
- package/common/middleware/web_error/index.js +119 -0
- package/common/middleware/web_error/middleware.json +18 -0
- package/common/middleware/web_ip/index.js +15 -0
- package/common/middleware/web_ip/middleware.json +14 -0
- package/common/middleware/web_logger/index.js +156 -0
- package/common/middleware/web_logger/middleware.json +14 -0
- package/common/middleware/web_main/index.js +24 -0
- package/common/middleware/web_main/middleware.json +9 -0
- package/common/middleware/web_static/index.js +73 -0
- package/common/middleware/web_static/middleware.json +54 -0
- package/common/middleware/web_waf/index.js +385 -0
- package/common/middleware/web_waf/middleware.json +13 -0
- package/common/model/msg/index.js +88 -0
- package/common/model/msg/model.json +401 -0
- package/common/model/player/index.js +63 -0
- package/common/model/player/model.json +185 -0
- package/common/model/user/index.js +11 -0
- package/common/model/user/model.json +219 -0
- package/core/app/config.tpl.json +67 -0
- package/core/app/index.js +632 -0
- package/core/app/script.tpl.js +52 -0
- package/core/channel/index.js +899 -0
- package/core/channel/matcher.js +585 -0
- package/core/com/config.tpl.json +16 -0
- package/core/com/index.js +74 -0
- package/core/com/script.tpl.js +5 -0
- package/core/component/component.js +42 -0
- package/core/component/config.tpl.json +63 -0
- package/core/component/index.js +273 -0
- package/core/component/script.tpl.js +19 -0
- package/core/controller/config.tpl.json +14 -0
- package/core/controller/index.js +373 -0
- package/core/controller/script.tpl.js +27 -0
- package/core/factory/config.tpl.json +14 -0
- package/core/factory/entity.js +275 -0
- package/core/factory/index.js +241 -0
- package/core/factory/script.tpl.js +16 -0
- package/core/game/bat/index.js +137 -0
- package/core/game/bat/world.js +622 -0
- package/core/game/config.tpl.json +16 -0
- package/core/game/entity_admin.js +230 -0
- package/core/game/index.js +186 -0
- package/core/handler/config.tpl.json +22 -0
- package/core/handler/index.js +181 -0
- package/core/handler/script.tpl.js +23 -0
- package/core/logic/config.tpl.json +14 -0
- package/core/logic/index.js +59 -0
- package/core/logic/script.tpl.js +19 -0
- package/core/middleware/config.tpl.json +16 -0
- package/core/middleware/index.js +125 -0
- package/core/middleware/script.tpl.js +37 -0
- package/core/mod/config.tpl.json +22 -0
- package/core/mod/index.js +130 -0
- package/core/mod/script.tpl.js +34 -0
- package/core/model/config.tpl.json +219 -0
- package/core/model/index.js +272 -0
- package/core/model/model.js +27 -0
- package/core/model/script.tpl.js +20 -0
- package/core/notifier/config.tpl.json +14 -0
- package/core/notifier/index.js +77 -0
- package/core/notifier/script.tpl.js +20 -0
- package/core/plugin/config.tpl.json +24 -0
- package/core/plugin/index.js +232 -0
- package/core/plugin/script.tpl.js +51 -0
- package/core/pusher/config.tpl.json +14 -0
- package/core/pusher/index.js +161 -0
- package/core/pusher/script.tpl.js +20 -0
- package/core/room/bat/index.js +170 -0
- package/core/room/bat/room.js +524 -0
- package/core/room/config.tpl.json +20 -0
- package/core/room/index.js +249 -0
- package/core/room/room.js +61 -0
- package/core/scene/config.tpl.json +14 -0
- package/core/scene/index.js +466 -0
- package/core/scene/loop.js +1255 -0
- package/core/scene/map.js +28 -0
- package/core/scene/script.tpl.js +22 -0
- package/core/sender/config.tpl.json +14 -0
- package/core/sender/index.js +79 -0
- package/core/sender/script.tpl.js +20 -0
- package/core/service/config.tpl.json +14 -0
- package/core/service/index.js +100 -0
- package/core/service/script.tpl.js +25 -0
- package/core/store/config.tpl.json +26 -0
- package/core/store/index.js +1755 -0
- package/core/store/script.tpl.js +22 -0
- package/core/store/sql.js +1464 -0
- package/core/system/config.tpl.json +18 -0
- package/core/system/index.js +312 -0
- package/core/system/script.tpl.js +77 -0
- package/core/view/config.tpl.json +14 -0
- package/core/view/index.js +91 -0
- package/core/view/script.tpl.js +20 -0
- package/core/zone/bat/index.js +725 -0
- package/core/zone/config.tpl.json +54 -0
- package/core/zone/index.js +614 -0
- package/core/zone/script.tpl.js +10 -0
- package/core/zone/zone_bat.js +136 -0
- package/core//345/237/272/347/261/273/346/250/241/345/235/227/346/270/205/345/215/225.md +24 -0
- package/index.js +17 -314
- package/os.js +57 -0
- package/package.json +60 -58
- package/server.js +598 -0
- package/README.en.md +0 -36
- package/conf.json +0 -3
- package/core/base/mqtt/index.js +0 -1107
- package/core/base/mqtt/lib.js +0 -40
- package/core/base/web/index.js +0 -243
- package/core/com/api/com.json +0 -4
- package/core/com/api/drive.js +0 -668
- package/core/com/api/index.js +0 -108
- package/core/com/api/oauth.js +0 -158
- package/core/com/api/script.js +0 -32
- package/core/com/app/README.md +0 -3
- package/core/com/app/com.json +0 -4
- package/core/com/app/config.tpl.json +0 -16
- package/core/com/app/drive.js +0 -309
- package/core/com/app/index.js +0 -211
- package/core/com/app/script.js +0 -155
- package/core/com/cmd/com.json +0 -4
- package/core/com/cmd/config.tpl.json +0 -66
- package/core/com/cmd/drive.js +0 -513
- package/core/com/cmd/index.js +0 -354
- package/core/com/cmd/old/5w2h.js +0 -54
- package/core/com/cmd/old/drive.js +0 -423
- package/core/com/cmd/script.js +0 -11
- package/core/com/component/README.md +0 -3
- package/core/com/component/com.json +0 -4
- package/core/com/component/component.html +0 -16
- package/core/com/component/drive.js +0 -197
- package/core/com/component/index.js +0 -312
- package/core/com/component/script.js +0 -18
- package/core/com/db/com.json +0 -4
- package/core/com/db/drive.js +0 -1160
- package/core/com/db/index.js +0 -176
- package/core/com/event/com.json +0 -4
- package/core/com/event/drive.js +0 -133
- package/core/com/event/index.js +0 -345
- package/core/com/event/script.js +0 -26
- package/core/com/eventer/com.js +0 -477
- package/core/com/eventer/com.json +0 -4
- package/core/com/middleware/com.js +0 -153
- package/core/com/middleware/com.json +0 -4
- package/core/com/middleware/config.tpl.json +0 -8
- package/core/com/middleware/script.js +0 -9
- package/core/com/mqtt/com.json +0 -4
- package/core/com/mqtt/drive.js +0 -600
- package/core/com/mqtt/index.js +0 -572
- package/core/com/mqtt/mm_mqtt.js +0 -330
- package/core/com/mqtt/script.js +0 -604
- package/core/com/msg/com.js +0 -296
- package/core/com/msg/com.json +0 -4
- package/core/com/nav/com.json +0 -4
- package/core/com/nav/config.tpl.json +0 -75
- package/core/com/nav/drive.js +0 -549
- package/core/com/nav/index.js +0 -182
- package/core/com/nav/tpl/admin_pc/page_form.vue +0 -180
- package/core/com/nav/tpl/admin_pc/page_view.vue +0 -124
- package/core/com/nav/tpl/dev_pc/page_default.vue +0 -247
- package/core/com/nav/tpl/dev_pc/page_type.vue +0 -313
- package/core/com/nav/tpl/home_pc/page_default.vue +0 -234
- package/core/com/nav/tpl/home_pc/page_form.vue +0 -137
- package/core/com/nav/tpl/home_pc/page_list.vue +0 -234
- package/core/com/nav/tpl/home_pc/page_nav.vue +0 -221
- package/core/com/nav/tpl/home_pc/page_type.vue +0 -234
- package/core/com/nav/tpl/home_pc/page_view.vue +0 -125
- package/core/com/nav/tpl/home_phone/page_channel.vue +0 -234
- package/core/com/nav/tpl/home_phone/page_default.vue +0 -234
- package/core/com/nav/tpl/home_phone/page_form.vue +0 -137
- package/core/com/nav/tpl/home_phone/page_nav.vue +0 -237
- package/core/com/nav/tpl/home_phone/page_type.vue +0 -234
- package/core/com/nav/tpl/home_phone/page_view.vue +0 -125
- package/core/com/nav/viewmodel.js +0 -296
- package/core/com/param/drive.js +0 -366
- package/core/com/param/index.js +0 -80
- package/core/com/param/script.js +0 -12
- package/core/com/param/test.js +0 -98
- package/core/com/plugin/README.md +0 -3
- package/core/com/plugin/com.json +0 -4
- package/core/com/plugin/config.tpl.json +0 -26
- package/core/com/plugin/drive.js +0 -536
- package/core/com/plugin/index.js +0 -259
- package/core/com/plugin/script.js +0 -213
- package/core/com/rpc/com.json +0 -4
- package/core/com/rpc/drive.js +0 -160
- package/core/com/rpc/index.js +0 -87
- package/core/com/rpc/rpc.js +0 -118
- package/core/com/socket/com.json +0 -4
- package/core/com/socket/config.tpl.json +0 -14
- package/core/com/socket/drive.js +0 -403
- package/core/com/socket/index.js +0 -62
- package/core/com/socket/script.js +0 -42
- package/core/com/sql/drive.js +0 -1087
- package/core/com/sql/index.js +0 -83
- package/core/com/sql/script.js +0 -48
- package/core/com/static/com.json +0 -4
- package/core/com/static/drive.js +0 -220
- package/core/com/static/index.js +0 -149
- package/core/com/static/script.js +0 -28
- package/core/com/task/com.json +0 -4
- package/core/com/task/drive.js +0 -403
- package/core/com/task/index.js +0 -110
- package/core/com/task/script.js +0 -37
- package/core/com/timer/com.js +0 -217
- package/core/com/timer/com.json +0 -4
- package/core/com/tpl/com.js +0 -19
- package/core/com/tpl/com.json +0 -4
- package/lib/actions.js +0 -50
- package/lib/base.js +0 -361
- package/lib/com.js +0 -29
- package/lib/ref.js +0 -121
- package/middleware/mqtt_base/index.js +0 -10
- package/middleware/mqtt_base/middleware.json +0 -10
- package/middleware/performance/index.js +0 -151
- package/middleware/performance/middleware.json +0 -16
- package/middleware/security_audit/index.js +0 -549
- package/middleware/security_audit/middleware.json +0 -48
- package/middleware/security_headers/index.js +0 -487
- package/middleware/security_headers/middleware.json +0 -45
- package/middleware/waf/index.js +0 -348
- package/middleware/waf/middleware.json +0 -10
- package/middleware/waf_ddos/index.js +0 -520
- package/middleware/waf_ddos/middleware.json +0 -38
- package/middleware/waf_ip/index.js +0 -379
- package/middleware/waf_ip/middleware.json +0 -49
- package/middleware/waf_xss/index.js +0 -269
- package/middleware/waf_xss/middleware.json +0 -18
- package/middleware/web_after/index.js +0 -33
- package/middleware/web_after/middleware.json +0 -9
- package/middleware/web_base/index.js +0 -90
- package/middleware/web_base/middleware.json +0 -9
- package/middleware/web_before/index.js +0 -27
- package/middleware/web_before/middleware.json +0 -9
- package/middleware/web_check/index.js +0 -28
- package/middleware/web_check/middleware.json +0 -9
- package/middleware/web_main/index.js +0 -28
- package/middleware/web_main/middleware.json +0 -9
- package/middleware/web_proxy/index.js +0 -37
- package/middleware/web_proxy/middleware.json +0 -9
- package/middleware/web_render/index.js +0 -87
- package/middleware/web_render/middleware.json +0 -9
- package/middleware/web_socket/index.js +0 -34
- package/middleware/web_socket/middleware.json +0 -9
- package/middleware/web_static/index.js +0 -115
- package/middleware/web_static/middleware.json +0 -9
- /package/{core/com → com}/api/README.md +0 -0
- /package/{core/com → com}/db/README.md +0 -0
- /package/{core/com → com}/event/README.md +0 -0
- /package/{core/com → com}/mqtt/README.md +0 -0
- /package/{core/com → com}/nav/README.md +0 -0
- /package/{core/com → com}/nav/tpl/admin_pc/page_channel.vue +0 -0
- /package/{core/com → com}/nav/tpl/admin_pc/page_default.vue +0 -0
- /package/{core/com → com}/nav/tpl/admin_pc/page_lang.vue +0 -0
- /package/{core/com → com}/nav/tpl/admin_pc/page_nav.vue +0 -0
- /package/{core/com → com}/nav/tpl/admin_pc/page_table.vue +0 -0
- /package/{core/com → com}/nav/tpl/admin_pc/page_type.vue +0 -0
- /package/{core/com → com}/nav/tpl/dev_pc/page_channel.vue +0 -0
- /package/{core/com → com}/nav/tpl/dev_pc/page_config.vue +0 -0
- /package/{core/com → com}/nav/tpl/dev_pc/page_form.vue +0 -0
- /package/{core/com → com}/nav/tpl/dev_pc/page_nav.vue +0 -0
- /package/{core/com → com}/nav/tpl/dev_pc/page_table.vue +0 -0
- /package/{core/com → com}/nav/tpl/home_pc/page_channel.vue +0 -0
- /package/{core/com → com}/nav/tpl/home_phone/page_list.vue +0 -0
- /package/{core/com → com}/param/README.md +0 -0
- /package/{core/com/cmd → com/pendant}/README.md +0 -0
- /package/{core/com → com}/socket/README.md +0 -0
- /package/{core/com → com}/sql/README.md +0 -0
- /package/{core/com → com}/static/README.md +0 -0
- /package/{core/com → com}/task/README.md +0 -0
package/core/com/db/drive.js
DELETED
|
@@ -1,1160 +0,0 @@
|
|
|
1
|
-
const Item = require('mm_machine').Item;
|
|
2
|
-
const fs = require("fs");
|
|
3
|
-
|
|
4
|
-
if (!$.dict.user_id) {
|
|
5
|
-
$.dict.user_id = "user_id";
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
var keyword_default =
|
|
9
|
-
"`user_id` in (SELECT `user_id` FROM `user_account` WHERE `nickname` LIKE '%{0}%' OR `phone` LIKE '%{0}%' OR `wallet_address` LIKE '%{0}%')";
|
|
10
|
-
|
|
11
|
-
var keyword_default_tip = "昵称、手机号、钱包地址";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* db数据库开发驱动类
|
|
15
|
-
* @extends {Item}
|
|
16
|
-
* @class
|
|
17
|
-
*/
|
|
18
|
-
class Drive extends Item {
|
|
19
|
-
/**
|
|
20
|
-
* 构造函数
|
|
21
|
-
* @param {String} dir 当前目录
|
|
22
|
-
* @constructor
|
|
23
|
-
*/
|
|
24
|
-
constructor(dir) {
|
|
25
|
-
super(dir, __dirname);
|
|
26
|
-
this.default_file = "./db.json";
|
|
27
|
-
|
|
28
|
-
this.query_string = ["name", "title", "keywords", "tag", "description", "content"];
|
|
29
|
-
|
|
30
|
-
// 是否设置数值类型为可查询
|
|
31
|
-
this.query_number = ["state", "uin"];
|
|
32
|
-
|
|
33
|
-
// 是否设置数值类型为关键词可查
|
|
34
|
-
this.query_keyword = ["name", "title", "keywords", "tag", "description"];
|
|
35
|
-
|
|
36
|
-
// 是否设置以下字段为get查列表SQL时不可见
|
|
37
|
-
this.get_not = ['password', 'salt', 'content'];
|
|
38
|
-
|
|
39
|
-
// 是否设置以下字段为getObj查对象SQL时不可见
|
|
40
|
-
this.getObj_not = ['password', 'salt', 'display'];
|
|
41
|
-
|
|
42
|
-
// 是否设置默认该表仅用户可访问
|
|
43
|
-
this.query_default_table = ['user'];
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* 配置参数
|
|
47
|
-
*/
|
|
48
|
-
this.config = {
|
|
49
|
-
// 名称, 由中英文和下“_”组成, 用于修改或卸载 例如: demo
|
|
50
|
-
"name": "",
|
|
51
|
-
// 状态 0未启用,1启用
|
|
52
|
-
"state": 1,
|
|
53
|
-
// 标题
|
|
54
|
-
"title": "",
|
|
55
|
-
// 描述
|
|
56
|
-
"description": "",
|
|
57
|
-
// 表名
|
|
58
|
-
"table": "",
|
|
59
|
-
// 主键,用于实体模型
|
|
60
|
-
"key": "",
|
|
61
|
-
// 字段
|
|
62
|
-
"fields": [
|
|
63
|
-
/* */
|
|
64
|
-
],
|
|
65
|
-
"indexes": []
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 创建字段模型
|
|
72
|
-
* @param {Object} obj
|
|
73
|
-
* @property {String} obj.name 字段名称
|
|
74
|
-
* @param {Object} dflt_value 默认值
|
|
75
|
-
* @param {Object} notnull 是否非空
|
|
76
|
-
* @param {Object} type 字段类型
|
|
77
|
-
* @param {Object} pk 是否主键
|
|
78
|
-
* @param {Object} note 字段备注
|
|
79
|
-
*/
|
|
80
|
-
Drive.prototype.model = function(fields) {
|
|
81
|
-
var {
|
|
82
|
-
name,
|
|
83
|
-
dflt_value,
|
|
84
|
-
notnull,
|
|
85
|
-
type,
|
|
86
|
-
pk,
|
|
87
|
-
note,
|
|
88
|
-
auto
|
|
89
|
-
} = fields;
|
|
90
|
-
|
|
91
|
-
var tp = type.left("(", true);
|
|
92
|
-
var len = type.between("(", ")");
|
|
93
|
-
var min_length = 0;
|
|
94
|
-
var max_length = 0;
|
|
95
|
-
var decimal = 0;
|
|
96
|
-
if (len) {
|
|
97
|
-
max_length = Number(len.left(",", true));
|
|
98
|
-
var d = len.right(",");
|
|
99
|
-
if (d) {
|
|
100
|
-
decimal = Number(d);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
var min = 0;
|
|
104
|
-
var max = 0;
|
|
105
|
-
|
|
106
|
-
var note = note.replace(":", ":").replace('(', '(').replace(')', ')');
|
|
107
|
-
var title = note.left(":", true).trim();
|
|
108
|
-
var desc = note.right(":");
|
|
109
|
-
var description = "";
|
|
110
|
-
var map = "";
|
|
111
|
-
if (desc) {
|
|
112
|
-
// 获取主要注释
|
|
113
|
-
description = desc.right(']', true).left('(', true).trim();
|
|
114
|
-
var range = desc.between("[", "]");
|
|
115
|
-
if (range) {
|
|
116
|
-
// 取最小值
|
|
117
|
-
var min_str = range.left(',', true);
|
|
118
|
-
if (min_str) {
|
|
119
|
-
if (tp === 'varchar') {
|
|
120
|
-
min_length = Number(min_str);
|
|
121
|
-
} else {
|
|
122
|
-
min = Number(min_str);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// 取最大值
|
|
126
|
-
var max_str = range.right(',');
|
|
127
|
-
if (max_str) {
|
|
128
|
-
var n = Number(max_str);
|
|
129
|
-
if (tp === 'varchar') {
|
|
130
|
-
if (n < max_length) {
|
|
131
|
-
max_length = n;
|
|
132
|
-
}
|
|
133
|
-
} else {
|
|
134
|
-
max = n;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
map = desc.between("(", ")");
|
|
139
|
-
}
|
|
140
|
-
if (name.indexOf('_id') !== -1 || name == 'id') {
|
|
141
|
-
min = 0;
|
|
142
|
-
}
|
|
143
|
-
if (max === 0) {
|
|
144
|
-
switch (tp) {
|
|
145
|
-
case "tinyint":
|
|
146
|
-
max = 1;
|
|
147
|
-
break;
|
|
148
|
-
case "smallint":
|
|
149
|
-
max = 32767;
|
|
150
|
-
break;
|
|
151
|
-
case "mediumint":
|
|
152
|
-
max = 8388607;
|
|
153
|
-
break;
|
|
154
|
-
case "int":
|
|
155
|
-
max = 2147483647;
|
|
156
|
-
break;
|
|
157
|
-
case "bigint":
|
|
158
|
-
max = 0;
|
|
159
|
-
break;
|
|
160
|
-
default:
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
if (max_length) {
|
|
164
|
-
var num = Math.pow(10, max_length) - 1;
|
|
165
|
-
if (max > num) {
|
|
166
|
-
max = num;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
var not_null = notnull | pk | (tp !== 'varchar' && tp !== 'text')
|
|
172
|
-
if (not_null && !dflt_value) {
|
|
173
|
-
if (tp === 'varchar' || tp === 'text') {
|
|
174
|
-
dflt_value = "";
|
|
175
|
-
} else {
|
|
176
|
-
dflt_value = "0";
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
var config = this.config;
|
|
180
|
-
if (pk && !config.key) {
|
|
181
|
-
config.key = name;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return {
|
|
185
|
-
// 字段名
|
|
186
|
-
"name": name,
|
|
187
|
-
// 字段标题
|
|
188
|
-
"title": title,
|
|
189
|
-
// 字段描述
|
|
190
|
-
"description": description,
|
|
191
|
-
// 字段类型 smallint短整数、mediumint中长整数、int整数、float浮点数、double双精度、tinyint二进制(0和1的布尔)、text文本、varchar字符串、datetime日期时间、date日期、time时间、timestamp时间戳
|
|
192
|
-
"type": tp,
|
|
193
|
-
// 是否主键
|
|
194
|
-
"key": pk,
|
|
195
|
-
// 自动
|
|
196
|
-
"auto": auto,
|
|
197
|
-
// 是否含符号
|
|
198
|
-
"symbol": tp === "float" || tp === "decimal",
|
|
199
|
-
// 是否填充零,用于数字类型
|
|
200
|
-
"fill_zero": false,
|
|
201
|
-
// 非空
|
|
202
|
-
"not_null": not_null,
|
|
203
|
-
// 最小长度
|
|
204
|
-
"min_length": min_length,
|
|
205
|
-
// 最大长度
|
|
206
|
-
"max_length": max_length,
|
|
207
|
-
// 最小值
|
|
208
|
-
"min": min,
|
|
209
|
-
// 最大值
|
|
210
|
-
"max": max,
|
|
211
|
-
// 小数位
|
|
212
|
-
"decimal": decimal,
|
|
213
|
-
// 默认值
|
|
214
|
-
"default": dflt_value,
|
|
215
|
-
// 转换编排
|
|
216
|
-
"map": map
|
|
217
|
-
};
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* 创建索引字段模型
|
|
222
|
-
* @param {Object} o
|
|
223
|
-
* @return {Object} 返回索引模型
|
|
224
|
-
*/
|
|
225
|
-
Drive.prototype.model_index = function(o) {
|
|
226
|
-
return {
|
|
227
|
-
"name": o.Key_name,
|
|
228
|
-
"type": o.Non_unique ? "unique" : "index",
|
|
229
|
-
"fields": o.Column_name.replace(/`/g, '').split(","),
|
|
230
|
-
"comment": o.Index_comment
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* 从数据库更新索引配置
|
|
236
|
-
* @param {Object} db 数据库管理器
|
|
237
|
-
* @return {Array} 索引列表
|
|
238
|
-
*/
|
|
239
|
-
Drive.prototype.update_file_index = function(db) {
|
|
240
|
-
var sql = "SHOW INDEX FROM `" + this.config.table + "`";
|
|
241
|
-
var rows = db.run(sql);
|
|
242
|
-
var dict = {};
|
|
243
|
-
for (var i = 0; i < rows.length; i++) {
|
|
244
|
-
var o = rows[i];
|
|
245
|
-
if (o.Key_name !== 'PRIMARY') {
|
|
246
|
-
if (!dict[o.Key_name]) {
|
|
247
|
-
dict[o.Key_name] = {
|
|
248
|
-
Column_name: []
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
dict[o.Key_name].Column_name.push(o.Column_name);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
var list = [];
|
|
255
|
-
for (var k in dict) {
|
|
256
|
-
var m = this.model_index(dict[k]);
|
|
257
|
-
list.push(m);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
return list;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* 从数据库更新配置
|
|
265
|
-
* @param {Object} db 数据库管理器
|
|
266
|
-
* @param {Boolean} cover 是否覆盖文件
|
|
267
|
-
*/
|
|
268
|
-
Drive.prototype.update_file = async function(db, cover) {
|
|
269
|
-
var cg = this.config;
|
|
270
|
-
var list = [];
|
|
271
|
-
|
|
272
|
-
// 查询表注释并修改
|
|
273
|
-
var sql = "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '" + db
|
|
274
|
-
.database() +
|
|
275
|
-
"' && TABLE_NAME = '" + cg.table + "';";
|
|
276
|
-
|
|
277
|
-
var lt = await db.run(sql);
|
|
278
|
-
if (lt && lt.length > 0) {
|
|
279
|
-
var commit = lt[0].TABLE_COMMENT;
|
|
280
|
-
var arr = commit.replace(':', ':').split(':');
|
|
281
|
-
cg.title = arr[0];
|
|
282
|
-
if (arr.length > 1) {
|
|
283
|
-
cg.description = arr[1];
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// 设置表名
|
|
288
|
-
db.table = cg.table + "";
|
|
289
|
-
|
|
290
|
-
// 获取所有字段
|
|
291
|
-
var fields = await db.fields();
|
|
292
|
-
for (var i = 0; i < fields.length; i++) {
|
|
293
|
-
var field = this.model(fields[i]);
|
|
294
|
-
list.push(field);
|
|
295
|
-
}
|
|
296
|
-
cg.fields = list;
|
|
297
|
-
cg.index = await this.update_file_index(db);
|
|
298
|
-
if (!cg.name) {
|
|
299
|
-
cg.name = cg.table;
|
|
300
|
-
}
|
|
301
|
-
await this.update_app(cover);
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* @param {Object} db
|
|
306
|
-
*/
|
|
307
|
-
Drive.prototype.update_db_index = async function(db) {
|
|
308
|
-
var cg = this.config;
|
|
309
|
-
var indexes = cg.indexes;
|
|
310
|
-
// 更新索引
|
|
311
|
-
if (indexes) {
|
|
312
|
-
var len = indexes.length;
|
|
313
|
-
for (var i = 0; i < len; i++) {
|
|
314
|
-
var o = indexes[i];
|
|
315
|
-
var sql_start = "";
|
|
316
|
-
if (o.type === "unique") {
|
|
317
|
-
sql_start = "CREATE UNIQUE INDEX `"
|
|
318
|
-
} else {
|
|
319
|
-
sql_start = "CREATE INDEX `";
|
|
320
|
-
}
|
|
321
|
-
await db.exec(sql_start + o.name + "` ON `" + table + "` (" + o.fields + ");");
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* 通过配置更新数据库
|
|
328
|
-
* @param {Object} db 数据库管理器
|
|
329
|
-
* @return {String} 更新成功返回空,否则返回错误提示
|
|
330
|
-
*/
|
|
331
|
-
Drive.prototype.update_db = async function(db) {
|
|
332
|
-
var cg = this.config;
|
|
333
|
-
db.table = cg.table + "";
|
|
334
|
-
var fields = await db.fields();
|
|
335
|
-
var table = cg.table;
|
|
336
|
-
var list = cg.fields;
|
|
337
|
-
if (fields.length === 0) {
|
|
338
|
-
var k = cg.key;
|
|
339
|
-
var len = list.length;
|
|
340
|
-
for (var i = 0; i < len; i++) {
|
|
341
|
-
var o = list[i];
|
|
342
|
-
if (k === o.name) {
|
|
343
|
-
await db.addTable(cg.table, o.name, o.type, o.auto, cg.title + ":" + cg.description);
|
|
344
|
-
fields.push({
|
|
345
|
-
name: o.name
|
|
346
|
-
});
|
|
347
|
-
break;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
} else {
|
|
351
|
-
var commit = cg.title + ":" + cg.description;
|
|
352
|
-
var sql = "alter table `{0}` comment '{1}';".replace('{0}', cg.table).replace('{1}', commit);
|
|
353
|
-
await db.exec(sql);
|
|
354
|
-
}
|
|
355
|
-
if (fields.length > 0) {
|
|
356
|
-
// 删除配置中没有的字段
|
|
357
|
-
for (var i = 0; i < fields.length; i++) {
|
|
358
|
-
var o = fields[i];
|
|
359
|
-
var obj = list.getObj({
|
|
360
|
-
name: o.name
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
if (!obj) {
|
|
364
|
-
await db.field_del(o.name)
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
// 添加或修改配置
|
|
369
|
-
var len = list.length;
|
|
370
|
-
for (var i = 0; i < len; i++) {
|
|
371
|
-
var o = list[i];
|
|
372
|
-
var arr = fields.get({
|
|
373
|
-
name: o.name
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
var notnull = "";
|
|
377
|
-
var type = '';
|
|
378
|
-
var value = "";
|
|
379
|
-
switch (o.type) {
|
|
380
|
-
case "varchar":
|
|
381
|
-
case "longtext":
|
|
382
|
-
case "text":
|
|
383
|
-
if (o.decimal) {
|
|
384
|
-
type = o.type + '(' + o.max_length + ',' + o.decimal + ')';
|
|
385
|
-
} else {
|
|
386
|
-
type = o.type + '(' + o.max_length + ')';
|
|
387
|
-
}
|
|
388
|
-
if (o.not_null) {
|
|
389
|
-
notnull = "NOT NULL";
|
|
390
|
-
}
|
|
391
|
-
if (o.default) {
|
|
392
|
-
value = "DEFAULT '" + o.default+"'";
|
|
393
|
-
} else if (o.default === null) {
|
|
394
|
-
value = "DEFAULT NULL";
|
|
395
|
-
} else {
|
|
396
|
-
value = "DEFAULT ''";
|
|
397
|
-
}
|
|
398
|
-
break;
|
|
399
|
-
case "date":
|
|
400
|
-
case "time":
|
|
401
|
-
case "datetime":
|
|
402
|
-
case "timestamp":
|
|
403
|
-
type = o.type;
|
|
404
|
-
notnull = "NOT NULL";
|
|
405
|
-
if (o.default) {
|
|
406
|
-
if (o.default.indexOf('CURR') !== -1) {
|
|
407
|
-
value = "DEFAULT " + o.default;
|
|
408
|
-
} else {
|
|
409
|
-
value = "DEFAULT '" + o.default+"'";
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
if (o.auto) {
|
|
413
|
-
notnull += '';
|
|
414
|
-
value = "DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP";
|
|
415
|
-
}
|
|
416
|
-
break;
|
|
417
|
-
default:
|
|
418
|
-
// 数字类型
|
|
419
|
-
if (o.decimal) {
|
|
420
|
-
type = o.type + '(' + o.max_length + ',' + o.decimal + ')';
|
|
421
|
-
} else {
|
|
422
|
-
type = o.type + '(' + o.max_length + ')';
|
|
423
|
-
}
|
|
424
|
-
if (!o.symbol) {
|
|
425
|
-
type += " UNSIGNED";
|
|
426
|
-
}
|
|
427
|
-
notnull = "NOT NULL";
|
|
428
|
-
if (o.default) {
|
|
429
|
-
value = "DEFAULT " + o.default;
|
|
430
|
-
} else {
|
|
431
|
-
value = "DEFAULT 0";
|
|
432
|
-
}
|
|
433
|
-
if (o.auto) {
|
|
434
|
-
notnull += ' AUTO_INCREMENT';
|
|
435
|
-
value = "";
|
|
436
|
-
}
|
|
437
|
-
break;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
var note = o.title + ":";
|
|
441
|
-
if (o.type === 'varchar' || o.type === 'text' || o.type === 'longtext') {
|
|
442
|
-
if (o.max_length) {
|
|
443
|
-
note += "[" + o.min_length + "," + o.max_length + "]"
|
|
444
|
-
} else if (o.min_length) {
|
|
445
|
-
note += "[" + o.min_length + "]"
|
|
446
|
-
}
|
|
447
|
-
} else {
|
|
448
|
-
if (o.max) {
|
|
449
|
-
note += "[" + o.min + "," + o.max + "]"
|
|
450
|
-
} else if (o.min) {
|
|
451
|
-
note += "[" + o.min + "]"
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
note += o.description;
|
|
455
|
-
if (o.map) {
|
|
456
|
-
note += '(' + o.map + ')'
|
|
457
|
-
}
|
|
458
|
-
var sql = "`{1}` {2} {3} {4} COMMENT '{5}'";
|
|
459
|
-
sql = sql.replace('{1}', o.name).replace('{2}', type).replace('{3}', notnull).replace('{4}', value)
|
|
460
|
-
.replace('{5}',
|
|
461
|
-
note);
|
|
462
|
-
|
|
463
|
-
if (arr.length === 0) {
|
|
464
|
-
// 如果没有则添加
|
|
465
|
-
await db.exec("alter table `{0}` add ".replace('{0}', table) + sql);
|
|
466
|
-
} else {
|
|
467
|
-
// 如果有则修改
|
|
468
|
-
await db.exec("alter table `{0}` change `{1}` ".replace('{0}', table).replace('{1}', o
|
|
469
|
-
.name) + sql);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
} else {
|
|
473
|
-
return "数据表更新失败";
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* 更新应用,根据表生成目录结构和文件
|
|
479
|
-
* @param {Boolean} cover 是否覆盖文件
|
|
480
|
-
*/
|
|
481
|
-
Drive.prototype.update_app = async function(cover) {
|
|
482
|
-
var cg = this.config;
|
|
483
|
-
var f;
|
|
484
|
-
var dir_api;
|
|
485
|
-
if (!this.filename) {
|
|
486
|
-
var p = "./app/".fullname();
|
|
487
|
-
var dir_arr = cg.table.split('_');
|
|
488
|
-
var scope = dir_arr[0];
|
|
489
|
-
var dir = p + scope;
|
|
490
|
-
if (!fs.existsSync(dir)) {
|
|
491
|
-
fs.mkdirSync(dir);
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
dir += "/plugin";
|
|
495
|
-
if (!fs.existsSync(dir)) {
|
|
496
|
-
fs.mkdirSync(dir);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
dir += "/server";
|
|
500
|
-
if (!fs.existsSync(dir)) {
|
|
501
|
-
fs.mkdirSync(dir);
|
|
502
|
-
}
|
|
503
|
-
dir_api = dir;
|
|
504
|
-
var db_dir = dir + "/db";
|
|
505
|
-
if (!fs.existsSync(db_dir)) {
|
|
506
|
-
fs.mkdirSync(db_dir);
|
|
507
|
-
}
|
|
508
|
-
this.dir = db_dir.fullname();
|
|
509
|
-
|
|
510
|
-
f = this.dir + cg.table.replace(scope + '_', '') + '.db.json';
|
|
511
|
-
this.filename = f;
|
|
512
|
-
} else {
|
|
513
|
-
f = this.filename + '.db.json';
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
if (f) {
|
|
517
|
-
if (!this.dir) {
|
|
518
|
-
this.dir = f.dirname();
|
|
519
|
-
if (!fs.existsSync(dir)) {
|
|
520
|
-
fs.mkdirSync(dir);
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
if (!dir_api) {
|
|
524
|
-
dir_api = this.dir.dirname()
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
if (!f.hasFile()) {
|
|
528
|
-
this.save();
|
|
529
|
-
} else if (cover) {
|
|
530
|
-
var jobj = f.loadJson();
|
|
531
|
-
var o = Object.assign({}, this.config);
|
|
532
|
-
if (!o.title) {
|
|
533
|
-
delete o.title;
|
|
534
|
-
}
|
|
535
|
-
if (!o.description) {
|
|
536
|
-
delete o.description;
|
|
537
|
-
}
|
|
538
|
-
$.push(jobj, o, true);
|
|
539
|
-
f.saveText(JSON.stringify(jobj, null, 4));
|
|
540
|
-
}
|
|
541
|
-
this.update_api(dir_api, cover);
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* 更新API及相关配置文件
|
|
547
|
-
* @param {String} dir API存放目录
|
|
548
|
-
* @param {Boolean} cover 是否覆盖文件
|
|
549
|
-
*/
|
|
550
|
-
Drive.prototype.update_api = async function(dir, cover) {
|
|
551
|
-
var cg = this.config;
|
|
552
|
-
var arr = cg.table.split('_');
|
|
553
|
-
|
|
554
|
-
var name = "root";
|
|
555
|
-
if (arr.length > 1) {
|
|
556
|
-
name = cg.table.replace(arr[0], '').trim('_');
|
|
557
|
-
}
|
|
558
|
-
var l = $.slash;
|
|
559
|
-
var app = arr[0];
|
|
560
|
-
var o = $.pool.api[app + '_client'];
|
|
561
|
-
var client = "";
|
|
562
|
-
if (o) {
|
|
563
|
-
client = dir + l + "api_" + app + "_client";
|
|
564
|
-
} else {
|
|
565
|
-
client = dir + l + "api_client"
|
|
566
|
-
}
|
|
567
|
-
if (!fs.existsSync(client)) {
|
|
568
|
-
fs.mkdirSync(client);
|
|
569
|
-
}
|
|
570
|
-
client += "/" + name;
|
|
571
|
-
if (!fs.existsSync(client)) {
|
|
572
|
-
fs.mkdirSync(client);
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
o = $.pool.api[app + '_manage'];
|
|
576
|
-
var manage = "";
|
|
577
|
-
if (o) {
|
|
578
|
-
manage = dir + l + "api_" + app + "_manage";
|
|
579
|
-
} else {
|
|
580
|
-
manage = dir + l + "api_manage"
|
|
581
|
-
}
|
|
582
|
-
if (!fs.existsSync(manage)) {
|
|
583
|
-
fs.mkdirSync(manage);
|
|
584
|
-
}
|
|
585
|
-
manage += "/" + name;
|
|
586
|
-
if (!fs.existsSync(manage)) {
|
|
587
|
-
fs.mkdirSync(manage);
|
|
588
|
-
}
|
|
589
|
-
this.new_sql(client, manage, cover);
|
|
590
|
-
await this.new_param(client, manage, cover);
|
|
591
|
-
this.new_api(client, manage, cover);
|
|
592
|
-
};
|
|
593
|
-
|
|
594
|
-
/**
|
|
595
|
-
* 新建event配置文件和文件
|
|
596
|
-
* @param {String} dir 保存的路径
|
|
597
|
-
* @param {String} path 检索路径
|
|
598
|
-
* @param {String} scope 接口域
|
|
599
|
-
*/
|
|
600
|
-
Drive.prototype.new_event = async function(dir, path, scope) {
|
|
601
|
-
var f = dir + "/main.js";
|
|
602
|
-
if (!f.hasFile()) {
|
|
603
|
-
var code = (__dirname + '/event_script.js').loadText();
|
|
604
|
-
code = code.replaceAll('{0}', path).replaceAll('{1}', scope);
|
|
605
|
-
f.saveText(code);
|
|
606
|
-
}
|
|
607
|
-
};
|
|
608
|
-
|
|
609
|
-
/**
|
|
610
|
-
* 获取格式
|
|
611
|
-
* @param {Object} obj
|
|
612
|
-
* @return {Object} 返回格式
|
|
613
|
-
*/
|
|
614
|
-
Drive.prototype.get_format = async function(obj) {
|
|
615
|
-
var map = obj.map;
|
|
616
|
-
var format = {
|
|
617
|
-
key: obj.name,
|
|
618
|
-
title: obj.title.replace('ID', '').replace('id', '')
|
|
619
|
-
};
|
|
620
|
-
if (map.indexOf('|') !== -1) {
|
|
621
|
-
var list = map.split('|');
|
|
622
|
-
if (map.indexOf(',') !== -1) {
|
|
623
|
-
format.list = list.map((o) => {
|
|
624
|
-
var arr = o.split(',');
|
|
625
|
-
var value = arr[0];
|
|
626
|
-
if (arr.length > 0) {
|
|
627
|
-
return {
|
|
628
|
-
name: arr[1],
|
|
629
|
-
value: value
|
|
630
|
-
}
|
|
631
|
-
} else {
|
|
632
|
-
return {
|
|
633
|
-
name: value,
|
|
634
|
-
value
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
});
|
|
638
|
-
} else if (/^[0-9]+/.test(map)) {
|
|
639
|
-
if (map.indexOf('0') !== 0) {
|
|
640
|
-
list.unshift('');
|
|
641
|
-
}
|
|
642
|
-
format.list = list.map((value) => {
|
|
643
|
-
return value.replace(/[0-9]+/, '')
|
|
644
|
-
})
|
|
645
|
-
} else {
|
|
646
|
-
format.list = list.map((value) => {
|
|
647
|
-
return {
|
|
648
|
-
name: value,
|
|
649
|
-
value
|
|
650
|
-
}
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
} else {
|
|
654
|
-
if (map.indexOf('.') !== -1) {
|
|
655
|
-
var arr = obj.map.split('.');
|
|
656
|
-
format.table = arr[0];
|
|
657
|
-
format.name = arr[1];
|
|
658
|
-
if (arr.length > 2) {
|
|
659
|
-
format.id = arr[2];
|
|
660
|
-
} else {
|
|
661
|
-
format.id = obj.name;
|
|
662
|
-
}
|
|
663
|
-
} else {
|
|
664
|
-
format.table = obj.map;
|
|
665
|
-
format.id = obj.name;
|
|
666
|
-
format.name = 'name';
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
return format;
|
|
670
|
-
};
|
|
671
|
-
|
|
672
|
-
/**
|
|
673
|
-
* 新建sql配置文件
|
|
674
|
-
* @param {String} client 客户端配置保存路径
|
|
675
|
-
* @param {String} manage 管理端配置保存路径
|
|
676
|
-
* @param {Boolean} cover 是否覆盖文件
|
|
677
|
-
*/
|
|
678
|
-
Drive.prototype.new_sql = async function(client, manage, cover) {
|
|
679
|
-
var cg = this.config;
|
|
680
|
-
|
|
681
|
-
var lt = cg.fields;
|
|
682
|
-
var query = {};
|
|
683
|
-
var update = {};
|
|
684
|
-
var field = "";
|
|
685
|
-
var field_obj = "";
|
|
686
|
-
var query_default = {};
|
|
687
|
-
var format = [];
|
|
688
|
-
var orderby = "";
|
|
689
|
-
var uid = $.dict.user_id;
|
|
690
|
-
// 设置sql模板
|
|
691
|
-
var len = lt.length;
|
|
692
|
-
var keyword = "";
|
|
693
|
-
var query_default_user = this.isSet(cg.table, this.query_default_table);
|
|
694
|
-
for (var i = 0; i < len; i++) {
|
|
695
|
-
var o = lt[i];
|
|
696
|
-
var p = o.type;
|
|
697
|
-
var n = o.name;
|
|
698
|
-
if (this.isCan(n, this.get_not, p)) {
|
|
699
|
-
field += ",`" + n + "`";
|
|
700
|
-
}
|
|
701
|
-
if (this.isCan(n, this.getObj_not)) {
|
|
702
|
-
field_obj += ",`" + n + "`";
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
if (p === 'varchar' || p === 'text' || p === 'longtext') {
|
|
706
|
-
query[n] = "`" + n + "` like '%{0}%'";
|
|
707
|
-
if (this.isSet(n, this.query_keyword)) {
|
|
708
|
-
keyword += " || `" + n + "` like '%{0}%'";
|
|
709
|
-
}
|
|
710
|
-
} else if (p === 'date' || p === 'time' || p === 'datetime' || p === 'datetime' || p ===
|
|
711
|
-
'timestamp') {
|
|
712
|
-
query[n + "_min"] = "`" + n + "` >= '{0}'";
|
|
713
|
-
query[n + "_max"] = "`" + n + "` <= '{0}'";
|
|
714
|
-
} else if (p !== 'tinyint') {
|
|
715
|
-
if (!n.endWith('id')) {
|
|
716
|
-
query[n + "_min"] = "`" + n + "` >= {0}";
|
|
717
|
-
query[n + "_max"] = "`" + n + "` <= {0}";
|
|
718
|
-
update[n + "_add"] = "`" + n + "` = `" + n + "` + {0}";
|
|
719
|
-
|
|
720
|
-
if (n === "sort" || n === "display" || n === "orderby") {
|
|
721
|
-
orderby = '`' + n + '` asc';
|
|
722
|
-
}
|
|
723
|
-
} else if (n === uid && query_default_user) {
|
|
724
|
-
query_default[n] = "`" + n + "` = {" + uid + "}";
|
|
725
|
-
} else if (n === 'available' || n === 'show') {
|
|
726
|
-
query_default[n] = "`" + n + "` = 1";
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
if (o.map) {
|
|
730
|
-
var fmt = await this.get_format(o);
|
|
731
|
-
if (fmt) {
|
|
732
|
-
format.push(fmt);
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
if (cg.table.indexOf("user_") !== -1) {
|
|
738
|
-
keyword += ' || ' + keyword_default;
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
if (keyword) {
|
|
742
|
-
query["keyword"] = "(" + keyword.replace(' || ', '') + ")";
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
// 创建模型
|
|
746
|
-
var m = {
|
|
747
|
-
name: cg.table,
|
|
748
|
-
title: cg.title,
|
|
749
|
-
table: cg.table,
|
|
750
|
-
key: cg.key,
|
|
751
|
-
orderby_default: '`' + cg.key + '` desc',
|
|
752
|
-
field_obj: field_obj.replace(',', ''),
|
|
753
|
-
field_default: field.replace(',', ''),
|
|
754
|
-
method: 'get get_obj avg sum count',
|
|
755
|
-
query,
|
|
756
|
-
query_default,
|
|
757
|
-
update,
|
|
758
|
-
format
|
|
759
|
-
};
|
|
760
|
-
if (client) {
|
|
761
|
-
var oj = Object.assign({}, m);
|
|
762
|
-
if (orderby) {
|
|
763
|
-
oj.orderby_default = orderby;
|
|
764
|
-
}
|
|
765
|
-
if (oj.query_default[uid] && cg.table.indexOf("user_") !== -1) {
|
|
766
|
-
oj.filter = {
|
|
767
|
-
"table": "table",
|
|
768
|
-
"page": "page",
|
|
769
|
-
"size": "size",
|
|
770
|
-
"method": "method",
|
|
771
|
-
"orderby": "orderby",
|
|
772
|
-
"field": "field",
|
|
773
|
-
"count_ret": "count_ret"
|
|
774
|
-
};
|
|
775
|
-
oj.filter[uid] = uid;
|
|
776
|
-
}
|
|
777
|
-
this.save_file(client + '/sql.json', oj, cover);
|
|
778
|
-
}
|
|
779
|
-
if (manage) {
|
|
780
|
-
delete m.method;
|
|
781
|
-
m.field_hide = [];
|
|
782
|
-
m.name += 2;
|
|
783
|
-
m.field_obj = m.field_obj.replace(",`time_create`", "").replace(",`time_update`", "")
|
|
784
|
-
.replace(
|
|
785
|
-
",`create_time`", "")
|
|
786
|
-
.replace(",`update_time`", "");
|
|
787
|
-
delete m.query_default;
|
|
788
|
-
this.save_file(manage + '/sql.json', m, cover);
|
|
789
|
-
}
|
|
790
|
-
};
|
|
791
|
-
|
|
792
|
-
/**
|
|
793
|
-
* 保存sql配置
|
|
794
|
-
* @param {String} file 文件名
|
|
795
|
-
* @param {Object} model 配置模型
|
|
796
|
-
* @param {Boolean} cover 是否覆盖文件
|
|
797
|
-
*/
|
|
798
|
-
Drive.prototype.save_file = function(file, model, cover) {
|
|
799
|
-
if (!file.hasFile()) {
|
|
800
|
-
file.saveText(JSON.stringify(model, null, 4));
|
|
801
|
-
} else if (cover) {
|
|
802
|
-
var jobj = file.loadJson();
|
|
803
|
-
for (var k in model) {
|
|
804
|
-
var val = model[k];
|
|
805
|
-
if (!val) {
|
|
806
|
-
model[k] = jobj[k];
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
$.push(jobj, model, true);
|
|
810
|
-
file.saveText(JSON.stringify(jobj, null, 4));
|
|
811
|
-
}
|
|
812
|
-
};
|
|
813
|
-
|
|
814
|
-
/**
|
|
815
|
-
* 新建param配置文件
|
|
816
|
-
* @param {String} client 客户端配置保存路径
|
|
817
|
-
* @param {String} manage 管理端配置保存路径
|
|
818
|
-
* @param {Boolean} cover 是否覆盖文件
|
|
819
|
-
*/
|
|
820
|
-
Drive.prototype.new_param = async function(client, manage, cover) {
|
|
821
|
-
var cg = this.config;
|
|
822
|
-
|
|
823
|
-
var lt = cg.fields;
|
|
824
|
-
|
|
825
|
-
var cm = {
|
|
826
|
-
name: cg.table,
|
|
827
|
-
title: cg.title,
|
|
828
|
-
add: {
|
|
829
|
-
body: [],
|
|
830
|
-
body_required: []
|
|
831
|
-
},
|
|
832
|
-
del: {
|
|
833
|
-
query: [],
|
|
834
|
-
query_required: []
|
|
835
|
-
},
|
|
836
|
-
set: {
|
|
837
|
-
query: [],
|
|
838
|
-
query_required: [],
|
|
839
|
-
body: [],
|
|
840
|
-
body_required: [],
|
|
841
|
-
body_not: []
|
|
842
|
-
},
|
|
843
|
-
get: {
|
|
844
|
-
query: [],
|
|
845
|
-
query_required: []
|
|
846
|
-
},
|
|
847
|
-
get_obj: {
|
|
848
|
-
query_required: []
|
|
849
|
-
},
|
|
850
|
-
list: []
|
|
851
|
-
};
|
|
852
|
-
var len = lt.length;
|
|
853
|
-
var keyword = "";
|
|
854
|
-
for (var i = 0; i < len; i++) {
|
|
855
|
-
var o = lt[i];
|
|
856
|
-
var p = o.type;
|
|
857
|
-
var n = o.name;
|
|
858
|
-
|
|
859
|
-
var m = {
|
|
860
|
-
// 参数名
|
|
861
|
-
"name": n,
|
|
862
|
-
// 参数介绍名
|
|
863
|
-
"title": o.title,
|
|
864
|
-
// 参数做用描述
|
|
865
|
-
"description": o.description + (o.map ? '(' + o.map + ')' : ''),
|
|
866
|
-
// 是否主键
|
|
867
|
-
"key": o.pk,
|
|
868
|
-
// 参数类型 string字符串、number数字、bool布尔、dateTime时间、object对象类型、array数组类型
|
|
869
|
-
"type": "",
|
|
870
|
-
// 数据存储类型
|
|
871
|
-
"dataType": p
|
|
872
|
-
};
|
|
873
|
-
|
|
874
|
-
if (p === 'varchar' || p === 'text' || p === 'longtext') {
|
|
875
|
-
m.type = "string";
|
|
876
|
-
// 默认值
|
|
877
|
-
m.default = o.default;
|
|
878
|
-
|
|
879
|
-
// 字符串相关验证
|
|
880
|
-
m.string = {
|
|
881
|
-
// // 非空
|
|
882
|
-
// "notEmpty": o.not_null,
|
|
883
|
-
// // 最小长度
|
|
884
|
-
// "min": o.min_length,
|
|
885
|
-
// // 最大长度
|
|
886
|
-
// "max": o.max_length,
|
|
887
|
-
// // 验证字符串范围, 传入两个成员, 最小长度和最大长度。例如:[0, 0]
|
|
888
|
-
// "range": ,
|
|
889
|
-
// // 格式验证 email、url、date、dateISO、number、digits、phone
|
|
890
|
-
// "format": ""
|
|
891
|
-
};
|
|
892
|
-
|
|
893
|
-
var range = (o.min_length && o.max_length) ? [o.min_length, o.max_length] : [];
|
|
894
|
-
if (range.length > 0) {
|
|
895
|
-
m.string.range = range;
|
|
896
|
-
} else if (o.min_length) {
|
|
897
|
-
m.string.min = o.min_length;
|
|
898
|
-
} else if (o.max_length) {
|
|
899
|
-
m.string.max = o.max_length;
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
if (n.has("phone") || n === "tel") {
|
|
903
|
-
m.string.format = "phone"
|
|
904
|
-
} else if (n.has("url") || n === "src" || n === "source") {
|
|
905
|
-
m.string.format = "url"
|
|
906
|
-
} else if (n.has("date")) {
|
|
907
|
-
m.string.format = "date"
|
|
908
|
-
} else if (n === "num" || n === "number" || n === "count") {
|
|
909
|
-
m.string.format = "digits"
|
|
910
|
-
} else if (n === "money" || n === "coin") {
|
|
911
|
-
m.string.format = "number"
|
|
912
|
-
} else if (n.has("email")) {
|
|
913
|
-
m.string.format = "email"
|
|
914
|
-
}
|
|
915
|
-
if (o.not_null) {
|
|
916
|
-
m.string.notEmpty = !!o.not_null;
|
|
917
|
-
cm.add.body_required.push(n);
|
|
918
|
-
} else {
|
|
919
|
-
cm.add.body.push(n);
|
|
920
|
-
}
|
|
921
|
-
if (this.isSet(n, this.query_string)) {
|
|
922
|
-
cm.get.query.push(n);
|
|
923
|
-
cm.set.query.push(n);
|
|
924
|
-
keyword += "、" + o.title + "(" + n + ")";
|
|
925
|
-
}
|
|
926
|
-
cm.set.body.push(n);
|
|
927
|
-
// 添加验证模型
|
|
928
|
-
cm.list.push(m);
|
|
929
|
-
} else if (p === 'date' || p === 'time' || p === 'datetime' || p === 'timestamp') {
|
|
930
|
-
var format = "";
|
|
931
|
-
if (p === 'timestamp') {
|
|
932
|
-
format = "datetime"
|
|
933
|
-
} else {
|
|
934
|
-
format = p;
|
|
935
|
-
}
|
|
936
|
-
m.type = "string";
|
|
937
|
-
m.default = "";
|
|
938
|
-
// 时间相关验证
|
|
939
|
-
m.string = {
|
|
940
|
-
// 非空
|
|
941
|
-
"notEmpty": true,
|
|
942
|
-
"format": format
|
|
943
|
-
};
|
|
944
|
-
// 添加验证模型
|
|
945
|
-
cm.list.push(m);
|
|
946
|
-
var m_min = Object.assign({}, m);
|
|
947
|
-
m_min.name = n + "_min";
|
|
948
|
-
m_min.title += "——开始时间";
|
|
949
|
-
cm.list.push(m_min);
|
|
950
|
-
var m_max = Object.assign({}, m);
|
|
951
|
-
m_max.name = n + "_max";
|
|
952
|
-
m_max.title += "——结束时间";
|
|
953
|
-
cm.list.push(m_max);
|
|
954
|
-
|
|
955
|
-
if (n.indexOf('create') !== -1 && n.indexOf('update') !== -1) {
|
|
956
|
-
cm.add.body.push(n);
|
|
957
|
-
cm.set.body.push(n);
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
cm.get.query.push(n + "_min");
|
|
961
|
-
cm.get.query.push(n + "_max");
|
|
962
|
-
} else {
|
|
963
|
-
m.type = "number";
|
|
964
|
-
m.default = Number(o.default) + "";
|
|
965
|
-
// 数值相关验证
|
|
966
|
-
|
|
967
|
-
m.number = {
|
|
968
|
-
// // 最小值
|
|
969
|
-
// "min": o.min,
|
|
970
|
-
// // 最大值
|
|
971
|
-
// "max": o.max,
|
|
972
|
-
// // 验证字符串范围
|
|
973
|
-
// "range": []
|
|
974
|
-
};
|
|
975
|
-
var range = (o.min && o.max) ? [o.min, o.max] : [];
|
|
976
|
-
if (range.length > 0) {
|
|
977
|
-
m.number.range = range;
|
|
978
|
-
} else if (o.min) {
|
|
979
|
-
m.number.min = o.min;
|
|
980
|
-
} else if (o.max) {
|
|
981
|
-
m.number.max = o.max;
|
|
982
|
-
}
|
|
983
|
-
if (o.name === cg.key) {
|
|
984
|
-
cm.del.query_required.push(n);
|
|
985
|
-
cm.set.query.push(n);
|
|
986
|
-
cm.get.query.push(n);
|
|
987
|
-
cm.get_obj.query_required.push(n);
|
|
988
|
-
// 添加验证模型
|
|
989
|
-
cm.list.push(m);
|
|
990
|
-
} else {
|
|
991
|
-
cm.add.body.push(n);
|
|
992
|
-
cm.set.body.push(n);
|
|
993
|
-
cm.list.push(m);
|
|
994
|
-
if (m.dataType !== "tinyint") {
|
|
995
|
-
var ne = n;
|
|
996
|
-
if (!ne.endWith('id')) {
|
|
997
|
-
cm.get.query.push(n + "_min");
|
|
998
|
-
cm.get.query.push(n + "_max");
|
|
999
|
-
cm.set.query.push(n + "_min");
|
|
1000
|
-
cm.set.query.push(n + "_max");
|
|
1001
|
-
cm.set.body.push(n + "_add");
|
|
1002
|
-
var m_min = Object.assign({}, m);
|
|
1003
|
-
m_min.name = n + "_min";
|
|
1004
|
-
m_min.title += "——最小值";
|
|
1005
|
-
cm.list.push(m_min);
|
|
1006
|
-
var m_max = Object.assign({}, m);
|
|
1007
|
-
m_max.name = n + "_max";
|
|
1008
|
-
m_max.title += "——最大值";
|
|
1009
|
-
cm.list.push(m_max);
|
|
1010
|
-
} else {
|
|
1011
|
-
cm.get.query.push(n);
|
|
1012
|
-
if (this.isSet(n, this.query_number)) {
|
|
1013
|
-
cm.set.query.push(n);
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
} else {
|
|
1017
|
-
cm.set.query.push(n);
|
|
1018
|
-
cm.get.query.push(n);
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
if (keyword) {
|
|
1025
|
-
cm.get.query.push('keyword');
|
|
1026
|
-
cm.set.query.push('keyword');
|
|
1027
|
-
if (cg.table.indexOf("user_") !== -1) {
|
|
1028
|
-
keyword += '、' + keyword_default_tip;
|
|
1029
|
-
}
|
|
1030
|
-
var m_k = {
|
|
1031
|
-
"name": "keyword",
|
|
1032
|
-
"title": "关键词",
|
|
1033
|
-
"description": "用于搜索" + keyword.replace('、', ''),
|
|
1034
|
-
"type": "string",
|
|
1035
|
-
"dataType": "varchar",
|
|
1036
|
-
"string": {}
|
|
1037
|
-
};
|
|
1038
|
-
cm.list.push(m_k);
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
// 保存配置文件
|
|
1042
|
-
if (client) {
|
|
1043
|
-
this.save_file(client + '/param.json', cm, cover);
|
|
1044
|
-
}
|
|
1045
|
-
if (manage) {
|
|
1046
|
-
delete cm.method;
|
|
1047
|
-
cm.name += 2;
|
|
1048
|
-
this.save_file(manage + '/param.json', cm, cover);
|
|
1049
|
-
}
|
|
1050
|
-
};
|
|
1051
|
-
|
|
1052
|
-
/**
|
|
1053
|
-
* 是否设置
|
|
1054
|
-
* @param {String} name 名称
|
|
1055
|
-
* @param {Array} arr 匹配的对象
|
|
1056
|
-
*/
|
|
1057
|
-
Drive.prototype.isSet = function(name, arr) {
|
|
1058
|
-
var bl = false;
|
|
1059
|
-
for (var i = 0; i < arr.length; i++) {
|
|
1060
|
-
if (name.indexOf(arr[i]) !== -1) {
|
|
1061
|
-
bl = true;
|
|
1062
|
-
break;
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
return bl;
|
|
1066
|
-
};
|
|
1067
|
-
|
|
1068
|
-
/**
|
|
1069
|
-
* 是否排除
|
|
1070
|
-
* @param {String} name 名称
|
|
1071
|
-
* @param {Array} arr 匹配的对象
|
|
1072
|
-
* @param {String} type 数据类型
|
|
1073
|
-
* @return {Boolean} 是否可以
|
|
1074
|
-
*/
|
|
1075
|
-
Drive.prototype.isCan = function(name, arr, type) {
|
|
1076
|
-
if (type === 'longtext') {
|
|
1077
|
-
return false;
|
|
1078
|
-
}
|
|
1079
|
-
var bl = false;
|
|
1080
|
-
for (var i = 0; i < arr.length; i++) {
|
|
1081
|
-
if (name.indexOf(arr[i]) !== -1) {
|
|
1082
|
-
bl = true;
|
|
1083
|
-
break;
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
return !bl;
|
|
1087
|
-
};
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
/**
|
|
1091
|
-
* 新建api配置文件
|
|
1092
|
-
* @param {String} client 客户端配置保存路径
|
|
1093
|
-
* @param {String} manage 管理端配置保存路径
|
|
1094
|
-
* @param {Boolean} cover 是否覆盖文件
|
|
1095
|
-
*/
|
|
1096
|
-
Drive.prototype.new_api = async function(client, manage, cover) {
|
|
1097
|
-
var cg = this.config;
|
|
1098
|
-
var arr = cg.table.split('_');
|
|
1099
|
-
var p = "/api/";
|
|
1100
|
-
if (arr.length > 1) {
|
|
1101
|
-
p += cg.table.replace('_', '/');
|
|
1102
|
-
} else {
|
|
1103
|
-
p += arr[0];
|
|
1104
|
-
}
|
|
1105
|
-
var m = {
|
|
1106
|
-
"name": cg.table,
|
|
1107
|
-
"title": cg.title,
|
|
1108
|
-
"description": cg.description,
|
|
1109
|
-
"path": p,
|
|
1110
|
-
"method": "ALL",
|
|
1111
|
-
"cache": 0,
|
|
1112
|
-
"client_cache": false,
|
|
1113
|
-
"param_path": "./param.json",
|
|
1114
|
-
"sql_path": "./sql.json",
|
|
1115
|
-
"check_param": true
|
|
1116
|
-
};
|
|
1117
|
-
|
|
1118
|
-
// 保存配置文件
|
|
1119
|
-
if (client) {
|
|
1120
|
-
var o = Object.assign({}, m);
|
|
1121
|
-
|
|
1122
|
-
var lt = cg.fields;
|
|
1123
|
-
if (cg.title.indexOf('user') !== -1) {
|
|
1124
|
-
// 判断该表是否含用户ID,如果含有则需要验证才能访问
|
|
1125
|
-
var has = false;
|
|
1126
|
-
for (var i = 0, item; item = lt[i++];) {
|
|
1127
|
-
var name = item.name;
|
|
1128
|
-
if (name == $.dict.user_id || name === 'uid' || name === 'user_id' || name ===
|
|
1129
|
-
'userid') {
|
|
1130
|
-
has = true;
|
|
1131
|
-
break;
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
if (has) {
|
|
1135
|
-
o.oauth = {
|
|
1136
|
-
"scope": true,
|
|
1137
|
-
"signIn": true,
|
|
1138
|
-
"vip": 0,
|
|
1139
|
-
"user_group": []
|
|
1140
|
-
};
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
o.method = "GET";
|
|
1144
|
-
this.save_file(client + '/api.json', o, cover);
|
|
1145
|
-
}
|
|
1146
|
-
if (manage) {
|
|
1147
|
-
var o = Object.assign({}, m);
|
|
1148
|
-
o.oauth = {
|
|
1149
|
-
"scope": true,
|
|
1150
|
-
"signIn": true,
|
|
1151
|
-
"gm": 2,
|
|
1152
|
-
"user_admin": []
|
|
1153
|
-
};
|
|
1154
|
-
o.path = o.path.replace("/api/", "/apis/");
|
|
1155
|
-
o.name += "_manage";
|
|
1156
|
-
this.save_file(manage + '/api.json', o, cover);
|
|
1157
|
-
}
|
|
1158
|
-
};
|
|
1159
|
-
|
|
1160
|
-
module.exports = Drive;
|