| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- /**
- * 数据看板与经营复盘模块 — 控制器层
- *
- * 对应规范文档 §十一「模块 8:数据看板与经营复盘模块」
- */
- import type { Request, Response } from 'express';
- import { sendSuccess } from '../../../../shared/http/response.js';
- import {
- getOverviewDashboard,
- getCommunityDashboard,
- getStoreDashboard,
- getActivityIndex,
- getActivityRanking,
- generatePeriodicReport,
- } from '../services/dashboard.service.js';
- /** GET /api/dashboard/overview — 总览看板(§11.1) */
- export async function overview(_req: Request, res: Response): Promise<void> {
- try {
- const data = getOverviewDashboard();
- sendSuccess(res, data);
- } catch (error) {
- throw error;
- }
- }
- /** GET /api/dashboard/community/:communityId — 小区看板(§11.2) */
- export async function communityDashboard(req: Request, res: Response): Promise<void> {
- try {
- const communityId = Number(req.params.communityId);
- const data = getCommunityDashboard(communityId);
- sendSuccess(res, data);
- } catch (error) {
- throw error;
- }
- }
- /** GET /api/dashboard/store/:storeId — 门店看板(§11.3) */
- export async function storeDashboard(req: Request, res: Response): Promise<void> {
- try {
- const storeId = Number(req.params.storeId);
- const data = getStoreDashboard(storeId);
- sendSuccess(res, data);
- } catch (error) {
- throw error;
- }
- }
- /** GET /api/dashboard/activity/:roomId — 群活跃度指数(§11.4) */
- export async function activityIndex(req: Request, res: Response): Promise<void> {
- try {
- const roomId = String(req.params.roomId);
- const data = getActivityIndex(roomId);
- sendSuccess(res, data);
- } catch (error) {
- throw error;
- }
- }
- /** GET /api/dashboard/activity-ranking — 群活跃度排行榜 */
- export async function activityRanking(req: Request, res: Response): Promise<void> {
- try {
- const limit = typeof req.query.limit === 'string' ? Number(req.query.limit) : 20;
- const data = getActivityRanking(limit);
- sendSuccess(res, data);
- } catch (error) {
- throw error;
- }
- }
- /** GET /api/dashboard/reports/weekly — 周报(§11.9) */
- export async function weeklyReport(_req: Request, res: Response): Promise<void> {
- try {
- const data = generatePeriodicReport('weekly');
- sendSuccess(res, data);
- } catch (error) {
- throw error;
- }
- }
- /** GET /api/dashboard/reports/monthly — 月报(§11.9) */
- export async function monthlyReport(_req: Request, res: Response): Promise<void> {
- try {
- const data = generatePeriodicReport('monthly');
- sendSuccess(res, data);
- } catch (error) {
- throw error;
- }
- }
|