tenant-use.js 635 B

1234567891011121314151617
  1. 'use strict';
  2. const _ = require('lodash');
  3. const { BusinessError, ErrorCode } = require('naf-core').Error;
  4. const tenantIsUse = async ctx => {
  5. const _tenant = ctx.tenant;
  6. const res = await ctx.model.System.Tenant.findOne({ _tenant });
  7. if (!res) throw new BusinessError(ErrorCode.SERVICE_FAULT, '该分站未开通!');
  8. if (!res.is_use) throw new BusinessError(ErrorCode.SERVICE_FAULT, '该分站处于关闭状态!');
  9. return true;
  10. };
  11. module.exports = options => {
  12. return async function tenantUse(ctx, next) {
  13. console.log('function in tenant-use middleware');
  14. // await this.tenantIsUse(ctx);
  15. await next();
  16. };
  17. };