mirror of
https://github.com/certd/certd.git
synced 2025-11-25 09:10:11 +08:00
perf: 管理控制台数据统计
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ALL, Body, Controller, Inject, Post, Provide } from '@midwayjs/core';
|
||||
import { Controller, Inject, Post, Provide } from '@midwayjs/core';
|
||||
import { BaseController, Constants } from '@certd/lib-server';
|
||||
import { UserService } from '../../modules/sys/authority/service/user-service.js';
|
||||
import { RoleService } from '../../modules/sys/authority/service/role-service.js';
|
||||
@@ -12,7 +12,7 @@ export type ChartItem = {
|
||||
export type UserStatisticCount = {
|
||||
pipelineCount?: number;
|
||||
pipelineStatusCount?: ChartItem[];
|
||||
runningCount: ChartItem[];
|
||||
historyCountPerDay: ChartItem[];
|
||||
expiringList: any[];
|
||||
};
|
||||
/**
|
||||
@@ -33,36 +33,15 @@ export class StatisticController extends BaseController {
|
||||
@Post('/count', { summary: Constants.per.authOnly })
|
||||
public async count() {
|
||||
const pipelineCount = await this.pipelineService.count({ userId: this.getUserId() });
|
||||
let pipelineStatusCount = await this.pipelineService.statusCount({ userId: this.getUserId() });
|
||||
pipelineStatusCount = pipelineStatusCount.map(item => {
|
||||
return {
|
||||
name: item.status,
|
||||
value: item.count,
|
||||
};
|
||||
});
|
||||
|
||||
const historyCount = await this.historyService.dayCount({ userId: this.getUserId(), days: 7 });
|
||||
const runningCount = historyCount.map(item => {
|
||||
return {
|
||||
name: item.date,
|
||||
value: item.count,
|
||||
};
|
||||
});
|
||||
|
||||
const pipelineStatusCount = await this.pipelineService.statusCount({ userId: this.getUserId() });
|
||||
const historyCount = await this.historyService.countPerDay({ userId: this.getUserId(), days: 7 });
|
||||
const expiringList = await this.pipelineService.latestExpiringList({ userId: this.getUserId(), count: 5 });
|
||||
const count: UserStatisticCount = {
|
||||
pipelineCount,
|
||||
pipelineStatusCount,
|
||||
runningCount,
|
||||
historyCountPerDay: historyCount,
|
||||
expiringList,
|
||||
};
|
||||
return this.ok(count);
|
||||
}
|
||||
|
||||
@Post('/changePassword', { summary: Constants.per.authOnly })
|
||||
public async changePassword(@Body(ALL) body: any) {
|
||||
const userId = this.getUserId();
|
||||
await this.userService.changePassword(userId, body);
|
||||
return this.ok({});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user