소스 검색

ts template

lrf 2 년 전
부모
커밋
7415d8a97a
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 2
      app/public/ts-template.js

+ 4 - 2
app/public/ts-template.js

@@ -132,8 +132,10 @@ const getInterfaceColumn = (col, needReq = false) => {
   const { type, zh, title, required } = col;
   const modelType = getModelType(type);
   fc.push(`  @ApiProperty({ description: '${title}' })`);
-  if (needReq && required) {
-    const ruleStr = `@Rule(RuleType['${modelType}']().required().error(new ServiceError('缺少${zh}',FrameworkErrorEnum.${needReq ? 'NEED_BODY' : 'NEED_QUERY'})))`;
+  if (needReq) {
+    let ruleStr = '';
+    if (required) ruleStr = `@Rule(RuleType['${modelType}']().required().error(new ServiceError('缺少${zh}',FrameworkErrorEnum.${needReq ? 'NEED_BODY' : 'NEED_QUERY'})))`;
+    else ruleStr = `@Rule(RuleType['${modelType}'].empty())`;
     fc.push(ruleStr);
   }
   fc.push(`  '${title}': ${modelType} = undefined;`);