123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- '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 ticket() {
- const url = `${this.project.live}/api/live/v0/statistics/index/ticket`;
- return await this.httpUtil.$get(url);
- }
- }
- module.exports = StatisticsService;
|