去除无用代码,新增demo示例

This commit is contained in:
啊平 2021-03-12 18:55:47 +08:00
parent 292a02a352
commit a66d67cf64
3 changed files with 41 additions and 3 deletions

View File

@ -1,6 +1,7 @@
import { Provide } from '@midwayjs/decorator'; import { Get, Inject, Provide } from '@midwayjs/decorator';
import { CoolController, BaseController } from 'midwayjs-cool-core'; import { CoolController, BaseController } from 'midwayjs-cool-core';
import { DemoAppGoodsEntity } from '../../entity/goods'; import { DemoAppGoodsEntity } from '../../entity/goods';
import { DemoGoodsService } from '../../service/goods';
/** /**
* *
@ -10,4 +11,16 @@ import { DemoAppGoodsEntity } from '../../entity/goods';
api: ['add', 'delete', 'update', 'info', 'list', 'page'], api: ['add', 'delete', 'update', 'info', 'list', 'page'],
entity: DemoAppGoodsEntity, entity: DemoAppGoodsEntity,
}) })
export class DemoAppGoodsController extends BaseController {} export class DemoAppGoodsController extends BaseController {
@Inject()
demoGoodsService: DemoGoodsService;
/**
*
* @returns
*/
@Get('/all')
async all() {
return this.ok(await this.demoGoodsService.all());
}
}

View File

@ -0,0 +1,26 @@
import { Inject, Provide } from '@midwayjs/decorator';
import { BaseService, Cache } from 'midwayjs-cool-core';
import { InjectEntityModel } from '@midwayjs/orm';
import { Repository } from 'typeorm';
import { DemoAppGoodsEntity } from '../entity/goods';
import { ICoolCache } from 'midwayjs-cool-core';
/**
*
*/
@Provide()
export class DemoGoodsService extends BaseService {
@InjectEntityModel(DemoAppGoodsEntity)
demoAppGoodsEntity: Repository<DemoAppGoodsEntity>;
@Inject('cool:cache')
coolCache: ICoolCache;
/**
*
*/
@Cache(5)
async all() {
return this.demoAppGoodsEntity.find();
}
}

View File

@ -36,7 +36,6 @@ export class ContainerLifeCycle implements ILifeCycle {
app: Application; app: Application;
// 应用启动完成 // 应用启动完成
async onReady(container?: IMidwayContainer) { async onReady(container?: IMidwayContainer) {
console.log(container.baseDir);
} }
// 应用停止 // 应用停止
async onStop() {} async onStop() {}