lrf402788946 4 lat temu
rodzic
commit
c0f8ce8bfb

+ 12 - 0
lib/plugin/egg-multi-tenancy/app/extend/application.js

@@ -90,6 +90,18 @@ const loadModel2 = (app, tenant) => {
   return model;
 };
 
+const getAllModel = data => {
+  if(_.isFunction(data)) return data;
+  const keys = Object.keys(data);
+  const arr = [];
+  for (const key of keys) {
+    const model = data[key];
+    if(_.isFunction(model)) arr.push(model)
+    else arr.push(...getAllModel(model))
+  }
+  return arr;
+}
+
 // this 就是 app 对象,在其中可以调用 app 上的其他方法,或访问属性
 module.exports = {