|
@@ -53,18 +53,18 @@ const ServiceContext = (data) => {
|
|
};
|
|
};
|
|
const ControllerContext = (data) => {
|
|
const ControllerContext = (data) => {
|
|
const fc = [];
|
|
const fc = [];
|
|
- const { name: table_name, name_zh } = data;
|
|
|
|
- const prefix = _.upperFirst(table_name);
|
|
|
|
|
|
+ const { name, name_zh } = data;
|
|
|
|
+ const prefix = _.upperFirst(name);
|
|
fc.push(`import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';`);
|
|
fc.push(`import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';`);
|
|
fc.push(`import { BaseController } from 'free-midway-component';`);
|
|
fc.push(`import { BaseController } from 'free-midway-component';`);
|
|
- fc.push(`import { ${prefix}Service } from '../service/${table_name}.service';`);
|
|
|
|
|
|
+ fc.push(`import { ${prefix}Service } from '../service/${name}.service';`);
|
|
fc.push(
|
|
fc.push(
|
|
`import { CreateDTO_${name}, CreateVO_${name}, FetchVO_${name}, QueryDTO_${name}, QueryVO_${name}, UpdateDTO_${name}, UpdateVO_${name} } from '../interface/${table_name}.interface';`
|
|
`import { CreateDTO_${name}, CreateVO_${name}, FetchVO_${name}, QueryDTO_${name}, QueryVO_${name}, UpdateDTO_${name}, UpdateVO_${name} } from '../interface/${table_name}.interface';`
|
|
);
|
|
);
|
|
fc.push(`import { ApiResponse, ApiTags } from '@midwayjs/swagger';`);
|
|
fc.push(`import { ApiResponse, ApiTags } from '@midwayjs/swagger';`);
|
|
fc.push(`import { Validate } from '@midwayjs/validate';`);
|
|
fc.push(`import { Validate } from '@midwayjs/validate';`);
|
|
fc.push(`@ApiTags(['${name_zh}'])`);
|
|
fc.push(`@ApiTags(['${name_zh}'])`);
|
|
- fc.push(`@Controller('/${table_name}')`);
|
|
|
|
|
|
+ fc.push(`@Controller('/${name}')`);
|
|
fc.push(`export class ${prefix}Controller extends BaseController {`);
|
|
fc.push(`export class ${prefix}Controller extends BaseController {`);
|
|
fc.push(` @Inject()`);
|
|
fc.push(` @Inject()`);
|
|
fc.push(` service: ${prefix}Service;`);
|
|
fc.push(` service: ${prefix}Service;`);
|
|
@@ -141,7 +141,7 @@ const getInterfaceColumn = (col, needReq = false) => {
|
|
|
|
|
|
const interfaceContext = (data) => {
|
|
const interfaceContext = (data) => {
|
|
const fc = [];
|
|
const fc = [];
|
|
- const { columns = [],name } = data;
|
|
|
|
|
|
+ const { columns = [], name } = data;
|
|
fc.push(`import { Rule, RuleType } from '@midwayjs/validate';`);
|
|
fc.push(`import { Rule, RuleType } from '@midwayjs/validate';`);
|
|
fc.push(`import { ApiProperty } from '@midwayjs/swagger';`);
|
|
fc.push(`import { ApiProperty } from '@midwayjs/swagger';`);
|
|
fc.push(`import _ = require('lodash');`);
|
|
fc.push(`import _ = require('lodash');`);
|