mm_os 1.5.3 → 1.5.5
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/com/sql/drive.js +26 -12
- package/package.json +2 -2
package/core/com/sql/drive.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
const Item = require('mm_machine').Item;
|
|
2
2
|
const Excel = require('mm_excel');
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
var url_path = "/sys/doc/";
|
|
4
|
+
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Sql操作驱动类
|
|
@@ -18,6 +17,10 @@ class Drive extends Item {
|
|
|
18
17
|
constructor(dir) {
|
|
19
18
|
super(dir, __dirname);
|
|
20
19
|
this.default_file = "./sql.json";
|
|
20
|
+
// 保存文件目录
|
|
21
|
+
this.save_dir = '/static/doc/';
|
|
22
|
+
// 读取文件目录
|
|
23
|
+
this.url_path = "/doc/";
|
|
21
24
|
|
|
22
25
|
/* 通用项 */
|
|
23
26
|
// 配置参数
|
|
@@ -636,8 +639,14 @@ Drive.prototype.get_format = async function(db) {
|
|
|
636
639
|
Drive.prototype.import_main = async function(db, file) {
|
|
637
640
|
var params = await this.get_params();
|
|
638
641
|
var format = await this.get_format(db);
|
|
639
|
-
file = file.replace(url_path, save_dir);
|
|
640
|
-
|
|
642
|
+
file = file.replace(this.url_path, this.save_dir);
|
|
643
|
+
var path;
|
|
644
|
+
if ($.config.path) {
|
|
645
|
+
path = $.config.path.user || $.config.path.static || "/static/";
|
|
646
|
+
} else {
|
|
647
|
+
path = "/static/";
|
|
648
|
+
}
|
|
649
|
+
file = file.fullname(path);
|
|
641
650
|
if (!file.hasFile()) {
|
|
642
651
|
return $.ret.error(30001, file + "文件不存在!");
|
|
643
652
|
}
|
|
@@ -740,9 +749,17 @@ Drive.prototype.export_main = async function(db, query, body) {
|
|
|
740
749
|
var table = db.table || this.config.table;
|
|
741
750
|
var date = new Date();
|
|
742
751
|
var name = table + "_" + date.stamp() + '.xlsx';
|
|
752
|
+
|
|
753
|
+
if (!path) {
|
|
754
|
+
if ($.config.path) {
|
|
755
|
+
path = $.config.path.user || $.config.path.static || "/static/";
|
|
756
|
+
} else {
|
|
757
|
+
path = "/static/";
|
|
758
|
+
}
|
|
759
|
+
}
|
|
743
760
|
if (!file) {
|
|
744
|
-
file = save_dir + name;
|
|
745
|
-
file.addDir(
|
|
761
|
+
file = this.save_dir + name;
|
|
762
|
+
file.addDir(path);
|
|
746
763
|
}
|
|
747
764
|
if (!fields && query.field) {
|
|
748
765
|
fields = query.field;
|
|
@@ -750,10 +767,7 @@ Drive.prototype.export_main = async function(db, query, body) {
|
|
|
750
767
|
var params = await this.get_params(fields);
|
|
751
768
|
var format = await this.get_format(db);
|
|
752
769
|
|
|
753
|
-
|
|
754
|
-
path = $.config.path.user;
|
|
755
|
-
}
|
|
756
|
-
file = file.fullname(path || $.config.path.static);
|
|
770
|
+
file = file.fullname(path);
|
|
757
771
|
var excel = new Excel({
|
|
758
772
|
file,
|
|
759
773
|
params,
|
|
@@ -771,7 +785,7 @@ Drive.prototype.export_main = async function(db, query, body) {
|
|
|
771
785
|
|
|
772
786
|
var body = $.ret.bl(!!file, file ? '导出成功!' : '导出失败!');
|
|
773
787
|
body.result.file = file;
|
|
774
|
-
body.result.url = url_path + name;
|
|
788
|
+
body.result.url = this.url_path + name;
|
|
775
789
|
if (message) {
|
|
776
790
|
body.result.message = message;
|
|
777
791
|
}
|
|
@@ -1019,4 +1033,4 @@ Drive.prototype.count = async function(db, query, body) {
|
|
|
1019
1033
|
};
|
|
1020
1034
|
|
|
1021
1035
|
|
|
1022
|
-
module.exports = Drive;
|
|
1036
|
+
module.exports = Drive;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_os",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5",
|
|
4
4
|
"description": "这是超级美眉服务端框架,用于快速构建应用程序。",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"mm_html": "^1.1.1",
|
|
41
41
|
"mm_koa_proxy": "^1.0.0",
|
|
42
42
|
"mm_logs": "^1.1.0",
|
|
43
|
-
"mm_machine": "^1.5.
|
|
43
|
+
"mm_machine": "^1.5.8",
|
|
44
44
|
"mm_mongodb": "^1.3.9",
|
|
45
45
|
"mm_mqtt": "^1.0.5",
|
|
46
46
|
"mm_mysql": "^1.7.1",
|