tenant-use.js 581 B

12345678910111213141516
  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. // await this.tenantIsUse(ctx);
  14. await next();
  15. };
  16. };