mirror of
https://github.com/certd/certd.git
synced 2026-05-17 13:57:31 +08:00
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
|
|
import { Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||
|
|
import { PipelineService } from '../../pipeline/service/pipeline-service.js';
|
||
|
|
import { CertInfoService } from '../../monitor/service/cert-info-service.js';
|
||
|
|
import { IUsedCountService } from '@certd/commercial-core';
|
||
|
|
import { SiteInfoService } from '../../monitor/service/site-info-service.js';
|
||
|
|
|
||
|
|
@Provide('myCountService')
|
||
|
|
@Scope(ScopeEnum.Request, { allowDowngrade: true })
|
||
|
|
export class MyCountService implements IUsedCountService {
|
||
|
|
@Inject()
|
||
|
|
pipelineService: PipelineService;
|
||
|
|
|
||
|
|
@Inject()
|
||
|
|
certInfoService: CertInfoService;
|
||
|
|
@Inject()
|
||
|
|
siteInfoService: SiteInfoService;
|
||
|
|
|
||
|
|
async getUsedCount(userId: number) {
|
||
|
|
if (!userId) {
|
||
|
|
throw new Error('userId is required');
|
||
|
|
}
|
||
|
|
const pipelineCountUsed = await this.pipelineService.getUserPipelineCount(userId);
|
||
|
|
const domainCountUsed = await this.certInfoService.getUserDomainCount(userId);
|
||
|
|
const monitorCountUsed = await this.siteInfoService.getUserMonitorCount(userId);
|
||
|
|
return {
|
||
|
|
pipelineCountUsed,
|
||
|
|
domainCountUsed,
|
||
|
|
monitorCountUsed,
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|