Browse Source

bug:ref解析错误

lrf 2 năm trước cách đây
mục cha
commit
80ccc3302a

+ 3 - 2
src/service/BaseService.ts

@@ -142,8 +142,9 @@ export abstract class BaseService<T extends AnyParamConstructor<any>> {
     const refs = [];
     const refs = [];
     for (const key in schema) {
     for (const key in schema) {
       const f = schema[key];
       const f = schema[key];
-      if (_.isObject(f) && _.get(f, 'ref')) {
-        const model = GetModel(key);
+      const ref = _.get(f, 'ref');
+      if (ref) {
+        const model = GetModel(ref);
         const path = key;
         const path = key;
         refs.push({ path, model });
         refs.push({ path, model });
       }
       }

+ 2 - 2
src/util/getModel.ts

@@ -9,10 +9,10 @@ export function GetModel(modelName) {
       getClass(_.upperFirst(modelName)) as AnyParamConstructor<any>
       getClass(_.upperFirst(modelName)) as AnyParamConstructor<any>
     );
     );
   } catch (error) {
   } catch (error) {
-    throw new ServiceError('生成模型错误', FrameworkErrorEnum.SERVICE_FAULT);
+    throw new ServiceError(`${modelName}-生成模型错误`, FrameworkErrorEnum.SERVICE_FAULT);
   }
   }
   if (!model)
   if (!model)
-    throw new ServiceError('未找到模型', FrameworkErrorEnum.SERVICE_FAULT);
+    throw new ServiceError(`${modelName}-未找到模型`, FrameworkErrorEnum.SERVICE_FAULT);
 
 
   return model;
   return model;
 }
 }