'use strict'; const { CrudService } = require('naf-framework-mongoose/lib/service'); const { BusinessError, ErrorCode } = require('naf-core').Error; const _ = require('lodash'); const assert = require('assert'); // 统计 class StatisticsService extends CrudService { constructor(ctx) { super(ctx, 'statistics'); this.httpUtil = this.ctx.service.util.httpUtil; this.project = this.app.config.project; } async users() { // 需要访问两个地方,1个是正常9201的main中的service,另一个是9101的live中的统计 const url1 = `${this.project.main}/statistics/users`; const url2 = `${this.project.live}/api/live/v0/statistics/index/orgCount`; // 带条件就直接写 let obj = {}; const res1 = await this.httpUtil.$get(url1); if (res1.errcode === 0) { obj = res1; } else { obj = res1; return obj; } const res2 = await this.httpUtil.$get(url2); if (res2.errcode === 0) { obj.data.push({ name: '企业用户', value: res2.data }); } else { obj = res2; return obj; } return obj; } async policyApply() { const url = `${this.project.live}/api/live/v0/statistics/index/pac`; return await this.httpUtil.$get(url); } async declare() { const url = `${this.project.live}/api/live/v0/statistics/index/declare`; return await this.httpUtil.$get(url); } } module.exports = StatisticsService;