mm_os 1.5.4 → 1.5.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.
@@ -328,7 +328,6 @@ Drive.prototype.save_file = function(files) {
328
328
  if (files.file) {
329
329
  var f = files.file;
330
330
  // 创建可读流
331
- const readStream = fs.createReadStream(f.path);
332
331
  var stamp = Date.now();
333
332
  var name = f.name;
334
333
  file = path.join($.runPath, dir, name);
@@ -375,7 +374,10 @@ $.get_state = async function(db, token) {
375
374
  o.password = o.password ? "******" : "";
376
375
  delete o.salt;
377
376
  delete o.time_create;
378
- return { state, user: o };
377
+ return {
378
+ state,
379
+ user: o
380
+ };
379
381
  } else {
380
382
  return null;
381
383
  }
@@ -714,4 +716,4 @@ Drive.prototype.runRPC = async function(db, method, query, body) {
714
716
  return ret;
715
717
  };
716
718
 
717
- module.exports = Drive;
719
+ module.exports = Drive;
@@ -1,8 +1,7 @@
1
1
  const Item = require('mm_machine').Item;
2
2
  const Excel = require('mm_excel');
3
3
 
4
- var save_dir = '/app/sys/static/doc/';
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/file/';
22
+ // 读取文件目录
23
+ this.url_path = "/file/";
21
24
 
22
25
  /* 通用项 */
23
26
  // 配置参数
@@ -620,7 +623,12 @@ Drive.prototype.get_format = async function(db) {
620
623
  if (o.table) {
621
624
  if (!o.list || o.list.length == 0) {
622
625
  dbs.table = o.table;
623
- o.list = await dbs.getSql(o.where, null, o.key + "," + o.name);
626
+ var list = await dbs.getSql(o.where, null, o.id + "," + o.name);
627
+ if (o.id !== o.key) {
628
+ o.list.map((m) => {
629
+ m[o.key] = m[o.id]
630
+ })
631
+ }
624
632
  }
625
633
  }
626
634
  }
@@ -636,8 +644,14 @@ Drive.prototype.get_format = async function(db) {
636
644
  Drive.prototype.import_main = async function(db, file) {
637
645
  var params = await this.get_params();
638
646
  var format = await this.get_format(db);
639
- file = file.replace(url_path, save_dir);
640
- file = file.fullname($.config.path.user || $.config.path.static);
647
+ file = file.replace(this.url_path, this.save_dir);
648
+ var path;
649
+ if ($.config.path) {
650
+ path = $.config.path.user || $.config.path.static || "/static/";
651
+ } else {
652
+ path = "/static/";
653
+ }
654
+ file = file.fullname(path);
641
655
  if (!file.hasFile()) {
642
656
  return $.ret.error(30001, file + "文件不存在!");
643
657
  }
@@ -740,9 +754,17 @@ Drive.prototype.export_main = async function(db, query, body) {
740
754
  var table = db.table || this.config.table;
741
755
  var date = new Date();
742
756
  var name = table + "_" + date.stamp() + '.xlsx';
757
+
758
+ if (!path) {
759
+ if ($.config.path) {
760
+ path = $.config.path.user || $.config.path.static || "/static/";
761
+ } else {
762
+ path = "/static/";
763
+ }
764
+ }
743
765
  if (!file) {
744
- file = save_dir + name;
745
- file.addDir($.config.path.user || $.config.path.static);
766
+ file = this.save_dir + name;
767
+ file.addDir(path);
746
768
  }
747
769
  if (!fields && query.field) {
748
770
  fields = query.field;
@@ -750,10 +772,7 @@ Drive.prototype.export_main = async function(db, query, body) {
750
772
  var params = await this.get_params(fields);
751
773
  var format = await this.get_format(db);
752
774
 
753
- if (!path) {
754
- path = $.config.path.user;
755
- }
756
- file = file.fullname(path || $.config.path.static);
775
+ file = file.fullname(path);
757
776
  var excel = new Excel({
758
777
  file,
759
778
  params,
@@ -771,7 +790,7 @@ Drive.prototype.export_main = async function(db, query, body) {
771
790
 
772
791
  var body = $.ret.bl(!!file, file ? '导出成功!' : '导出失败!');
773
792
  body.result.file = file;
774
- body.result.url = url_path + name;
793
+ body.result.url = this.url_path + name;
775
794
  if (message) {
776
795
  body.result.message = message;
777
796
  }
@@ -1019,4 +1038,4 @@ Drive.prototype.count = async function(db, query, body) {
1019
1038
  };
1020
1039
 
1021
1040
 
1022
- module.exports = Drive;
1041
+ module.exports = Drive;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_os",
3
- "version": "1.5.4",
3
+ "version": "1.5.6",
4
4
  "description": "这是超级美眉服务端框架,用于快速构建应用程序。",
5
5
  "main": "index.js",
6
6
  "scripts": {