|
@@ -38,13 +38,14 @@ const ModelContext = (data) => {
|
|
};
|
|
};
|
|
const ServiceContext = (data) => {
|
|
const ServiceContext = (data) => {
|
|
const fc = [];
|
|
const fc = [];
|
|
- const { name: table_name } = data;
|
|
|
|
|
|
+ const { name: table_name, getPath } = data;
|
|
const prefix = _.upperFirst(table_name);
|
|
const prefix = _.upperFirst(table_name);
|
|
|
|
+ const entityPath = getPath('entity');
|
|
fc.push(`import { Provide } from '@midwayjs/decorator';`);
|
|
fc.push(`import { Provide } from '@midwayjs/decorator';`);
|
|
fc.push(`import { InjectEntityModel } from '@midwayjs/typegoose';`);
|
|
fc.push(`import { InjectEntityModel } from '@midwayjs/typegoose';`);
|
|
fc.push(`import { ReturnModelType } from '@typegoose/typegoose';`);
|
|
fc.push(`import { ReturnModelType } from '@typegoose/typegoose';`);
|
|
fc.push(`import { BaseService } from 'free-midway-component';`);
|
|
fc.push(`import { BaseService } from 'free-midway-component';`);
|
|
- fc.push(`import { ${prefix} } from '../entity/${_.lowerFirst(table_name)}.entity';`);
|
|
|
|
|
|
+ fc.push(`import { ${prefix} } from '${entityPath}';`);
|
|
fc.push(`type modelType = ReturnModelType<typeof ${prefix}>;`);
|
|
fc.push(`type modelType = ReturnModelType<typeof ${prefix}>;`);
|
|
fc.push(`@Provide()`);
|
|
fc.push(`@Provide()`);
|
|
fc.push(`export class ${prefix}Service extends BaseService<modelType> {`);
|
|
fc.push(`export class ${prefix}Service extends BaseService<modelType> {`);
|
|
@@ -55,12 +56,14 @@ const ServiceContext = (data) => {
|
|
};
|
|
};
|
|
const ControllerContext = (data) => {
|
|
const ControllerContext = (data) => {
|
|
const fc = [];
|
|
const fc = [];
|
|
- const { name, name_zh } = data;
|
|
|
|
|
|
+ const { name, name_zh, getPath } = data;
|
|
const prefix = _.upperFirst(name);
|
|
const prefix = _.upperFirst(name);
|
|
|
|
+ const servicePath = getPath('service');
|
|
|
|
+ const interfacePath = getPath('interface');
|
|
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/${_.lowerFirst(name)}.service';`);
|
|
|
|
- fc.push(`import { CDTO_${name}, CVO_${name}, FVO_${name},QDTO_${name}, QVO_${name}, UDTO_${name}, UVAO_${name} } from '../interface/${_.lowerFirst(name)}.interface';`);
|
|
|
|
|
|
+ fc.push(`import { ${prefix}Service } from '${servicePath}';`);
|
|
|
|
+ fc.push(`import { CDTO_${name}, CVO_${name}, FVO_${name},QDTO_${name}, QVO_${name}, UDTO_${name}, UVAO_${name} } from '${interfacePath}';`);
|
|
fc.push(`import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';`);
|
|
fc.push(`import { ApiResponse, ApiTags, ApiQuery } 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}'])`);
|