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