naf-service.js 509 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const assert = require('assert');
  3. const Service = require('egg').Service;
  4. class NafService extends Service {
  5. constructor(ctx, name) {
  6. super(ctx);
  7. this.name = name;
  8. }
  9. get tenant() {
  10. return this.ctx.tenant;
  11. }
  12. set tenant(value) {
  13. this.ctx.tenant = value;
  14. }
  15. async nextId(seqName) {
  16. assert(this.name);
  17. const { seq } = this.ctx.service;
  18. const value = await seq.nextVal(seqName || this.name);
  19. return value;
  20. }
  21. }
  22. module.exports.NafService = NafService;