|
@@ -139,7 +139,7 @@ const getInterfaceColumn = (col, needReq = false) => {
|
|
|
if (type === 'Money' || type === 'money') rt = 'number';
|
|
|
else rt = _.lowerFirst(type);
|
|
|
if (required) ruleStr = `@Rule(RuleType['${rt}']().required().error(new ServiceError('缺少${zh}',FrameworkErrorEnum.${needReq ? 'NEED_BODY' : 'NEED_QUERY'})))`;
|
|
|
- else ruleStr = `@Rule(RuleType['${rt}']().empty())`;
|
|
|
+ else ruleStr = `@Rule(RuleType['${rt}']().empty(''))`;
|
|
|
fc.push(ruleStr);
|
|
|
}
|
|
|
fc.push(` '${title}': ${modelType} = undefined;`);
|
|
@@ -149,10 +149,12 @@ const getInterfaceColumn = (col, needReq = false) => {
|
|
|
const interfaceContext = (data) => {
|
|
|
const fc = [];
|
|
|
const { columns = [], name } = data;
|
|
|
+ const have_required = columns.find((f) => f.required);
|
|
|
fc.push(`import { Rule, RuleType } from '@midwayjs/validate';`);
|
|
|
fc.push(`import { ApiProperty } from '@midwayjs/swagger';`);
|
|
|
fc.push(`import _ = require('lodash');`);
|
|
|
- fc.push(`import { FrameworkErrorEnum, SearchBase, ServiceError } from 'free-midway-component';`);
|
|
|
+ if (have_required) fc.push(`import { FrameworkErrorEnum, SearchBase, ServiceError } from 'free-midway-component';`);
|
|
|
+ else fc.push(`import { SearchBase } from 'free-midway-component';`);
|
|
|
fc.push(`export class FetchVO_${name} {`);
|
|
|
fc.push(` constructor(data: object) {`);
|
|
|
fc.push(` for (const key of Object.keys(this)) {`);
|
|
@@ -194,7 +196,7 @@ const interfaceContext = (data) => {
|
|
|
fc.push(`\n`);
|
|
|
fc.push(`export class UpdateDTO_${name} extends CreateDTO_${name} {
|
|
|
@ApiProperty({ description: '数据id' })
|
|
|
- @Rule(RuleType['string']().empty())
|
|
|
+ @Rule(RuleType['string']().empty(''))
|
|
|
_id: string = undefined;
|
|
|
}`);
|
|
|
fc.push(`\n`);
|