mm_dbs 1.0.1 → 1.0.2

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.
Files changed (2) hide show
  1. package/lib/db.js +22 -2
  2. package/package.json +1 -1
package/lib/db.js CHANGED
@@ -5,7 +5,7 @@ const { string, array, object, file } = require('mm_helper');
5
5
 
6
6
  /** 关键词搜索默认SQL模板(用户表关联查询) */
7
7
  const KEYWORD_DEFAULT =
8
- "`user_id` in (SELECT `user_id` FROM `user_account` WHERE `nickname` LIKE '%{0}%' OR `phone` LIKE '%{0}%' OR `wallet_address` LIKE '%{0}%')";
8
+ "`user_id` in (SELECT `user_id` FROM `sys_user` WHERE `nickname` LIKE '%{0}%' OR `phone` LIKE '%{0}%' OR `wallet_address` LIKE '%{0}%')";
9
9
 
10
10
  /** 关键词搜索默认提示 */
11
11
  const KEYWORD_DEFAULT_TIP = '昵称、手机号、钱包地址';
@@ -970,13 +970,33 @@ Db.prototype._getEventApi = function () {
970
970
  if (typeof getter === 'function') {
971
971
  return getter();
972
972
  }
973
+ var admin = this._getHostApiAdmin();
974
+ if (admin) {
975
+ return admin;
976
+ }
973
977
  if (!this._event_api_warned) {
974
978
  this._event_api_warned = true;
975
- this.log('warn', '未配置 get_event_api,API目录判断使用默认路径');
979
+ this.log('warn', '未配置 get_event_api 且宿主API管理器不可用,API目录判断使用默认路径');
976
980
  }
977
981
  return null;
978
982
  };
979
983
 
984
+ /**
985
+ * 获取宿主API管理器工厂(未注入 get_event_api 时的回退)
986
+ * @returns {object|null} 支持按作用域取管理器的工厂;宿主不可用时返回null
987
+ * @private
988
+ */
989
+ Db.prototype._getHostApiAdmin = function () {
990
+ var manager = this.parent;
991
+ var server = manager && typeof manager.getServer === 'function' ? manager.getServer() : null;
992
+ var container = server && server.container;
993
+ if (!container) {
994
+ return null;
995
+ }
996
+ var factory = container.get('api_admin');
997
+ return factory && typeof factory.get === 'function' ? factory : null;
998
+ };
999
+
980
1000
  /**
981
1001
  * 处理配置文件
982
1002
  * @param {string} f 文件路径
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_dbs",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "数据库框架,通过设计数据库生成sql模板,或通过db.json配置文件生成mysql数据表(基于 mm_corejs,内置管理器池,无全局/原型扩展依赖)",
5
5
  "main": "index.js",
6
6
  "keywords": [