ming_node 2.2.3 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. package/README.md +10 -0
  2. package/beforeTest/ApiCloudBaseRpcApiTest.js +17 -0
  3. package/beforeTest/FileBaseRpcApiTest.js +8 -0
  4. package/beforeTest/MemorDbTest.js +16 -0
  5. package/beforeTest/MemoryBaseRestApiTest.js +8 -0
  6. package/beforeTest/MemoryBaseRpcApiTest.js +8 -0
  7. package/beforeTest/MiApiCloudClientTest.js +16 -0
  8. package/beforeTest/MongoDbBaseRestApiTest.js +22 -0
  9. package/beforeTest/MongoDbBaseRpcApiTest.js +19 -0
  10. package/beforeTest/MySqlBaseRestApiTest.js +13 -0
  11. package/beforeTest/MysqlBaseRpcApiTest.js +18 -0
  12. package/beforeTest/graphql_test.js +12 -0
  13. package/beforeTest/installPluginTest.js +10 -0
  14. package/index.js +125 -28
  15. package/ming_node.md +4 -4
  16. package/module/BaseMapper.js +37 -4
  17. package/module/MemoryDb.js +136 -0
  18. package/module/MiApiCloudClient.js +649 -0
  19. package/package.json +1 -1
  20. package/plugins/BaseGraphqlApi/getGraphqlSchema.js +145 -0
  21. package/plugins/BaseGraphqlApi/getGraphqlSchemaDemo.js +76 -0
  22. package/plugins/BaseGraphqlApi/index.js +23 -0
  23. package/plugins/BaseRestApi/AbstractBaseRestApi.js +59 -0
  24. package/plugins/BaseRestApi/ApiCloudBaseRestApi.js +56 -0
  25. package/plugins/BaseRestApi/FileBaseRestApi.js +62 -0
  26. package/plugins/BaseRestApi/MemoryBaseRestApi.js +50 -0
  27. package/plugins/BaseRestApi/MongoDbBaseRestApi.js +75 -0
  28. package/plugins/BaseRestApi/MysqlBaseRestApi.js +72 -0
  29. package/plugins/BaseRpcApi/AbstractBaseRpcApi.js +72 -0
  30. package/plugins/BaseRpcApi/ApiCloudBaseRpcApi.js +57 -0
  31. package/plugins/BaseRpcApi/FileBaseRpcApi.js +62 -0
  32. package/plugins/BaseRpcApi/MemoryBaseRpcApi.js +50 -0
  33. package/plugins/BaseRpcApi/MongoDbBaseRpcApi.js +75 -0
  34. package/plugins/BaseRpcApi/MysqlBaseRpcApi.js +72 -0
  35. package/utils/common/CollectionUtils.js +28 -0
  36. package/beforeTest/t1.js +0 -18
