feat: 首页全新改版

This commit is contained in:
xiaojunnuo
2024-10-31 15:14:56 +08:00
parent e5e468a463
commit 63ec5b5519
14 changed files with 492 additions and 53 deletions

View File

@@ -0,0 +1,68 @@
import { ALL, Body, 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';
import { PipelineService } from '../../modules/pipeline/service/pipeline-service.js';
import { HistoryService } from '../../modules/pipeline/service/history-service.js';
export type ChartItem = {
name: string;
value: number;
};
export type UserStatisticCount = {
pipelineCount?: number;
pipelineStatusCount?: ChartItem[];
runningCount: ChartItem[];
expiringList: any[];
};
/**
*/
@Provide()
@Controller('/api/statistic/')
export class StatisticController extends BaseController {
@Inject()
userService: UserService;
@Inject()
roleService: RoleService;
@Inject()
pipelineService: PipelineService;
@Inject()
historyService: HistoryService;
@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 expiringList = await this.pipelineService.latestExpiringList({ userId: this.getUserId(), count: 5 });
const count: UserStatisticCount = {
pipelineCount,
pipelineStatusCount,
runningCount,
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({});
}
}