2025-09-13 08:35:59 +08:00
|
|
|
|
import { Controller, Get, Query, UseGuards, Req, UnauthorizedException } from '@nestjs/common';
|
2025-09-10 08:04:28 +08:00
|
|
|
|
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
|
|
|
|
|
|
import type { Request } from 'express';
|
|
|
|
|
|
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
|
|
|
|
|
import { RolesGuard } from '../../../auth/guards/RolesGuard';
|
|
|
|
|
|
import { Roles } from '../../../auth/decorators/RolesDecorator';
|
|
|
|
|
|
|
|
|
|
|
|
interface AuthenticatedRequest extends Request {
|
|
|
|
|
|
user?: {
|
|
|
|
|
|
uid: number;
|
|
|
|
|
|
username: string;
|
|
|
|
|
|
siteId: number;
|
|
|
|
|
|
userType: string;
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 定时任务日志控制器 - 管理端
|
|
|
|
|
|
* 路由前缀: /adminapi/sys/schedule-log
|
|
|
|
|
|
*/
|
|
|
|
|
|
@ApiTags('定时任务日志')
|
|
|
|
|
|
@Controller('adminapi/sys/schedule-log')
|
|
|
|
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
|
|
|
|
@Roles('admin')
|
|
|
|
|
|
export class ScheduleLogController {
|
|
|
|
|
|
constructor() {}
|
|
|
|
|
|
|
|
|
|
|
|
@Get('page')
|
|
|
|
|
|
@ApiOperation({ summary: '获取定时任务日志分页列表' })
|
|
|
|
|
|
@ApiResponse({ status: 200, description: '获取成功' })
|
|
|
|
|
|
async getPage(@Query() query: any, @Req() req: AuthenticatedRequest) {
|
2025-09-13 08:35:59 +08:00
|
|
|
|
const siteId = req.user?.siteId;
|
|
|
|
|
|
if (!siteId) {
|
|
|
|
|
|
throw new UnauthorizedException('未授权访问:缺少 site_id');
|
|
|
|
|
|
}
|
2025-09-10 08:04:28 +08:00
|
|
|
|
// TODO: 实现定时任务日志分页列表
|
2025-09-13 08:35:59 +08:00
|
|
|
|
return { list: [], total: 0 };
|
2025-09-10 08:04:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Get('list')
|
|
|
|
|
|
@ApiOperation({ summary: '获取定时任务日志列表' })
|
|
|
|
|
|
@ApiResponse({ status: 200, description: '获取成功' })
|
|
|
|
|
|
async getList(@Query() query: any, @Req() req: AuthenticatedRequest) {
|
2025-09-13 08:35:59 +08:00
|
|
|
|
const siteId = req.user?.siteId;
|
|
|
|
|
|
if (!siteId) {
|
|
|
|
|
|
throw new UnauthorizedException('未授权访问:缺少 site_id');
|
|
|
|
|
|
}
|
2025-09-10 08:04:28 +08:00
|
|
|
|
// TODO: 实现定时任务日志列表
|
2025-09-13 08:35:59 +08:00
|
|
|
|
return [];
|
2025-09-10 08:04:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Get('stats')
|
|
|
|
|
|
@ApiOperation({ summary: '获取定时任务统计信息' })
|
|
|
|
|
|
@ApiResponse({ status: 200, description: '获取成功' })
|
|
|
|
|
|
async getStats(@Req() req: AuthenticatedRequest) {
|
2025-09-13 08:35:59 +08:00
|
|
|
|
const siteId = req.user?.siteId;
|
|
|
|
|
|
if (!siteId) {
|
|
|
|
|
|
throw new UnauthorizedException('未授权访问:缺少 site_id');
|
|
|
|
|
|
}
|
2025-09-10 08:04:28 +08:00
|
|
|
|
// TODO: 实现定时任务统计信息
|
2025-09-13 08:35:59 +08:00
|
|
|
|
return { total: 0, success: 0, failed: 0 };
|
2025-09-10 08:04:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|