chore: 清理管理中心 fetchDashboardStats 与 GET /admin/stats 已无用的接口
This commit is contained in:
@@ -54,12 +54,6 @@ function normalizePaginatedData<T>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AdminStats {
|
|
||||||
todayBookings: number
|
|
||||||
totalOrders: number
|
|
||||||
totalBookings: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export type MemberSummary = AdminMemberSummary
|
export type MemberSummary = AdminMemberSummary
|
||||||
|
|
||||||
export interface UserMembership {
|
export interface UserMembership {
|
||||||
@@ -264,12 +258,7 @@ export const useAdminStore = defineStore('admin', () => {
|
|||||||
await fetchSchedulePreview(dto.date)
|
await fetchSchedulePreview(dto.date)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Dashboard stats ──────────────────────────────────────────────
|
// ── Teaching analytics ─────────────────────────────────────────
|
||||||
async function fetchDashboardStats(): Promise<AdminStats> {
|
|
||||||
return get<AdminStats>('/admin/stats')
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Teaching analytics ─────────────────────────────────────────
|
|
||||||
async function fetchTeachingAnalytics(month: string): Promise<TeachingAnalytics> {
|
async function fetchTeachingAnalytics(month: string): Promise<TeachingAnalytics> {
|
||||||
return get<TeachingAnalytics>('/admin/teaching-analytics', { month })
|
return get<TeachingAnalytics>('/admin/teaching-analytics', { month })
|
||||||
}
|
}
|
||||||
@@ -315,7 +304,5 @@ export const useAdminStore = defineStore('admin', () => {
|
|||||||
fetchSchedulePreview,
|
fetchSchedulePreview,
|
||||||
previewScheduleByDate,
|
previewScheduleByDate,
|
||||||
publishDaySlots,
|
publishDaySlots,
|
||||||
// Stats
|
|
||||||
fetchDashboardStats,
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,40 +4,15 @@ import { JwtAuthGuard } from '../auth/jwt-auth.guard'
|
|||||||
import { Roles } from '../auth/roles.decorator'
|
import { Roles } from '../auth/roles.decorator'
|
||||||
import { RolesGuard } from '../auth/roles.guard'
|
import { RolesGuard } from '../auth/roles.guard'
|
||||||
import { UserRole } from '@mp-pilates/shared'
|
import { UserRole } from '@mp-pilates/shared'
|
||||||
import { PrismaService } from '../prisma/prisma.service'
|
|
||||||
|
|
||||||
interface AdminStats {
|
|
||||||
todayBookings: number
|
|
||||||
totalOrders: number
|
|
||||||
totalBookings: number
|
|
||||||
}
|
|
||||||
|
|
||||||
@Controller('admin')
|
@Controller('admin')
|
||||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||||
@Roles(UserRole.ADMIN)
|
@Roles(UserRole.ADMIN)
|
||||||
export class AdminController {
|
export class AdminController {
|
||||||
constructor(private readonly prisma: PrismaService, private readonly analytics: TeachingAnalyticsService) {}
|
constructor(private readonly analytics: TeachingAnalyticsService) {}
|
||||||
|
|
||||||
@Get('teaching-analytics')
|
@Get('teaching-analytics')
|
||||||
getTeachingAnalytics(@Query('month') month: string) {
|
getTeachingAnalytics(@Query('month') month: string) {
|
||||||
return this.analytics.getMonthly(month)
|
return this.analytics.getMonthly(month)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('stats')
|
|
||||||
async getStats(): Promise<AdminStats> {
|
|
||||||
const today = new Date()
|
|
||||||
today.setUTCHours(0, 0, 0, 0)
|
|
||||||
|
|
||||||
const [todayBookings, totalOrders, totalBookings] = await Promise.all([
|
|
||||||
this.prisma.booking.count({
|
|
||||||
where: {
|
|
||||||
timeSlot: { date: today },
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
this.prisma.order.count(),
|
|
||||||
this.prisma.booking.count(),
|
|
||||||
])
|
|
||||||
|
|
||||||
return { todayBookings, totalOrders, totalBookings }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user