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

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

@@ -70,30 +70,30 @@ const ControllerContext = (data) => {
   fc.push(`  service: ${prefix}Service;`);
   fc.push('\n');
   // create
-  fc.push(`@Post('/') @Validate() @ApiResponse({ type: CVO })`);
-  fc.push(`  async create(@Body() data: CDTO) {`);
+  fc.push(`@Post('/') @Validate() @ApiResponse({ type: CVO_${name} })`);
+  fc.push(`  async create(@Body() data: CDTO_${name}) {`);
   fc.push(`    const result = await this.service.create(data);`);
   fc.push(`    return result;`);
   fc.push(`  }`);
   // query
-  fc.push(`@Get('/')@ApiQuery({name:'query'})@ApiResponse({ type: QVO })`);
-  fc.push(`  async query(@Query() filter:QDTO, @Query('skip') skip: number,@Query('limit') limit: number){`);
+  fc.push(`@Get('/')@ApiQuery({name:'query'})@ApiResponse({ type: QVO_${name} })`);
+  fc.push(`  async query(@Query() filter:QDTO_${name}, @Query('skip') skip: number,@Query('limit') limit: number){`);
   fc.push(`    const data = await this.service.query(filter, { skip, limit });`);
   fc.push(`    const total = await this.service.count(filter);`);
   fc.push(`    return { data, total };`);
   fc.push(`  }`);
   fc.push(`\n`);
   // fetch
-  fc.push(`@Get('/:id')@ApiResponse({ type: FVO })`);
+  fc.push(`@Get('/:id')@ApiResponse({ type: FVO_${name} })`);
   fc.push(`  async fetch(@Param('id') id: string) {`);
   fc.push(`    const data = await this.service.fetch(id);`);
-  fc.push(`    const result = new FVO(data);`);
+  fc.push(`    const result = new FVO_${name}(data);`);
   fc.push(`    return result;`);
   fc.push(`  }`);
   fc.push(`\n`);
   // update
-  fc.push(`@Post('/:id')@Validate()@ApiResponse({ type: UVAO })`);
-  fc.push(`  async update(@Param('id') id: string, @Body() body: UDTO) {`);
+  fc.push(`@Post('/:id')@Validate()@ApiResponse({ type: UVAO_${name} })`);
+  fc.push(`  async update(@Param('id') id: string, @Body() body: UDTO_${name}) {`);
   fc.push(`    const result = await this.service.updateOne(id, body);`);
   fc.push(`    return result;`);
   fc.push(`  }`);
@@ -153,7 +153,7 @@ const interfaceContext = (data) => {
   fc.push(`import _ = require('lodash');`);
   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 FVO {`);
+  fc.push(`export class FVO_${name} {`);
   fc.push(`  @ApiProperty({ description: '数据id' })`);
   fc.push(`  _id: string = undefined;`);
   for (const col of columns) {
@@ -164,7 +164,7 @@ const interfaceContext = (data) => {
   fc.push(`\n`);
   const indexs = columns.filter((f) => f.index);
   const props = indexs.map((i) => `'${i.title}'`).join(', ');
-  fc.push(`export class QDTO extends SearchBase {`);
+  fc.push(`export class QDTO_${name} extends SearchBase {`);
   fc.push(`  constructor() {`);
   fc.push(`    const like_prop = [];`);
   fc.push(`    const props = [${props}];`);
@@ -177,24 +177,24 @@ const interfaceContext = (data) => {
   }
   fc.push(`}`);
   fc.push(`\n`);
-  fc.push(`export class QVO extends FVO {}`);
+  fc.push(`export class QVO_${name} extends FVO_${name} {}`);
   fc.push(`\n`);
-  fc.push(`export class CDTO {`);
+  fc.push(`export class CDTO_${name} {`);
   for (const col of columns) {
     const cfc = getInterfaceColumn(col, true);
     fc.push(...cfc);
   }
   fc.push(`}`);
   fc.push(`\n`);
-  fc.push(`export class CVO extends FVO {}`);
+  fc.push(`export class CVO_${name} extends FVO_${name} {}`);
   fc.push(`\n`);
-  fc.push(`export class UDTO extends CDTO {
+  fc.push(`export class UDTO_${name} extends CDTO_${name} {
     @ApiProperty({ description: '数据id' })
     @Rule(RuleType['string']().empty(''))
     _id: string = undefined;
 }`);
   fc.push(`\n`);
-  fc.push(`export class UVAO extends FVO {}`);
+  fc.push(`export class UVAO_${name} extends FVO_${name} {}`);
   return fc.join('\n');
 };