浏览代码

ts template

lrf 2 年之前
父节点
当前提交
0d80c87cf6
共有 1 个文件被更改,包括 5 次插入5 次删除
  1. 5 5
      app/public/ts-template.js

+ 5 - 5
app/public/ts-template.js

@@ -53,18 +53,18 @@ const ServiceContext = (data) => {
 };
 const ControllerContext = (data) => {
   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 { 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(
     `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 { Validate } from '@midwayjs/validate';`);
   fc.push(`@ApiTags(['${name_zh}'])`);
-  fc.push(`@Controller('/${table_name}')`);
+  fc.push(`@Controller('/${name}')`);
   fc.push(`export class ${prefix}Controller extends BaseController {`);
   fc.push(`  @Inject()`);
   fc.push(`  service: ${prefix}Service;`);
@@ -141,7 +141,7 @@ const getInterfaceColumn = (col, needReq = false) => {
 
 const interfaceContext = (data) => {
   const fc = [];
-  const { columns = [],name } = data;
+  const { columns = [], name } = data;
   fc.push(`import { Rule, RuleType } from '@midwayjs/validate';`);
   fc.push(`import { ApiProperty } from '@midwayjs/swagger';`);
   fc.push(`import _ = require('lodash');`);