1
0

base.ts 584 B

12345678910111213141516171819202122232425262728293031
  1. import { Service } from 'egg';
  2. export default class BaseService extends Service {
  3. /**
  4. * 所有实体会加载在ctx.entities中, 所有仓库会加载到ctx.repo;
  5. * 多数据库时加载在对应的ctx.entities[connectName]与ctx.repo[connectionName]上;
  6. * 详见typings/typeorm.d.ts文件
  7. */
  8. getRepo() {
  9. return this.ctx.repo;
  10. }
  11. getEntity() {
  12. return this.ctx.entity;
  13. }
  14. /**
  15. * 获取Helper
  16. */
  17. getHelper() {
  18. return this.ctx.helper;
  19. }
  20. /**
  21. * admin redis
  22. */
  23. getAdminRedis() {
  24. return this.app.redis.get('admin') as any;
  25. }
  26. }