package/README.md CHANGED
@@ -190,6 +190,16 @@ async function main(){
190
190
 
191
191
  ```
192
192
 
193
+ # Rpc风格,服务插件
194
+ [ming_node api插件.yuque](https://www.yuque.com/docs/share/f4444345-ea5b-4f3d-b0c7-ab267e901e81)
195
+ ```js
196
+ var M=require("ming_node");
197
+ const Api= require("ming_node/plugins/BaseRpcApi/MemoryBaseRpcApi");
198
+ let api = new Api({tableName:"ming",generateTime:true})
199
+ var app=M.server();
200
+ app.listen(8888);
201
+ app.use(api);
202
+ ```
193
203
 
194
204
  # 基于ming_node 的 ming_api_mock
195
205
 
@@ -0,0 +1,17 @@
1
+ var M=require("../index");
2
+ const ApiCloudBaseRpcApi= require("../plugins/BaseRpcApi/ApiCloudBaseRpcApi");
3
+ const MiApiCloudClient=require("../module/MiApiCloudClient");
4
+ const apiCloudClient = new MiApiCloudClient("A6032931027980", "FF279F8E-8B09-5F1A-1036-F6AE53F3538D");
5
+ let apiCloudBaseRpcApi = new ApiCloudBaseRpcApi(
6
+ {
7
+ prefix:"ming",
8
+ tableName:"ming",
9
+ apiCloudClient
10
+ }
11
+ )
12
+
13
+ var app=M.server();
14
+
15
+ app.listen(8888);
16
+
17
+ app.use(apiCloudBaseRpcApi);
@@ -0,0 +1,8 @@
1
+ var M=require("../index");
2
+ const FileBaseRpcApi= require("../plugins/BaseRpcApi/FileBaseRpcApi");
3
+
4
+ let fileBaseRpcApi = new FileBaseRpcApi({prefix:"ming", tableName:"a.json",generateTime:true})
5
+ var app=M.server();
6
+ app.listen(8888);
7
+
8
+ app.use(fileBaseRpcApi);
@@ -0,0 +1,16 @@
1
+ MemoryDb=require("../module/MemoryDb")
2
+
3
+ db= new MemoryDb()
4
+
5
+ db.add({
6
+ name:"zs"
7
+ })
8
+
9
+ console.log(db.listByPage())
10
+
11
+
12
+ db.add({
13
+ name:"ls"
14
+ })
15
+
16
+ console.log(db.listByPage())
@@ -0,0 +1,8 @@
1
+ var M=require("../index");
2
+ const MemoryBaseRestApi= require("../plugins/BaseRestApi/MemoryBaseRestApi");
3
+
4
+ let memoryBaseRestApi = new MemoryBaseRestApi({tableName:"ming",generateTime:true})
5
+ var app=M.server();
6
+ app.listen(8888);
7
+
8
+ app.use(memoryBaseRestApi);
@@ -0,0 +1,8 @@
1
+ var M=require("../index");
2
+ const MemoryBaseRpcApi= require("../plugins/BaseRpcApi/MemoryBaseRpcApi");
3
+
4
+ let memoryBaseRpcApi = new MemoryBaseRpcApi({tableName:"ming",generateTime:true})
5
+ var app=M.server();
6
+ app.listen(8888);
7
+
8
+ app.use(memoryBaseRpcApi);
@@ -0,0 +1,16 @@
1
+ const MiApiCloudClient=require("../module/MiApiCloudClient")
2
+
3
+
4
+ M.MiApiCloudClient = new MiApiCloudClient("A6032931027980", "FF279F8E-8B09-5F1A-1036-F6AE53F3538D").tableClient("mi_user");
5
+
6
+
7
+ mi_resource.list({},null,null,"sort").then(d => {
8
+ let result = { rows: d }
9
+ console.log(result)
10
+ })
11
+
12
+ // mi_resource.add({
13
+ // username:"minglie2234"
14
+ // }).then(d=>{
15
+ // console.log(d)
16
+ // })
@@ -0,0 +1,22 @@
1
+ var M=require("../index");
2
+
3
+
4
+ Db= M.getMongoDB({
5
+ dbUrl: "mongodb://root:123456@localhost:27017/?authMechanism=SCRAM-SHA-1&authSource=miapi",
6
+ dbName:"miapi"
7
+ })
8
+
9
+
10
+
11
+ const MongoDbBaseRestApi= require("../plugins/BaseRestApi/MongoDbBaseRestApi");
12
+
13
+
14
+
15
+ let mongoDbBaseRestApi = new MongoDbBaseRestApi({tableName:"test",prefix:"ming", generateTime:true})
16
+ var app=M.server();
17
+ app.listen(8888);
18
+
19
+ app.use(mongoDbBaseRestApi);
20
+
21
+
22
+ console.log(M._globle_plugin)
@@ -0,0 +1,19 @@
1
+ var M=require("../index");
2
+
3
+
4
+ Db= M.getMongoDB({
5
+ dbUrl: "mongodb://root:123456@localhost:27017/?authMechanism=SCRAM-SHA-1&authSource=miapi",
6
+ dbName:"miapi"
7
+ })
8
+
9
+
10
+
11
+ const MongoDbBaseRpcApi= require("../plugins/BaseRpcApi/MongoDbBaseRpcApi");
12
+
13
+
14
+
15
+ let mongoDbBaseRpcApi = new MongoDbBaseRpcApi({tableName:"test",prefix:"ming", generateTime:true})
16
+ var app=M.server();
17
+ app.listen(8888);
18
+
19
+ app.use(mongoDbBaseRpcApi);
@@ -0,0 +1,13 @@
1
+ var M=require("../index");
2
+ const MysqlBaseRestApi= require("../plugins/BaseRestApi/MysqlBaseRestApi");
3
+
4
+ M.getMySql({
5
+ database:"miapi"
6
+ })
7
+
8
+
9
+ let mysqlBaseRestApi = new MysqlBaseRestApi({tableName:"ming",generateTime:true})
10
+ var app=M.server();
11
+ app.listen(8888);
12
+
13
+ app.use(mysqlBaseRestApi);
@@ -0,0 +1,18 @@
1
+ var M=require("../index");
2
+
3
+
4
+ M.getMySql({
5
+ database:"miapi"
6
+ })
7
+
8
+
9
+
10
+ const MysqlBaseRpcApi= require("../plugins/BaseRpcApi/MysqlBaseRpcApi");
11
+
12
+
13
+
14
+ let mysqlBaseRpcApi = new MysqlBaseRpcApi({tableName:"ming",generateTime:true})
15
+ var app=M.server();
16
+ app.listen(8888);
17
+
18
+ app.use(mysqlBaseRpcApi);
@@ -0,0 +1,12 @@
1
+ var M = require('../index');
2
+ var BaseMapper=require("../module/BaseMapper")
3
+ var Db=M.getMySql({
4
+ "database" : "miapi"
5
+ })
6
+ let dbBaseMapper= new BaseMapper("person");
7
+ const BaseGraphqlApi= require("../plugins/BaseGraphqlApi/index");
8
+ let baseGraphqlApi = new BaseGraphqlApi({prefix:"person", dbBaseMapper});
9
+
10
+ var app = M.server()
11
+ app.listen(4000)
12
+ app.use(baseGraphqlApi);
@@ -0,0 +1,10 @@
1
+ var M=require("ming_node");
2
+
3
+ var app=M.server();
4
+ app.listen(8888);
5
+
6
+ app.installPlugin("http://localhost:4444/OssWebApi.js",{
7
+ name:"我是插件构造方法参数"
8
+ },{
9
+ name:"我是插件构造方法附加参数"
10
+ });
package/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * File : index.js
2
+ * File : MemoryBaseRpcApi.js
3
3
  * By : Minglie
4
4
  * QQ: 934031452
5
- * Date :2021.09.14
6
- * version :2.2.3
5
+ * Date :2021.12.01
6
+ * version :2.3.0
7
7
  */
8
8
  var http = require('http');
9
9
  var https = require('https');
@@ -32,6 +32,7 @@
32
32
  M.httpProxy = {};// http 代理配置
33
33
  M._sseClientMap=new Map();
34
34
  M._sseHeatTime=3000;
35
+ M._moduleMap=new Map();//模块map
35
36
  M.httpBefore = (d) => {
36
37
  return d
37
38
  }
@@ -41,13 +42,36 @@
41
42
  M._globle_cacheMap = {}
42
43
  //全局对象缓存
43
44
  M._globle_lib_cacheMap={}
45
+ //全局插件地址缓存
46
+ M._globle_plugin_url_cacheMap={};
47
+ //全局插件
48
+ M._globle_plugin=new Set();
44
49
  M._node_lib_path=process.env.NODE_PATH;
45
50
  //远程静态资源路径
46
51
  M.remoteStaticPath = "https://minglie.gitee.io/mingpage/static";
47
52
  M.remoteStaticPathEnable = true;
48
53
  //代理服务器配置
49
54
  M.proxyHost = "http://127.0.0.1:8888"
50
- M.proxyHost = ""
55
+ M.proxyHost = "";
56
+
57
+ M.setModule=function (key,module){
58
+ M._moduleMap.set(key,module);
59
+ }
60
+ M.getModule=function (key){
61
+ M._moduleMap.get(key);
62
+ }
63
+
64
+ M.getGloblePlugin=(pluginKey)=>{
65
+ let plugin=null;
66
+ M._globle_plugin.forEach(u=>{
67
+ if(u.key==pluginKey){
68
+ plugin=u;
69
+ }
70
+ })
71
+ return plugin;
72
+ }
73
+
74
+
51
75
  /**
52
76
  * ----------------------客户端START--------------------------------------------
53
77
  */
@@ -657,13 +681,14 @@ M.request.put=M.put;
657
681
  }
658
682
  }
659
683
  M.writeObjToFile(file, d);
684
+ return d_num;
660
685
  }
661
686
 
662
687
  M.updateObjByIdFile = function (file, obj) {
663
688
  var d = M.getObjByFile(file);
664
689
  for (let i = 0; i < d.length; i++) {
665
690
  if (d[i].id == obj.id) {
666
- d.splice(i, 1, obj);
691
+ d.splice(i, 1, Object.assign(d[i],obj));
667
692
  break;
668
693
  }
669
694
  }
@@ -677,17 +702,28 @@ M.request.put=M.put;
677
702
  }
678
703
  }
679
704
  }
680
- M.listAllObjByPropFile = function (file, o) {
681
- let r_list = [];
682
- let o_key = Object.keys(o)[0];
683
- let o_val = o[o_key]
684
- var d = M.getObjByFile(file);
685
- for (let i = 0; i < d.length; i++) {
686
- if (d[i][o_key] == o_val) {
687
- r_list.push(d[i]);
705
+ M.listAllObjByPropFile = function (file, caseObj) {
706
+ var d = M.getObjByFile(file);
707
+ let o_keys = Object.keys(caseObj);
708
+ if (caseObj && o_keys.length>0) {
709
+ let r_list = [];
710
+ let o_vals = Object.values(caseObj);
711
+ for (let i = 0; i < d.length; i++) {
712
+ let s=0;
713
+ for (let j=0;j<o_keys.length;j++){
714
+ if (d[i][o_keys[j]] != o_vals[j]) {
715
+ break
716
+ }
717
+ s++;
718
+ }
719
+ if(s==o_keys.length){
720
+ r_list.push(d[i]);
721
+ }
688
722
  }
723
+ return r_list;
724
+ } else {
725
+ return d;
689
726
  }
690
- return r_list;
691
727
  }
692
728
  /**
693
729
  * 文件型数据库第二层封装
@@ -976,6 +1012,7 @@ M.getMySql = function (dbConfig) {
976
1012
  timezone: "08:00"
977
1013
  }
978
1014
  var Db = {};
1015
+ Db.dbConfig=defaultDbConfig;
979
1016
  console.log("connect mysql", defaultDbConfig)
980
1017
  var pool = mysql.createPool(defaultDbConfig);
981
1018
  Db.pool=pool;
@@ -1209,8 +1246,9 @@ M.getMongoDB = function (dbConfig) {
1209
1246
  }
1210
1247
 
1211
1248
  }
1212
- MingMongoClient.ObjectID=(id)=> new ObjectID(id)
1213
- let Db=MingMongoClient;
1249
+ MingMongoClient.ObjectID=(id)=> new ObjectID(id)
1250
+ let Db=MingMongoClient;
1251
+ Db.dbConfig=Config;
1214
1252
  MingMongoClient.collectionName="test"
1215
1253
  M.mongoDb=Db;
1216
1254
  return Db;
@@ -1358,6 +1396,40 @@ M.failResult=(msg,code,d)=>{
1358
1396
  M.randomStr = function () {
1359
1397
  return (Math.random().toString(36) + new Date().getTime()).slice(2);
1360
1398
  }
1399
+
1400
+ M.urlStringify = function (obj) {
1401
+ if (obj !== null && typeof obj === 'object') {
1402
+ var keys = Object.keys(obj);
1403
+ var len = keys.length;
1404
+ var flast = len - 1;
1405
+ var fields = '';
1406
+ for (var i = 0; i < len; ++i) {
1407
+ var k = keys[i];
1408
+ var v = obj[k];
1409
+ var ks = k + "=";
1410
+ fields += ks + v;
1411
+ if (i < flast)
1412
+ fields += "&";
1413
+ }
1414
+ return fields;
1415
+ }
1416
+ return '';
1417
+ };
1418
+
1419
+ M.urlParse = function (url) {
1420
+ url = url.substr(url.indexOf("?") + 1);
1421
+ var t, n, r, i = url, s = {};
1422
+ t = i.split("&"),
1423
+ r = null,
1424
+ n = null;
1425
+ for (var o in t) {
1426
+ var u = t[o].indexOf("=");
1427
+ u !== -1 && (r = t[o].substr(0, u),
1428
+ n = t[o].substr(u + 1),
1429
+ s[r] = n)
1430
+ }
1431
+ return s
1432
+ };
1361
1433
 
1362
1434
  /**
1363
1435
  * 异常处理钩子
@@ -1663,16 +1735,43 @@ M.failResult=(msg,code,d)=>{
1663
1735
  G._server = callback;
1664
1736
  }
1665
1737
  app.use=function (url,callback){
1666
- if (Array.isArray(url)) {
1667
- url.forEach(u=>{
1668
- let regExp=new RegExp(u)
1669
- G._use[u] = {url,regExp,callback};
1670
- })
1671
- } else {
1672
- let regExp=new RegExp(url)
1673
- G._use[url] = {url,regExp,callback};
1738
+ if(typeof url === 'function' || typeof url === 'object' ){
1739
+ let plugin=url;
1740
+ let args=callback;
1741
+ if(plugin.installed){
1742
+ return app;
1743
+ }
1744
+ if (typeof plugin === 'function') {
1745
+ plugin(app, args);
1746
+ } else {
1747
+ plugin.install(app, args);
1748
+ }
1749
+ M._globle_plugin.add(plugin);
1750
+ plugin.installed = true;
1751
+ }else {
1752
+ if (Array.isArray(url)) {
1753
+ url.forEach(u=>{
1754
+ let regExp=new RegExp(u)
1755
+ G._use[u] = {url,regExp,callback};
1756
+ })
1757
+ } else {
1758
+ let regExp=new RegExp(url)
1759
+ G._use[url] = {url,regExp,callback};
1760
+ }
1674
1761
  }
1762
+ return app;
1675
1763
  }
1764
+
1765
+ app.installPlugin=async function (pluginUrl,constructorParams,pluginParams){
1766
+ if(M._globle_plugin_url_cacheMap[pluginUrl]){
1767
+ return
1768
+ }
1769
+ M._globle_plugin_url_cacheMap[pluginUrl]=pluginUrl;
1770
+ const Plugin= await M.require(pluginUrl);
1771
+ const plugin= new Plugin(constructorParams);
1772
+ app.use(plugin,pluginParams)
1773
+ }
1774
+
1676
1775
  /**
1677
1776
  * 注册get请求
1678
1777
  */
@@ -1766,9 +1865,8 @@ M.failResult=(msg,code,d)=>{
1766
1865
  app.set("gloable_exception_handle",(err,req,res)=>{
1767
1866
  console.error(err.stack)
1768
1867
  if (res && !res.alreadySend) {
1769
- res.writeHead(500, { "Content-Type": "text/html;charset='utf-8'" });
1770
- res.write("server err");
1771
- res.end();
1868
+ // res.writeHead(500, { "Content-Type": "text/j;charset='utf-8'" });
1869
+ res.send(M.result(err.message,false,-1));
1772
1870
  }
1773
1871
  })
1774
1872
 
@@ -1812,7 +1910,6 @@ M.failResult=(msg,code,d)=>{
1812
1910
  console.log("listen on port:" + port);
1813
1911
  return server;
1814
1912
  }
1815
-
1816
1913
  return app;
1817
1914
  }
1818
1915
  M["_gloable_exception_handle"]=(err)=>{
package/ming_node.md CHANGED
@@ -1001,7 +1001,7 @@ console.log(new Date().format("yyyy-MM-dd"))
1001
1001
  在含有static文件夹的目录执行下面命令,static便作为web根目录
1002
1002
  ```bash
1003
1003
  #node
1004
- curl https://minglie.github.io/js/index.js > index.js && node index.js
1004
+ curl https://minglie.github.io/js/MemoryBaseRpcApi.js > MemoryBaseRpcApi.js && node MemoryBaseRpcApi.js
1005
1005
  #python
1006
1006
  curl https://minglie.github.io/python/index.py > index.py && python index.py
1007
1007
 
@@ -1009,12 +1009,12 @@ curl https://minglie.github.io/python/index.py > index.py && python index.py
1009
1009
  git clone https://github.com/minglie/ming_mockServer.git && cd ming_mockServer && npm i && npm run start
1010
1010
 
1011
1011
  #curl启动ming_mockServer0
1012
- curl https://minglie.gitee.io/mingpage/static/js/ming_mockServer0.js > index.js && node index.js
1012
+ curl https://minglie.gitee.io/mingpage/static/js/ming_mockServer0.js > MemoryBaseRpcApi.js && node MemoryBaseRpcApi.js
1013
1013
 
1014
1014
  ```
1015
1015
  ## 当前目录静态页
1016
1016
  ```javascript
1017
- curl https://minglie.gitee.io/mingpage/static/js/index_cur.js > index.js && node index.js
1017
+ curl https://minglie.gitee.io/mingpage/static/js/index_cur.js > MemoryBaseRpcApi.js && node MemoryBaseRpcApi.js
1018
1018
  ```
1019
1019
  ```javascript
1020
1020
  +async function(){
@@ -1082,7 +1082,7 @@ app.post("/axios", async (req, res) => {
1082
1082
  ## 写web接口最快捷的方式ming_share_edit
1083
1083
  运行脚本, 访问 [http://localhost:8888/](http://localhost:8888/)
1084
1084
  ```bash
1085
- curl https://minglie.gitee.io/mi/i2.js > index.js && node index.js
1085
+ curl https://minglie.gitee.io/mi/i2.js > MemoryBaseRpcApi.js && node MemoryBaseRpcApi.js
1086
1086
  ```
1087
1087
  ![image.png](https://ming-bucket-01.oss-cn-beijing.aliyuncs.com/yuque/1591515706715-62d3b6f6-f113-497f-a532-63792180cd09.png#align=left&display=inline&height=506&margin=%5Bobject%20Object%5D&name=image.png&originHeight=506&originWidth=720&size=65942&status=done&style=none&width=720)
1088
1088
  ## ming_api_mock
@@ -1,9 +1,14 @@
1
- const M=require("ming_node")
2
- const Db=M.getMySql({})
1
+ const M=require("../index")
2
+ const Db=M.getMySql({});
3
3
 
4
4
  class BaseMapper {
5
+
6
+ //static BaseMapperMap=new Map();
7
+
5
8
  constructor(tableName) {
6
9
  this.tableName =tableName;
10
+ this.tableSchema=null;
11
+ //BaseMapper.BaseMapperMap.set(tableName,this);
7
12
  }
8
13
 
9
14
  /**
@@ -12,6 +17,7 @@ class BaseMapper {
12
17
  * @returns {Promise<*>}
13
18
  */
14
19
  async insert(obj){
20
+ delete obj.id;
15
21
  let sql= BaseMapper.getInsertObjSql(this.tableName,obj)
16
22
  let r=await Db.doSql(sql);
17
23
  return r;
@@ -52,7 +58,7 @@ class BaseMapper {
52
58
  }
53
59
 
54
60
  /**
55
- *根据条件改
61
+ * 删除
56
62
  * @param caseStr
57
63
  * @returns {Promise<*>}
58
64
  */
@@ -139,7 +145,7 @@ class BaseMapper {
139
145
  let dataList=await Db.doSql(`SELECT ${queryColumn} FROM ${this.tableName} where ${whereCase} order by ${order} LIMIT ${start},${num}`)
140
146
  let totalR=await Db.doSql(`SELECT count(1) c FROM ${this.tableName} where ${whereCase}`)
141
147
  let total=totalR[0].c
142
- return {dataList,total};
148
+ return {rows:dataList,total};
143
149
  }
144
150
 
145
151
  /**
@@ -157,6 +163,23 @@ class BaseMapper {
157
163
  return dataList;
158
164
  }
159
165
 
166
+
167
+ /**
168
+ * 分页查
169
+ * @param page
170
+ * @param num
171
+ * @param queryCase
172
+ * @param columns
173
+ * @param order
174
+ */
175
+ async selectPurePageList({page=1,num=10,queryCase="1=1", columns="*",order="id desc"}){
176
+ let start = (page - 1) * num;
177
+ let whereCase=queryCase;
178
+ let queryColumn=BaseMapper.getColumn(columns);
179
+ let dataList=await Db.doSql(`SELECT ${queryColumn} FROM ${this.tableName} where ${whereCase} order by ${order} LIMIT ${start},${num}`)
180
+ return dataList;
181
+ }
182
+
160
183
  /**
161
184
  * 查后代
162
185
  * @param parent_id
@@ -213,6 +236,14 @@ class BaseMapper {
213
236
  return rootList;
214
237
  }
215
238
 
239
+ async getTableSchema(){
240
+ if(this.tableSchema==null){
241
+ let dataBaseName=Db.dbConfig.database;
242
+ let sql=`select column_name,column_type,column_comment from information_schema.columns where table_schema ='${dataBaseName}' and table_name = '${this.tableName}';`
243
+ let tableSchema=await Db.doSql(sql);
244
+ return tableSchema;
245
+ }
246
+ }
216
247
 
217
248
 
218
249
  static getColumn(columns){
@@ -289,6 +320,8 @@ class BaseMapper {
289
320
  return sql;
290
321
  }
291
322
 
323
+
324
+
292
325
  }
293
326
 
294
327