mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2025-12-29 05:10:17 +00:00
去除无用代码,新增demo示例
This commit is contained in:
parent
292a02a352
commit
a66d67cf64
@ -1,6 +1,7 @@
|
||||
import { Provide } from '@midwayjs/decorator';
|
||||
import { Get, Inject, Provide } from '@midwayjs/decorator';
|
||||
import { CoolController, BaseController } from 'midwayjs-cool-core';
|
||||
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'],
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
26
src/app/modules/demo/service/goods.ts
Normal file
26
src/app/modules/demo/service/goods.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
@ -36,7 +36,6 @@ export class ContainerLifeCycle implements ILifeCycle {
|
||||
app: Application;
|
||||
// 应用启动完成
|
||||
async onReady(container?: IMidwayContainer) {
|
||||
console.log(container.baseDir);
|
||||
}
|
||||
// 应用停止
|
||||
async onStop() {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user