mm_os 2.1.4 → 2.1.6
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/api/drive.js +9 -3
- package/core/com/sql/drive.js +28 -3
- package/package.json +1 -1
package/core/com/api/drive.js
CHANGED
|
@@ -26,10 +26,10 @@ class Drive extends Item {
|
|
|
26
26
|
constructor(dir) {
|
|
27
27
|
super(dir, __dirname);
|
|
28
28
|
this.default_file = "./api.json";
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
this.save_dir = './static/file/';
|
|
31
31
|
this.url_path = "./file/";
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
// oauth身份验证配置 + 函数
|
|
34
34
|
this.oauth;
|
|
35
35
|
// param参数配置 + 函数
|
|
@@ -268,6 +268,12 @@ Drive.prototype.loadSql = async function(file_path) {
|
|
|
268
268
|
this.sql.load(p);
|
|
269
269
|
this.setSql(this.sql);
|
|
270
270
|
}
|
|
271
|
+
// if (this.sql && this.param && this.param.config) {
|
|
272
|
+
// var list = this.param.config.list;
|
|
273
|
+
// if (list && list.length) {
|
|
274
|
+
// this.sql.params = list;
|
|
275
|
+
// }
|
|
276
|
+
// }
|
|
271
277
|
}
|
|
272
278
|
};
|
|
273
279
|
|
|
@@ -334,7 +340,7 @@ Drive.prototype.save_file = function(files) {
|
|
|
334
340
|
file.addDir();
|
|
335
341
|
// 创建写入流
|
|
336
342
|
var readStream = fs.createReadStream(f.filepath);
|
|
337
|
-
|
|
343
|
+
|
|
338
344
|
try {
|
|
339
345
|
const writeStream = fs.createWriteStream(file);
|
|
340
346
|
readStream.pipe(writeStream);
|
package/core/com/sql/drive.js
CHANGED
|
@@ -21,6 +21,7 @@ class Drive extends Item {
|
|
|
21
21
|
this.url_path = "/file/";
|
|
22
22
|
|
|
23
23
|
/* 通用项 */
|
|
24
|
+
this.params = null;
|
|
24
25
|
// 配置参数
|
|
25
26
|
this.config = {
|
|
26
27
|
// 名称, 由中英文和下“_”组成, 用于修改或卸载 例如: demo
|
|
@@ -555,6 +556,18 @@ Drive.prototype.addOrSet = async function(db, query, body) {
|
|
|
555
556
|
return await this.addOrSet_main(db, query, body);
|
|
556
557
|
};
|
|
557
558
|
|
|
559
|
+
/**
|
|
560
|
+
* 获取数据类型
|
|
561
|
+
* @param {String} dataType 数据库数据类型
|
|
562
|
+
* @returns {String} 返回数据类型
|
|
563
|
+
*/
|
|
564
|
+
Drive.prototype.get_type = function(dataType) {
|
|
565
|
+
if (dataType.indexOf('int') !== -1) {
|
|
566
|
+
return 'number'
|
|
567
|
+
} else {
|
|
568
|
+
return 'string'
|
|
569
|
+
}
|
|
570
|
+
}
|
|
558
571
|
|
|
559
572
|
/**
|
|
560
573
|
* 获取数据
|
|
@@ -566,6 +579,9 @@ Drive.prototype.get_params = async function(db, fields) {
|
|
|
566
579
|
if (cg.params) {
|
|
567
580
|
return cg.params;
|
|
568
581
|
}
|
|
582
|
+
if (this.params) {
|
|
583
|
+
return this.params;
|
|
584
|
+
}
|
|
569
585
|
var lt = [];
|
|
570
586
|
if ($.pool.db) {
|
|
571
587
|
var pool = $.pool.db['sys'];
|
|
@@ -589,11 +605,13 @@ Drive.prototype.get_params = async function(db, fields) {
|
|
|
589
605
|
var list = await db.fields();
|
|
590
606
|
for (var i = 0; i < list.length; i++) {
|
|
591
607
|
var o = list[i];
|
|
608
|
+
console.log("值", o);
|
|
592
609
|
var name = o.name;
|
|
593
610
|
var note = o.note ? o.note.replace(":", ":") : name;
|
|
594
611
|
lt.push({
|
|
595
612
|
name,
|
|
596
|
-
title: note.left(":", true)
|
|
613
|
+
title: note.left(":", true),
|
|
614
|
+
type: this.get_type(o.type)
|
|
597
615
|
});
|
|
598
616
|
}
|
|
599
617
|
}
|
|
@@ -788,8 +806,15 @@ Drive.prototype.export_main = async function(db, query, body) {
|
|
|
788
806
|
if (!file) {
|
|
789
807
|
file = this.save_dir + name;
|
|
790
808
|
}
|
|
791
|
-
if (!fields
|
|
792
|
-
|
|
809
|
+
if (!fields) {
|
|
810
|
+
if (query.field) {
|
|
811
|
+
fields = query.field;
|
|
812
|
+
} else {
|
|
813
|
+
var f = this.config.field_default;
|
|
814
|
+
if (f.length !== "*") {
|
|
815
|
+
fields = f;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
793
818
|
}
|
|
794
819
|
var params = await this.get_params(db, fields);
|
|
795
820
|
var format = await this.get_format(db);
|